Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 committed Jan 14, 2025
2 parents 4ad2b51 + 24600f3 commit d34223c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 38 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,26 @@ MTProto protocol manuals: <https://core.telegram.org/mtproto>

Environment:

- A Linux distribution based on Debian (e.g. Ubuntu)
- Linux distribution based on Debian or Arch Linux, or macOS

- Native tools: `gcc` `go` `make` `cmake` `ninja` `yasm`
- Native tools: `gcc` `go` `make` `cmake` `ninja` `yasm` `meson` `pkgconf`

```shell
# for Debian based distribution
sudo apt install gcc golang make cmake ninja-build yasm
# for Arch Linux based distribution
sudo pacman -S base-devel go ninja cmake yasm meson
# for macOS
xcode-select --install # install developer tools (will open confirm dialog)
brew install go cmake ninja yasm meson pkgconf # install other tools by homebrew
```
- Android SDK: `build-tools;33.0.0` `platforms;android-33` `ndk;21.4.7075529` `cmake;3.18.1` (the default location is **$HOME/Android/SDK**, otherwise you need to specify **$ANDROID_HOME** for it)
- Android SDK: `build-tools;33.0.0` `platforms;android-33` `ndk;21.4.7075529` `cmake;3.18.1` `cmake;3.22.1` (the default location is **$HOME/Android/SDK**, otherwise you need to specify **$ANDROID_HOME** for it)

