From 3facd9f882a0a7c5216456fd9050e42868fedd6a Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 11 Aug 2023 22:10:29 +0800 Subject: [PATCH] fix: merge 9.7.6 --- TMessagesProj/jni/TgNetWrapper.cpp | 1 + TMessagesProj/jni/ffmpeg | 1 + .../telegram/messenger/ApplicationLoader.java | 4 + .../telegram/messenger/BillingController.java | 2 +- .../messenger/MessagesController.java | 3 +- .../messenger/utils/BillingUtilities.java | 108 -------- .../telegram/ui/Cells/ChatMessageCell.java | 8 +- .../ui/Cells/DrawerActionCheckCell.java | 6 - .../java/org/telegram/ui/ChatActivity.java | 9 +- .../ui/Components/ChatActivityEnterView.java | 2 +- .../java/org/telegram/ui/LoginActivity.java | 7 - .../java/org/telegram/ui/ProfileActivity.java | 2 +- .../ui/SelectAnimatedEmojiDialog.java | 2 +- .../telegram/ui/Stories/UserListPoller.java | 3 +- .../ui/Stories/recorder/PaintView.java | 259 +++++++++--------- .../nekomimi/nekogram/DatacenterActivity.java | 2 +- .../nekogram/settings/EmojiSetCell.java | 2 +- .../settings/NekoAccountSettingsActivity.java | 2 +- .../NekoPasscodeSettingsActivity.java | 4 +- .../tw/nekomimi/nekogram/ui/BottomBuilder.kt | 3 +- 20 files changed, 156 insertions(+), 274 deletions(-) create mode 160000 TMessagesProj/jni/ffmpeg delete mode 100644 TMessagesProj/src/main/java/org/telegram/messenger/utils/BillingUtilities.java diff --git a/TMessagesProj/jni/TgNetWrapper.cpp b/TMessagesProj/jni/TgNetWrapper.cpp index 51bffcb82a..7ef59aaa78 100644 --- a/TMessagesProj/jni/TgNetWrapper.cpp +++ b/TMessagesProj/jni/TgNetWrapper.cpp @@ -549,6 +549,7 @@ static JNINativeMethod ConnectionsManagerMethods[] = { {"native_setNetworkAvailable", "(IZIZ)V", (void *) setNetworkAvailable}, {"native_setPushConnectionEnabled", "(IZ)V", (void *) setPushConnectionEnabled}, {"native_setJava", "(Z)V", (void *) setJava}, + {"native_setJava", "(I)V", (void *) setJava1}, {"native_applyDnsConfig", "(IJLjava/lang/String;I)V", (void *) applyDnsConfig}, {"native_checkProxy", "(ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/telegram/tgnet/RequestTimeDelegate;)J", (void *) checkProxy}, {"native_onHostNameResolved", "(Ljava/lang/String;JLjava/lang/String;Z)V", (void *) onHostNameResolved}, diff --git a/TMessagesProj/jni/ffmpeg b/TMessagesProj/jni/ffmpeg new file mode 160000 index 0000000000..4bc4cafaef --- /dev/null +++ b/TMessagesProj/jni/ffmpeg @@ -0,0 +1 @@ +Subproject commit 4bc4cafaef8a55462138d7b6f7579c1522de26dc diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index ee32ea49d6..3ce295fe2f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -56,6 +56,9 @@ import static android.os.Build.VERSION.SDK_INT; public class ApplicationLoader extends Application { + + private static ApplicationLoader applicationLoaderInstance; + private static PendingIntent pendingIntent; @SuppressLint("StaticFieldLeak") @@ -285,6 +288,7 @@ public ApplicationLoader() { @Override public void onCreate() { + applicationLoaderInstance = this; try { applicationContext = getApplicationContext(); } catch (Throwable ignore) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BillingController.java b/TMessagesProj/src/main/java/org/telegram/messenger/BillingController.java index 3bdcf29583..91d1652f04 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BillingController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BillingController.java @@ -13,7 +13,7 @@ import com.google.android.exoplayer2.util.Util; -import org.telegram.messenger.utils.BillingUtilities; +//import org.telegram.messenger.utils.BillingUtilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.ui.PremiumPreviewFragment; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 4ef4ee2b67..4b2e253e64 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -17533,7 +17533,6 @@ public boolean canAddToForward(TLRPC.Dialog d) { } } return canAddToForward; ->>>>>>> off/master } public void sortDialogs(LongSparseArray chatsDict) { @@ -18522,7 +18521,7 @@ public StoriesController getStoriesController() { if (storiesController != null) { return storiesController; } - synchronized (lockObjects[currentAccount]) { + synchronized (lockObject) { if (storiesController != null) { return storiesController; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/utils/BillingUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/utils/BillingUtilities.java deleted file mode 100644 index 7e07c9a5a1..0000000000 --- a/TMessagesProj/src/main/java/org/telegram/messenger/utils/BillingUtilities.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.telegram.messenger.utils; - -import android.content.Context; -import android.util.Base64; - -import androidx.core.util.Pair; - -import com.android.billingclient.api.AccountIdentifiers; -import com.android.billingclient.api.Purchase; -import com.google.android.exoplayer2.util.Util; -import com.google.common.base.Charsets; - -import org.json.JSONObject; -import org.telegram.messenger.AccountInstance; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.UserConfig; -import org.telegram.tgnet.SerializedData; -import org.telegram.tgnet.TLRPC; - -import java.io.InputStream; -import java.util.Iterator; -import java.util.Map; - -public class BillingUtilities { - private static final String CURRENCY_FILE = "currencies.json"; - private static final String CURRENCY_EXP = "exp"; - - @SuppressWarnings("ConstantConditions") - public static void extractCurrencyExp(Map currencyExpMap) { - if (!currencyExpMap.isEmpty()) { - return; - } - try { - Context ctx = ApplicationLoader.applicationContext; - InputStream in = ctx.getAssets().open(CURRENCY_FILE); - JSONObject obj = new JSONObject(new String(Util.toByteArray(in), Charsets.UTF_8)); - Iterator it = obj.keys(); - while (it.hasNext()) { - String key = it.next(); - JSONObject currency = obj.optJSONObject(key); - currencyExpMap.put(key, currency.optInt(CURRENCY_EXP)); - } - in.close(); - } catch (Exception e) { - FileLog.e(e); - } - } - - public static Pair createDeveloperPayload(TLRPC.InputStorePaymentPurpose paymentPurpose, AccountInstance accountInstance) { - long currentAccountId = accountInstance.getUserConfig().getClientUserId(); - byte[] currentAccountIdBytes = String.valueOf(currentAccountId).getBytes(Charsets.UTF_8); - String obfuscatedAccountId = Base64.encodeToString(currentAccountIdBytes, Base64.DEFAULT); - - SerializedData serializedData = new SerializedData(paymentPurpose.getObjectSize()); - paymentPurpose.serializeToStream(serializedData); - String obfuscatedData = Base64.encodeToString(serializedData.toByteArray(), Base64.DEFAULT); - serializedData.cleanup(); - - return Pair.create(obfuscatedAccountId, obfuscatedData); - } - - private static AccountInstance findAccountById(long accountId) { - AccountInstance result = null; - for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) { - AccountInstance acc = AccountInstance.getInstance(i); - if (acc.getUserConfig().getClientUserId() == accountId) { - result = acc; - break; - } - } - return result; - } - - public static Pair extractDeveloperPayload(Purchase purchase) { - AccountIdentifiers identifiers = purchase.getAccountIdentifiers(); - if (identifiers == null) { - FileLog.d("Billing: Extract payload. No AccountIdentifiers"); - return null; - } - String obfuscatedAccountId = identifiers.getObfuscatedAccountId(); - String obfuscatedData = identifiers.getObfuscatedProfileId(); - if (obfuscatedAccountId == null || obfuscatedAccountId.isEmpty() || obfuscatedData == null || obfuscatedData.isEmpty()) { - FileLog.d("Billing: Extract payload. Empty AccountIdentifiers"); - return null; - } - - try { - byte[] obfuscatedDataBytes = Base64.decode(obfuscatedData, Base64.DEFAULT); - SerializedData data = new SerializedData(obfuscatedDataBytes); - TLRPC.InputStorePaymentPurpose purpose = TLRPC.InputStorePaymentPurpose.TLdeserialize(data, data.readInt32(true), true); - data.cleanup(); - - byte[] obfuscatedAccountIdBytes = Base64.decode(obfuscatedAccountId, Base64.DEFAULT); - long accountId = Long.parseLong(new String(obfuscatedAccountIdBytes, Charsets.UTF_8)); - - AccountInstance acc = findAccountById(accountId); - if (acc == null) { - FileLog.d("Billing: Extract payload. AccountInstance not found"); - return null; - } - return Pair.create(acc, purpose); - } catch (Exception e) { - FileLog.e("Billing: Extract Payload", e); - return null; - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 3a5439334d..ac5fcaa89b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -9188,16 +9188,12 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto if (timeTextWidth < 0) { timeTextWidth = AndroidUtilities.dp(10); } -<<<<<<< HEAD - CharSequence currentTime = Emoji.replaceEmoji(currentTimeString, Theme.chat_timePaint.getFontMetricsInt(), AndroidUtilities.dp(12), false); - timeLayout = new StaticLayout(currentTime, Theme.chat_timePaint, timeTextWidth + AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); -======= if (currentTimeString != null) { - timeLayout = new StaticLayout(currentTimeString, Theme.chat_timePaint, timeTextWidth + AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + CharSequence currentTime = Emoji.replaceEmoji(currentTimeString, Theme.chat_timePaint.getFontMetricsInt(), AndroidUtilities.dp(12), false); + timeLayout = new StaticLayout(currentTime, Theme.chat_timePaint, timeTextWidth + AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } else { timeLayout = null; } ->>>>>>> off/master if (mediaBackground) { if (currentMessageObject.isOutOwner()) { timeX = layoutWidth - timeWidth - AndroidUtilities.dp(42.0f); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCheckCell.java index d75d28200b..b8b4f7f3bb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCheckCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCheckCell.java @@ -101,12 +101,6 @@ public void setTextAndCheck(String text, boolean checked, boolean divider) { setWillNotDraw(!divider); } - public void setColors(String key, String switchKey, String switchKeyChecked, String switchThumb, String switchThumbChecked) { - textView.setTextColor(Theme.getColor(key)); - checkBox.setColors(switchKey, switchKeyChecked, switchThumb, switchThumbChecked); - textView.setTag(key); - } - public void setTypeface(Typeface typeface) { textView.setTypeface(typeface); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 33af5b0438..1822b06ace 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -4244,7 +4244,7 @@ private void processTouchEvent(MotionEvent e) { currentEncryptedChat == null && message.getId() < 0 || bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && allowReplyOnOpenTopic || message.wasJustSent) || currentChat != null && (ChatObject.isNotInChat(currentChat) && !isThreadChat() || ChatObject.isChannel(currentChat) && !ChatObject.canPost(currentChat) && !currentChat.megagroup || !ChatObject.canSendMessages(currentChat)) || - textSelectionHelper.isSelectionMode()) { + textSelectionHelper.isInSelectionMode()) { if (!canSendInCommentGroup()) { slidingView.setSlidingOffset(0); slidingView = null; @@ -24922,7 +24922,7 @@ public void setAutoDeleteHistory(int time, int action) { } else if (type == 21) { items.add(LocaleController.getString("ImportProxyList", R.string.ImportProxyList)); options.add(5); - icons.add(R.drawable.proxy_on); + icons.add(R.drawable.msg2_proxy_on); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); options.add(OPTION_ADD_TO_STICKERS_OR_MASKS); @@ -28864,7 +28864,6 @@ private void didPressMessageUrl(CharacterStyle url, boolean longPress, MessageOb }, (which, text, __) -> { if (which == 0) { - logSponsoredClicked(finalMessageObject); processExternalUrl(1, urlFinal, url, finalCell, false); } else if (which == 1 || which == 3) { // Copy / ShareMessage @@ -34152,7 +34151,7 @@ private void doRepeatMessage(boolean isLongClick, ArrayList messa } } else if ((selectedObject.isSticker() || selectedObject.isAnimatedSticker()) && selectedObject.getDocument() != null) { SendMessagesHelper.getInstance(currentAccount) - .sendSticker(selectedObject.getDocument(), null, dialog_id, replyTo, getThreadMessage(), null, null, true, 0, false); + .sendSticker(selectedObject.getDocument(), null, dialog_id, replyTo, getThreadMessage(), null, null, true, 0, false, null); } return; } @@ -34202,7 +34201,7 @@ public void invertReplyMessage(boolean isLongClick) { } else if ((selectedObject.isSticker() || selectedObject.isAnimatedSticker()) && selectedObject.getDocument() != null) { SendMessagesHelper.getInstance(currentAccount) .sendSticker(selectedObject.getDocument(), null, dialog_id, replyTo, getThreadMessage(), null - , null, true, 0, false); + , null, true, 0, false, null); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index b7b8157396..d02eae5eaa 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -11716,7 +11716,7 @@ protected void dispatchDraw(Canvas canvas) { } } - private int getThemedColor(int key) { + int getThemedColor(int key) { Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null; return color != null ? color : Theme.getColor(key); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index 1cbb643293..4d1b219e47 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -532,9 +532,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { marginLayoutParams = (MarginLayoutParams) backButtonView.getLayoutParams(); marginLayoutParams.topMargin = AndroidUtilities.dp(16) + statusBarHeight; - marginLayoutParams = (MarginLayoutParams) proxyButtonView.getLayoutParams(); - marginLayoutParams.topMargin = AndroidUtilities.dp(16) + statusBarHeight; - marginLayoutParams = (MarginLayoutParams) radialProgressView.getLayoutParams(); marginLayoutParams.topMargin = AndroidUtilities.dp(16) + statusBarHeight; @@ -7949,10 +7946,6 @@ private void updateColors() { backButtonView.setColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); backButtonView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector))); - proxyDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.SRC_IN)); - proxyDrawable.setColorKey(Theme.key_windowBackgroundWhiteBlackText); - proxyButtonView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector))); - radialProgressView.setProgressColor(Theme.getColor(Theme.key_chats_actionBackground)); floatingButtonIcon.setColor(Theme.getColor(Theme.key_chats_actionIcon)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 31c65c267c..d339405cef 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -9958,7 +9958,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { } else if (position == privacyRow) { textCell.setTextAndIcon(LocaleController.getString("PrivacySettings", R.string.PrivacySettings), R.drawable.msg_secret, true); } else if (position == dataRow) { - textCell.setTextAndIcon(LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.baseline_data_usage_24, true); + textCell.setTextAndIcon(LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg_filled_storageusage, true); } else if (position == chatRow) { textCell.setTextAndIcon(LocaleController.getString("ChatSettings", R.string.ChatSettings), R.drawable.msg_msgbubble3, true); } else if (position == stickersRow) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java index eb15cc031d..934d58c46a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java @@ -2976,7 +2976,7 @@ public void preload(int type, int account) { } } - private static boolean[] preloaded = new boolean[UserConfig.MAX_ACCOUNT_COUNT]; + private static boolean[] preloaded = new boolean[SharedConfig.activeAccounts.size()]; public static void preload(int account) { if (preloaded[account] || MediaDataController.getInstance(account) == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/UserListPoller.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/UserListPoller.java index 8dbac0efa6..5b7ddfa381 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/UserListPoller.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/UserListPoller.java @@ -9,6 +9,7 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.SharedConfig; import org.telegram.messenger.UserConfig; import org.telegram.messenger.support.LongSparseLongArray; import org.telegram.tgnet.ConnectionsManager; @@ -21,7 +22,7 @@ public class UserListPoller { - private static UserListPoller[] istances = new UserListPoller[UserConfig.MAX_ACCOUNT_COUNT]; + private static UserListPoller[] istances = new UserListPoller[SharedConfig.activeAccounts.size()]; final int currentAccount; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PaintView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PaintView.java index fb39c912fd..6c0d9def2f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PaintView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PaintView.java @@ -59,9 +59,9 @@ import androidx.dynamicanimation.animation.SpringAnimation; import androidx.dynamicanimation.animation.SpringForce; -import com.google.android.gms.vision.Frame; -import com.google.android.gms.vision.face.Face; -import com.google.android.gms.vision.face.FaceDetector; +//import com.google.android.gms.vision.Frame; +//import com.google.android.gms.vision.face.Face; +//import com.google.android.gms.vision.face.FaceDetector; import org.checkerframework.checker.units.qual.A; import org.telegram.messenger.AndroidUtilities; @@ -100,7 +100,7 @@ import org.telegram.ui.Components.Paint.PaintTypeface; import org.telegram.ui.Components.Paint.Painting; import org.telegram.ui.Components.Paint.PersistColorPalette; -import org.telegram.ui.Components.Paint.PhotoFace; +//import org.telegram.ui.Components.Paint.PhotoFace; import org.telegram.ui.Components.Paint.RenderView; import org.telegram.ui.Components.Paint.Swatch; import org.telegram.ui.Components.Paint.UndoStore; @@ -193,7 +193,7 @@ public void set(float val) { } }; - private ArrayList faces; +// private ArrayList faces; private int originalBitmapRotation; private BigInteger lcm; @@ -1697,61 +1697,61 @@ private void setupEntities() { } } - private int getFrameRotation() { - switch (originalBitmapRotation) { - case 90: return Frame.ROTATION_90; - case 180: return Frame.ROTATION_180; - case 270: return Frame.ROTATION_270; - default: return Frame.ROTATION_0; - } - } +// private int getFrameRotation() { +// switch (originalBitmapRotation) { +// case 90: return Frame.ROTATION_90; +// case 180: return Frame.ROTATION_180; +// case 270: return Frame.ROTATION_270; +// default: return Frame.ROTATION_0; +// } +// } private boolean isSidewardOrientation() { return originalBitmapRotation % 360 == 90 || originalBitmapRotation % 360 == 270; } private void detectFaces() { - queue.postRunnable(() -> { - FaceDetector faceDetector = null; - try { - faceDetector = new FaceDetector.Builder(getContext()) - .setMode(FaceDetector.ACCURATE_MODE) - .setLandmarkType(FaceDetector.ALL_LANDMARKS) - .setTrackingEnabled(false).build(); - if (!faceDetector.isOperational()) { - if (BuildVars.LOGS_ENABLED) { - FileLog.e("face detection is not operational"); - } - return; - } - - Frame frame = new Frame.Builder().setBitmap(facesBitmap).setRotation(getFrameRotation()).build(); - SparseArray faces; - try { - faces = faceDetector.detect(frame); - } catch (Throwable e) { - FileLog.e(e); - return; - } - ArrayList result = new ArrayList<>(); - Size targetSize = getPaintingSize(); - for (int i = 0; i < faces.size(); i++) { - int key = faces.keyAt(i); - Face f = faces.get(key); - PhotoFace face = new PhotoFace(f, facesBitmap, targetSize, isSidewardOrientation()); - if (face.isSufficient()) { - result.add(face); - } - } - PaintView.this.faces = result; - } catch (Exception e) { - FileLog.e(e); - } finally { - if (faceDetector != null) { - faceDetector.release(); - } - } - }, 200); +// queue.postRunnable(() -> { +// FaceDetector faceDetector = null; +// try { +// faceDetector = new FaceDetector.Builder(getContext()) +// .setMode(FaceDetector.ACCURATE_MODE) +// .setLandmarkType(FaceDetector.ALL_LANDMARKS) +// .setTrackingEnabled(false).build(); +// if (!faceDetector.isOperational()) { +// if (BuildVars.LOGS_ENABLED) { +// FileLog.e("face detection is not operational"); +// } +// return; +// } +// +// Frame frame = new Frame.Builder().setBitmap(facesBitmap).setRotation(getFrameRotation()).build(); +// SparseArray faces; +// try { +// faces = faceDetector.detect(frame); +// } catch (Throwable e) { +// FileLog.e(e); +// return; +// } +// ArrayList result = new ArrayList<>(); +// Size targetSize = getPaintingSize(); +// for (int i = 0; i < faces.size(); i++) { +// int key = faces.keyAt(i); +// Face f = faces.get(key); +// PhotoFace face = new PhotoFace(f, facesBitmap, targetSize, isSidewardOrientation()); +// if (face.isSufficient()) { +// result.add(face); +// } +// } +// PaintView.this.faces = result; +// } catch (Exception e) { +// FileLog.e(e); +// } finally { +// if (faceDetector != null) { +// faceDetector.release(); +// } +// } +// }, 200); } @Override @@ -3042,85 +3042,86 @@ private PaintView.StickerPosition calculateStickerPosition(TLRPC.Document docume baseScale = 0.75f; } PaintView.StickerPosition defaultPosition = new PaintView.StickerPosition(centerPositionForEntity(), baseScale, rotation); - if (maskCoords == null || faces == null || faces.size() == 0) { - return defaultPosition; - } else { - int anchor = maskCoords.n; - - PhotoFace face = getRandomFaceWithVacantAnchor(anchor, document.id, maskCoords); - if (face == null) { - return defaultPosition; - } - - Point referencePoint = face.getPointForAnchor(anchor); - float referenceWidth = face.getWidthForAnchor(anchor); - float angle = face.getAngle(); - Size baseSize = baseStickerSize(); - - float scale = (float) (referenceWidth / baseSize.width * maskCoords.zoom); - -// float radAngle = (float) Math.toRadians(angle); -// float xCompX = (float) (Math.sin(Math.PI / 2.0f - radAngle) * referenceWidth * maskCoords.x); -// float xCompY = (float) (Math.cos(Math.PI / 2.0f - radAngle) * referenceWidth * maskCoords.x); + return defaultPosition; +// if (maskCoords == null || faces == null || faces.size() == 0) { +// return defaultPosition; +// } else { +// int anchor = maskCoords.n; // -// float yCompX = (float) (Math.cos(Math.PI / 2.0f + radAngle) * referenceWidth * maskCoords.y); -// float yCompY = (float) (Math.sin(Math.PI / 2.0f + radAngle) * referenceWidth * maskCoords.y); - - float x = referencePoint.x; - float y = referencePoint.y; - - return new PaintView.StickerPosition(new Point(x, y), scale, angle); - } - } - - private PhotoFace getRandomFaceWithVacantAnchor(int anchor, long documentId, TLRPC.TL_maskCoords maskCoords) { - if (anchor < 0 || anchor > 3 || faces.isEmpty()) { - return null; - } - - int count = faces.size(); - int randomIndex = Utilities.random.nextInt(count); - int remaining = count; - - PhotoFace selectedFace = null; - for (int i = randomIndex; remaining > 0; i = (i + 1) % count, remaining--) { - PhotoFace face = faces.get(i); - if (!isFaceAnchorOccupied(face, anchor, documentId, maskCoords)) { - return face; - } - } - - return selectedFace; +// PhotoFace face = getRandomFaceWithVacantAnchor(anchor, document.id, maskCoords); +// if (face == null) { +// return defaultPosition; +// } +// +// Point referencePoint = face.getPointForAnchor(anchor); +// float referenceWidth = face.getWidthForAnchor(anchor); +// float angle = face.getAngle(); +// Size baseSize = baseStickerSize(); +// +// float scale = (float) (referenceWidth / baseSize.width * maskCoords.zoom); +// +//// float radAngle = (float) Math.toRadians(angle); +//// float xCompX = (float) (Math.sin(Math.PI / 2.0f - radAngle) * referenceWidth * maskCoords.x); +//// float xCompY = (float) (Math.cos(Math.PI / 2.0f - radAngle) * referenceWidth * maskCoords.x); +//// +//// float yCompX = (float) (Math.cos(Math.PI / 2.0f + radAngle) * referenceWidth * maskCoords.y); +//// float yCompY = (float) (Math.sin(Math.PI / 2.0f + radAngle) * referenceWidth * maskCoords.y); +// +// float x = referencePoint.x; +// float y = referencePoint.y; +// +// return new PaintView.StickerPosition(new Point(x, y), scale, angle); +// } } - private boolean isFaceAnchorOccupied(PhotoFace face, int anchor, long documentId, TLRPC.TL_maskCoords maskCoords) { - Point anchorPoint = face.getPointForAnchor(anchor); - if (anchorPoint == null) { - return true; - } - - float minDistance = face.getWidthForAnchor(0) * 1.1f; - - for (int index = 0; index < entitiesView.getChildCount(); index++) { - View view = entitiesView.getChildAt(index); - if (!(view instanceof StickerView)) { - continue; - } - - StickerView stickerView = (StickerView) view; - if (stickerView.getAnchor() != anchor) { - continue; - } - - Point location = stickerView.getPosition(); - float distance = (float)Math.hypot(location.x - anchorPoint.x, location.y - anchorPoint.y); - if ((documentId == stickerView.getSticker().id || faces.size() > 1) && distance < minDistance) { - return true; - } - } +// private PhotoFace getRandomFaceWithVacantAnchor(int anchor, long documentId, TLRPC.TL_maskCoords maskCoords) { +// if (anchor < 0 || anchor > 3 || faces.isEmpty()) { +// return null; +// } +// +// int count = faces.size(); +// int randomIndex = Utilities.random.nextInt(count); +// int remaining = count; +// +// PhotoFace selectedFace = null; +// for (int i = randomIndex; remaining > 0; i = (i + 1) % count, remaining--) { +// PhotoFace face = faces.get(i); +// if (!isFaceAnchorOccupied(face, anchor, documentId, maskCoords)) { +// return face; +// } +// } +// +// return selectedFace; +// } - return false; - } +// private boolean isFaceAnchorOccupied(PhotoFace face, int anchor, long documentId, TLRPC.TL_maskCoords maskCoords) { +// Point anchorPoint = face.getPointForAnchor(anchor); +// if (anchorPoint == null) { +// return true; +// } +// +// float minDistance = face.getWidthForAnchor(0) * 1.1f; +// +// for (int index = 0; index < entitiesView.getChildCount(); index++) { +// View view = entitiesView.getChildAt(index); +// if (!(view instanceof StickerView)) { +// continue; +// } +// +// StickerView stickerView = (StickerView) view; +// if (stickerView.getAnchor() != anchor) { +// continue; +// } +// +// Point location = stickerView.getPosition(); +// float distance = (float)Math.hypot(location.x - anchorPoint.x, location.y - anchorPoint.y); +// if ((documentId == stickerView.getSticker().id || faces.size() > 1) && distance < minDistance) { +// return true; +// } +// } +// +// return false; +// } public PhotoView createPhoto(String path, boolean select) { Size size = basePhotoSize(path); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DatacenterActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DatacenterActivity.java index 5f332b19c1..681a605dd0 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DatacenterActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DatacenterActivity.java @@ -360,7 +360,7 @@ public void setDC(NekoConfig.DatacenterInfo info, boolean divider) { } public void updateStatus() { - String colorKey; + int colorKey; if (currentInfo.checking) { valueTextView.setText(LocaleController.getString("Checking", R.string.Checking)); colorKey = Theme.key_windowBackgroundWhiteGrayText2; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/EmojiSetCell.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/EmojiSetCell.java index 971b0fd7aa..1a7957e074 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/EmojiSetCell.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/EmojiSetCell.java @@ -110,7 +110,7 @@ public void setText(CharSequence text, BufferType type) { if (selection) { checkBox = new CheckBox2(context, 21); - checkBox.setColor(null, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck); + checkBox.setColor(-1, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck); checkBox.setDrawUnchecked(false); checkBox.setDrawBackgroundAsArc(3); addView(checkBox, LayoutHelper.createFrameRelatively(24, 24, Gravity.START, 34, 30, 0, 0)); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java index 7829106101..8779e4457d 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java @@ -309,7 +309,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); if (position == deleteAccountRow) { textCell.setText(LocaleController.getString("DeleteAccount", R.string.DeleteAccount), false); - textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText)); + textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3)); } break; } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoPasscodeSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoPasscodeSettingsActivity.java index d65cd893ce..cb7d044004 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoPasscodeSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoPasscodeSettingsActivity.java @@ -239,10 +239,10 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (position == setPanicCodeRow) { textCell.setText(PasscodeHelper.hasPanicCode() ? LocaleController.getString("PasscodePanicCodeEdit", R.string.PasscodePanicCodeEdit) : LocaleController.getString("PasscodePanicCodeSet", R.string.PasscodePanicCodeSet), removePanicCodeRow != -1); } else if (position == clearPasscodesRow) { - textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText)); + textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3)); textCell.setText("Clear passcodes", false); } else if (position == removePanicCodeRow) { - textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText)); + textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3)); textCell.setText(LocaleController.getString("PasscodePanicCodeRemove", R.string.PasscodePanicCodeRemove), false); } break; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt index b3e17252fa..5f448bf315 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt @@ -11,6 +11,7 @@ import org.telegram.messenger.LocaleController import org.telegram.messenger.R import org.telegram.ui.ActionBar.BottomSheet import org.telegram.ui.ActionBar.Theme +import org.telegram.ui.ActionBar.Theme.key_dialogTextRed import org.telegram.ui.Cells.HeaderCell import org.telegram.ui.Cells.RadioButtonCell import org.telegram.ui.Cells.TextCell @@ -224,7 +225,7 @@ class BottomBuilder(val ctx: Context, val needFocus: Boolean = true, val bgColor listener?.invoke(this) } if (red) { - setColors("key_dialogTextRed", "key_dialogTextRed") + setColors(key_dialogTextRed, key_dialogTextRed) } this@BottomBuilder.rootView.addView(this, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, rtl)) }