It is recommended to use [Android Studio](https://developer.android.com/studio) to install, but you can also use `sdkmanager`:
It is recommended to use [Android Studio](https://developer.android.com/studio) to install, but you can also use `sdkmanager` command on distributions based on Debian:

```shell
sudo apt install sdkmanager
sdkmanager --sdk_root $HOME/Android/SDK --install "build-tools;33.0.0" "platforms;android-33" "ndk;21.4.7075529" "cmake;3.18.1"
sdkmanager --sdk_root $HOME/Android/SDK --install "build-tools;33.0.0" "platforms;android-33" "ndk;21.4.7075529" "cmake;3.18.1" "cmake;3.22.1"
```

Build:
Expand Down Expand Up @@ -147,7 +153,7 @@ Build:
7. Build with Gradle:

```shell
./gradlew assembleMini<Debug/Release/ReleaseNoGcm>
./gradlew assemble<Release/Debug>
```

----
Expand Down
4 changes: 4 additions & 0 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def keystorePwd = null
def alias = null
def pwd = null
def sentry_token = System.getenv("SENTRY_AUTH_TOKEN")
def nagram_build_args = System.getenv("NAGRAM_BUILD_ARGS")
def sentry_upload = project.rootProject.file("sentry.properties").exists()
def disableCMakeRelWithDebInfo = System.getenv("COMPILE_NATIVE") == null

Expand All @@ -66,6 +67,7 @@ if (properties != null) {
alias = properties.getProperty("ALIAS_NAME")
pwd = properties.getProperty("ALIAS_PASS")
sentry_token = properties.getProperty("SENTRY_AUTH_TOKEN", sentry_token)
nagram_build_args = properties.getProperty("NAGRAM_BUILD_ARGS", nagram_build_args)
}

keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS")
Expand Down Expand Up @@ -394,6 +396,8 @@ android {
task.enabled = false
} else if (task.name.endsWith("GoogleServices") && task.name.contains("NoGcm")) {
task.enabled = false
} else if (task.name.contains("buildCMakeDebug") && nagram_build_args.contains("skip_buildCMakeDebug")) {
task.enabled = false
}
}

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/build_dav1d_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ checkPreRequisites
cd dav1d

## common
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/${BUILD_PLATFORM}"
LLVM_BIN="${LLVM_PREFIX}/bin"
PREFIX_D=$(realpath .)
VERSION="4.9"
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/build_ffmpeg_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ checkPreRequisites
cd ffmpeg

## common
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/${BUILD_PLATFORM}"
LLVM_BIN="${LLVM_PREFIX}/bin"
PREFIX_D=$(realpath ..)
VERSION="4.9"
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/build_libvpx_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ checkPreRequisites
cd libvpx

## common
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/${BUILD_PLATFORM}"
LLVM_BIN="${LLVM_PREFIX}/bin"
VERSION="4.9"
ANDROID_API=21
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/patch_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ patch -d ffmpeg -p1 < patches/ffmpeg/0001-compilation-magic.patch
patch -d ffmpeg -p1 < patches/ffmpeg/0002-compilation-magic-2.patch

function cp {
install -D $@
install "$1" "$2"
}

cp ffmpeg/libavformat/dv.h ffmpeg/build/arm64-v8a/include/libavformat/dv.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ public int getChatMaxUniqReactions(long dialogId) {
}

public boolean isPremiumUser(TLRPC.User currentUser) {
if (NekoConfig.localPremium.Bool()) {
if (NekoConfig.localPremium.Bool() && currentUser.id == getUserConfig().getClientUserId()) {
return true;
}
return !premiumFeaturesBlocked() && currentUser.premium && !isSupportUser(currentUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void setCurrentUser(TLRPC.User user) {
private void checkPremiumSelf(TLRPC.User oldUser, TLRPC.User newUser) {
if (oldUser != null && newUser != null && oldUser.premium != newUser.premium) {
AndroidUtilities.runOnUIThread(() -> {
getMessagesController().updatePremium(newUser.premium || NekoConfig.localPremium.Bool());
getMessagesController().updatePremium(newUser.premium);
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.currentUserPremiumStatusChanged);
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.premiumStatusChangedGlobal);

Expand Down
59 changes: 33 additions & 26 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,8 @@ public void run() {
private final static int OPTION_COPY_PHOTO = 150;
private final static int OPTION_COPY_PHOTO_AS_STICKER = 151;

private boolean isChannelBottomMuteView = false;

private final static int[] allowedNotificationsDuringChatListAnimations = new int[]{
NotificationCenter.messagesRead,
NotificationCenter.threadMessagesRead,
Expand Down Expand Up @@ -3470,7 +3472,7 @@ protected boolean canCopy() {
return true;
}
return chatActivity == null || !(
chatActivity.getDialogId() < 0 && chatActivity.getMessagesController().isChatNoForwards(-chatActivity.getDialogId()) ||
chatActivity.getDialogId() < 0 && chatActivity.getMessagesController().isChatNoForwardsWithOverride(-chatActivity.getDialogId()) ||
selectedView != null && selectedView.getMessageObject() != null && (selectedView.getMessageObject().messageOwner != null && selectedView.getMessageObject().messageOwner.noforwards)
);
}
Expand Down Expand Up @@ -9923,10 +9925,15 @@ private void createUndoView() {
return;
}
undoView = new UndoView(getContext(), this, false, themeDelegate);
undoView.setAdditionalTranslationY(AndroidUtilities.dp(51));
undoView.setAdditionalTranslationY(isBottomOverlayHidden() ? 0 : AndroidUtilities.dp(51));
contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
}

private boolean isBottomOverlayHidden() {
// na: DisableChannelMuteButton
return currentChat != null && NaConfig.INSTANCE.getDisableChannelMuteButton().Bool() && isChannelBottomMuteView && !currentChat.creator && !ChatObject.canWriteToChat(currentChat);
}

@Override
public INavigationLayout.BackButtonState getBackButtonState() {
return INavigationLayout.BackButtonState.BACK;
Expand Down Expand Up @@ -11948,7 +11955,7 @@ private void invalidateChatListViewTopPadding() {
bottomMessagesActionContainer.setTranslationY(bottomPanelTranslationYReverse);
}
if (undoView != null) {
undoView.setAdditionalTranslationY(chatActivityEnterView.getHeightWithTopView() - chatActivityEnterView.getAnimatedTop());
undoView.setAdditionalTranslationY(chatActivityEnterView.getHeightWithTopView() - chatActivityEnterView.getAnimatedTop() - (isBottomOverlayHidden() ? AndroidUtilities.dp(51) : 0));
}
if (messagesSearchListContainer != null) {
messagesSearchListContainer.setTranslationY(getHashtagTabsHeight() + contentPanTranslation);
Expand Down Expand Up @@ -17811,6 +17818,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
} else if (child == chatListView || child == chatListThanosEffect) {
int contentWidthSpec = View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY);
int h = heightSize - listViewTopHeight - (inPreviewMode && Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + blurredViewTopOffset + blurredViewBottomOffset;
h += (isBottomOverlayHidden() ? AndroidUtilities.dp(51) : 0);
if (keyboardSize > AndroidUtilities.dp(20) && getLayoutParams().height < 0 && !isInsideContainer) {
h += keyboardSize;
}
Expand Down Expand Up @@ -18031,6 +18039,9 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (!inPreviewMode) {
childTop -= chatActivityEnterView.getMeasuredHeight();
}
if (isBottomOverlayHidden()) {
childTop += AndroidUtilities.dp(51);
}
} else if (child == emptyViewContainer) {
childTop -= inputFieldHeight / 2 - (actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() / 2 : 0);
} else if (chatActivityEnterView.isPopupView(child)) {
Expand Down Expand Up @@ -18697,9 +18708,7 @@ private void addToSelectedMessages(MessageObject messageObject, boolean outside,
saveMessageItem.setVisibility(canForward);
}

if (NekoConfig.showBottomActionsWhenSelecting.Bool())
createBottomMessagesActionButtons();

createBottomMessagesActionButtons();
if (prevCantForwardCount == 0 && cantForwardMessagesCount != 0 || prevCantForwardCount != 0 && cantForwardMessagesCount == 0) {
forwardButtonAnimation = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<>();
Expand Down Expand Up @@ -26450,6 +26459,7 @@ private void updateBottomOverlay() {
bottomOverlayChatWaitsReply = false;
bottomOverlayLinks = false;
boolean forceNoBottom = false;
boolean tempMuteView = false;
if (chatMode == MODE_DEFAULT && getDialogId() != getUserConfig().getClientUserId() && userInfo != null && userInfo.contact_require_premium && !getUserConfig().isPremium()) {
bottomOverlayLinks = true;
bottomOverlayChatText.setVisibility(View.GONE);
Expand Down Expand Up @@ -26497,6 +26507,7 @@ private void updateBottomOverlay() {
}
showBottomOverlayProgress(false, false);
} else if (currentUser != null && currentUser.id == UserObject.VERIFY) {
tempMuteView = true;
if (!getMessagesController().isDialogMuted(dialog_id, getTopicId())) {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelMute), false);
bottomOverlayChatText.setEnabled(true);
Expand Down Expand Up @@ -26534,18 +26545,14 @@ private void updateBottomOverlay() {
bottomOverlayChatText.setTextInfo(LocaleController.getString(R.string.ForumReplyToMessagesInTopic));
bottomOverlayChatText.setEnabled(false);
} else if (!isThreadChat()) {
tempMuteView = true;
if (!getMessagesController().isDialogMuted(dialog_id, getTopicId())) {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelMute), false);
bottomOverlayChatText.setEnabled(true);
} else {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelUnmute), true);
bottomOverlayChatText.setEnabled(true);
}
// na: DisableChannelMuteButton
if (NaConfig.INSTANCE.getDisableChannelMuteButton().Bool()) {
bottomOverlayChatText.setText("", false);
bottomOverlayChatText.setEnabled(false);
}
showBottomOverlayProgress(false, bottomOverlayProgress.getTag() != null);
} else if (forumTopic != null && forumTopic.closed) {
if (!ChatObject.canManageTopic(currentAccount, currentChat, forumTopic)) {
Expand Down Expand Up @@ -26591,6 +26598,7 @@ private void updateBottomOverlay() {
}
}
} else if (UserObject.isReplyUser(currentUser)) {
tempMuteView = true;
if (!getMessagesController().isDialogMuted(dialog_id, getTopicId())) {
bottomOverlayChatText.setText(LocaleController.getString(R.string.ChannelMute), false);
} else {
Expand All @@ -26616,6 +26624,8 @@ private void updateBottomOverlay() {
}
}

isChannelBottomMuteView = tempMuteView;

if (currentChat != null && currentChat.gigagroup && !isReport() && chatMode == 0) {
bottomOverlayImage.setVisibility(View.VISIBLE);
} else {
Expand All @@ -26628,6 +26638,10 @@ private void updateBottomOverlay() {
bottomOverlayChat.setVisibility(View.INVISIBLE);
chatActivityEnterView.setFieldFocused(false);
chatActivityEnterView.setVisibility(View.INVISIBLE);
} else if (isBottomOverlayHidden()) {
bottomOverlayChat.setVisibility(View.INVISIBLE);
chatActivityEnterView.setFieldFocused(false);
chatActivityEnterView.setVisibility(View.INVISIBLE);
} else if (bottomOverlayLinks) {
bottomOverlayChat.setVisibility(View.VISIBLE);
chatActivityEnterView.setVisibility(View.INVISIBLE);
Expand Down Expand Up @@ -28742,7 +28756,7 @@ public int getBottomOffset(int tag) {
height += translationY;
}
height += contentPanTranslation;
return height - AndroidUtilities.dp(1.5f);
return height - AndroidUtilities.dp(1.5f) - (isBottomOverlayHidden() ? AndroidUtilities.dp(51) : 0);
}

@Override
Expand Down Expand Up @@ -31777,7 +31791,10 @@ public void dismiss(boolean animated) {
actionModeOtherItem.showSubItem(nkbtn_forward_noquote);
actionMode.setItemVisibility(delete, View.VISIBLE);
createBottomMessagesActionButtons();
bottomMessagesActionContainer.setVisibility(View.VISIBLE);
if (NekoConfig.showBottomActionsWhenSelecting.Bool())
bottomMessagesActionContainer.setVisibility(View.VISIBLE);
else
bottomMessagesActionContainer.setVisibility(View.GONE);

int translationY = chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51);
createActionMode();
Expand All @@ -31790,27 +31807,17 @@ public void dismiss(boolean animated) {
if (suggestEmojiPanel != null && suggestEmojiPanel.getVisibility() == View.VISIBLE) {
views.add(suggestEmojiPanel);
}
if (NekoConfig.showBottomActionsWhenSelecting.Bool())
actionBar.showActionMode(true, bottomMessagesActionContainer, null, views.toArray(new View[0]), new boolean[]{false, true, true}, chatListView, translationY);
else
actionBar.showActionMode(true, null, null, null, new boolean[]{false, true, true}, chatListView, translationY);

actionBar.showActionMode(true, bottomMessagesActionContainer, null, views.toArray(new View[0]), new boolean[]{false, true, true}, chatListView, translationY);
if (getParentActivity() instanceof LaunchActivity) {
((LaunchActivity) getParentActivity()).hideVisibleActionMode();
}
if (chatActivityEnterView != null && chatActivityEnterView.getEditField() != null) {
chatActivityEnterView.getEditField().setAllowDrawCursor(false);
}
} else if (bottomOverlayChat.getVisibility() == View.VISIBLE) {
if (NekoConfig.showBottomActionsWhenSelecting.Bool())
actionBar.showActionMode(true, bottomMessagesActionContainer, null, new View[]{bottomOverlayChat}, new boolean[]{true}, chatListView, translationY);
else
actionBar.showActionMode(true, null, null, null, new boolean[]{true}, chatListView, translationY);
actionBar.showActionMode(true, bottomMessagesActionContainer, null, new View[]{bottomOverlayChat}, new boolean[]{true}, chatListView, translationY);
} else {
if (NekoConfig.showBottomActionsWhenSelecting.Bool())
actionBar.showActionMode(true, bottomMessagesActionContainer, null, null, null, chatListView, translationY);
else
actionBar.showActionMode(true, null, null, null, null, chatListView, translationY);
actionBar.showActionMode(true, bottomMessagesActionContainer, null, null, null, chatListView, translationY);
}
closeMenu();
chatLayoutManager.setCanScrollVertically(true);
Expand Down

0 comments on commit d34223c

Please sign in to comment.