1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-06 23:53:47 +00:00
This commit is contained in:
世界 2020-10-18 04:28:53 +00:00
parent 8d3ae5c943
commit 2682f3dbfc
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
12 changed files with 121 additions and 56 deletions

View File

@ -5,8 +5,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def verName = "7.1.3-preview04"
def verCode = 79
def verName = "7.1.3-rc04"
def verCode = 80
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -57,7 +57,7 @@ buildscript {
}
dependencies {
classpath 'cn.hutool:hutool-all:5.4.3'
classpath 'cn.hutool:hutool-all:5.4.5'
}
}
@ -74,7 +74,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.5.0-alpha04'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.0'
implementation 'androidx.exifinterface:exifinterface:1.3.1'
implementation "androidx.interpolator:interpolator:1.0.0"
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
@ -101,8 +101,8 @@ dependencies {
implementation 'dnsjava:dnsjava:3.3.0'
implementation 'org.dizitart:nitrite:3.4.2'
implementation 'cn.hutool:hutool-core:5.4.4'
implementation 'cn.hutool:hutool-crypto:5.4.4'
implementation 'cn.hutool:hutool-core:5.4.5'
implementation 'cn.hutool:hutool-crypto:5.4.5'
implementation project(":openpgp-api")
@ -291,7 +291,6 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
signingConfig signingConfigs.release
}
}

View File

@ -58,6 +58,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
public class MessageObject {
@ -2579,7 +2580,7 @@ public class MessageObject {
} else {
isRestrictedMessage = false;
String restrictionReason = MessagesController.getRestrictionReason(messageOwner.restriction_reason);
if (!TextUtils.isEmpty(restrictionReason)) {
if (!TextUtils.isEmpty(restrictionReason) && !NekoConfig.ignoreContentRestrictions) {
messageText = restrictionReason;
isRestrictedMessage = true;
} else if (!isMediaEmpty()) {

View File

@ -13304,7 +13304,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
if (reason != null) {
showCantOpenAlert(fragment, reason);
return false;
if (!NekoConfig.ignoreContentRestrictions) return false;
}
if (messageId != 0 && originalMessage != null && chat != null && chat.access_hash == 0) {
int did = (int) originalMessage.getDialogId();
@ -13369,9 +13369,11 @@ public class MessagesController extends BaseController implements NotificationCe
closeLast = true;
}
}
if (reason != null && !NekoConfig.ignoreContentRestrictions) {
if (reason != null) {
showCantOpenAlert(fragment, reason);
} else {
if (!NekoConfig.ignoreContentRestrictions) return;
}
Bundle args = new Bundle();
if (chat != null) {
args.putInt("chat_id", chat.id);
@ -13385,7 +13387,7 @@ public class MessagesController extends BaseController implements NotificationCe
} else {
fragment.presentFragment(new ChatActivity(args), closeLast);
}
}
}
public void openByUserName(String username, final BaseFragment fragment, final int type) {

View File

@ -44,6 +44,8 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
public class MessagesStorage extends BaseController {
@ -10888,7 +10890,7 @@ public class MessagesStorage extends BaseController {
}
if (!usersToLoad.isEmpty()) {
cursor = getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, status, name FROM users WHERE uid IN(%s)", TextUtils.join(",", usersToLoad)));
cursor = getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, status, name, uid FROM users WHERE uid IN(%s)", TextUtils.join(",", usersToLoad)));
while (cursor.next()) {
String name = cursor.stringValue(2);
String tName = LocaleController.getInstance().getTranslitString(name);
@ -10901,11 +10903,14 @@ public class MessagesStorage extends BaseController {
username = name.substring(usernamePos + 3);
}
int found = 0;
int uid = cursor.intValue(3);
for (String q : search) {
if (name.startsWith(q) || name.contains(" " + q) || tName != null && (tName.startsWith(q) || tName.contains(" " + q))) {
found = 1;
} else if (username != null && username.startsWith(q)) {
found = 2;
} else if (NumberUtil.isInteger(q) && (NumberUtil.parseInt(q) == uid || q.length() > 3 && StrUtil.utf8Str(uid).contains(q))) {
found = 3;
}
if (found != 0) {
NativeByteBuffer data = cursor.byteBufferValue(0);
@ -10918,8 +10923,10 @@ public class MessagesStorage extends BaseController {
}
if (found == 1) {
dialogSearchResult.name = AndroidUtilities.generateSearchName(user.first_name, user.last_name, q);
} else {
} else if (found == 2) {
dialogSearchResult.name = AndroidUtilities.generateSearchName("@" + user.username, null, "@" + q);
} else {
dialogSearchResult.name = AndroidUtilities.generateSearchName("ID: " + uid, null, q);
}
dialogSearchResult.object = user;
resultCount++;
@ -10932,15 +10939,22 @@ public class MessagesStorage extends BaseController {
}
if (!chatsToLoad.isEmpty()) {
cursor = getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, name FROM chats WHERE uid IN(%s)", TextUtils.join(",", chatsToLoad)));
cursor = getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, name, uid FROM chats WHERE uid IN(%s)", TextUtils.join(",", chatsToLoad)));
while (cursor.next()) {
String name = cursor.stringValue(1);
String tName = LocaleController.getInstance().getTranslitString(name);
if (name.equals(tName)) {
tName = null;
}
int chatId = cursor.intValue(2);
for (String q : search) {
int found = 0;
if (name.startsWith(q) || name.contains(" " + q) || tName != null && (tName.startsWith(q) || tName.contains(" " + q))) {
found = 1;
} else if (NumberUtil.isInteger(q) && (NumberUtil.parseInt(q) == chatId || q.length() > 3 && StrUtil.utf8Str(chatId).contains(q))) {
found = 2;
}
if (found > 0) {
NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) {
TLRPC.Chat chat = TLRPC.Chat.TLdeserialize(data, data.readInt32(false), false);
@ -10948,7 +10962,11 @@ public class MessagesStorage extends BaseController {
if (!(chat == null || chat.deactivated || ChatObject.isChannel(chat) && ChatObject.isNotInChat(chat))) {
long dialog_id = -chat.id;
DialogsSearchAdapter.DialogSearchResult dialogSearchResult = dialogsResult.get(dialog_id);
if (found == 1) {
dialogSearchResult.name = AndroidUtilities.generateSearchName(chat.title, null, q);
} else {
dialogSearchResult.name = AndroidUtilities.generateSearchName("ID: " + chatId, null, q);
}
dialogSearchResult.object = chat;
resultCount++;
}
@ -10974,6 +10992,8 @@ public class MessagesStorage extends BaseController {
if (usernamePos != -1) {
username = name.substring(usernamePos + 2);
}
int user_id = cursor.intValue(2);
int found = 0;
for (int a = 0; a < search.length; a++) {
String q = search[a];
@ -10981,6 +11001,8 @@ public class MessagesStorage extends BaseController {
found = 1;
} else if (username != null && username.startsWith(q)) {
found = 2;
} else if (NumberUtil.isInteger(q) && (NumberUtil.parseInt(q) == user_id || q.length() > 3 && StrUtil.utf8Str(user_id).contains(q))) {
found = 3;
}
if (found != 0) {
@ -10998,7 +11020,7 @@ public class MessagesStorage extends BaseController {
}
if (chat != null && user != null) {
DialogsSearchAdapter.DialogSearchResult dialogSearchResult = dialogsResult.get((long) chat.id << 32);
chat.user_id = cursor.intValue(2);
chat.user_id = user_id;
chat.a_or_b = cursor.byteArrayValue(3);
chat.auth_key = cursor.byteArrayValue(4);
chat.ttl = cursor.intValue(5);
@ -11026,8 +11048,10 @@ public class MessagesStorage extends BaseController {
if (found == 1) {
dialogSearchResult.name = new SpannableStringBuilder(ContactsController.formatName(user.first_name, user.last_name));
((SpannableStringBuilder) dialogSearchResult.name).setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chats_secretName)), 0, dialogSearchResult.name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
} else if (found == 2) {
dialogSearchResult.name = AndroidUtilities.generateSearchName("@" + user.username, null, "@" + q);
} else {
dialogSearchResult.name = AndroidUtilities.generateSearchName("ID: " + user_id, null, q);
}
dialogSearchResult.object = chat;
encUsers.add(user);
@ -11086,6 +11110,8 @@ public class MessagesStorage extends BaseController {
found = 1;
} else if (username != null && username.startsWith(q)) {
found = 2;
} else if (NumberUtil.isInteger(q) && (NumberUtil.parseInt(q) == uid || q.length() > 3 && StrUtil.utf8Str(uid).contains(q))) {
found = 3;
}
if (found != 0) {
NativeByteBuffer data = cursor.byteBufferValue(0);
@ -11097,8 +11123,10 @@ public class MessagesStorage extends BaseController {
}
if (found == 1) {
resultArrayNames.add(AndroidUtilities.generateSearchName(user.first_name, user.last_name, q));
} else {
} else if (found == 2) {
resultArrayNames.add(AndroidUtilities.generateSearchName("@" + user.username, null, "@" + q));
} else {
resultArrayNames.add(AndroidUtilities.generateSearchName("ID: " + uid, null, q));
}
resultArray.add(user);
}

View File

@ -962,7 +962,13 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
cell.useSeparator = (position != getItemCount() - 1 && position != localCount + phoneCount2 + localServerCount - 1 && position != localCount + globalCount + phoneCount + localServerCount - 1);
if (position < searchResult.size()) {
name = searchResultNames.get(position);
if (name != null && user != null && user.username != null && user.username.length() > 0) {
if (name != null && name.toString().startsWith("ID: ")) {
username = name;
name = null;
if (username instanceof SpannableStringBuilder) {
username = new SpannableStringBuilder(username);
}
} else if (name != null && user != null && user.username != null && user.username.length() > 0) {
if (name.toString().startsWith("@" + user.username)) {
username = name;
name = null;

View File

@ -315,13 +315,12 @@ public class ChatRightsEditActivity extends BaseFragment {
});
listView.setOnItemClickListener((view, position) -> {
if (!canEdit && (!currentChat.creator || currentType != TYPE_ADMIN || position != anonymousRow)) {
return;
}
if (position == 0) {
Bundle args = new Bundle();
args.putInt("user_id", currentUser.id);
presentFragment(new ProfileActivity(args));
} else if (!canEdit && (!currentChat.creator || currentType != TYPE_ADMIN || position != anonymousRow)) {
return;
} else if (position == removeAdminRow) {
if (currentType == TYPE_ADMIN) {
MessagesController.getInstance(currentAccount).setUserAdminRole(chatId, currentUser, new TLRPC.TL_chatAdminRights(), currentRank, isChannel, getFragmentForAlert(0), isAddingNew);

View File

@ -250,6 +250,7 @@ public class NekoConfig {
disableVibration = preferences.getBoolean("disableVibration", false);
autoPauseVideo = preferences.getBoolean("autoPauseVideo", false);
disableProximityEvents = preferences.getBoolean("disableProximityEvents", false);
ignoreContentRestrictions = preferences.getBoolean("ignoreContentRestrictions", false);

View File

@ -12,8 +12,8 @@ if [ ! -x "$(command -v go)" ]; then
#
# fi
#
# gvm install go1.14 -B
# gvm use go1.14 --default
# gvm install go1.15 -B
# gvm use go1.15 --default
echo "install golang please!"

View File

@ -1,6 +1,6 @@
#!/bin/bash
V2RAY_CORE_VERSION="4.31.0"
V2RAY_CORE_VERSION="4.31.2"
if [ ! -x "$(command -v go)" ]; then

0
bin/update_libwebp.kts Normal file → Executable file
View File

View File

@ -1,7 +1,7 @@
#!/bin/bash
./gradlew TMessagesProj:assembleFullRelease \
TMessagesProj:assembleFullReleaseNoGcm
TMessagesProj:assembleFullReleaseNoGcm || exit 1
trap 'kill $(jobs -p)' SIGINT

29
bin/upload_debug.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
./gradlew TMessagesProj:assembleFullRelease || exit 1
trap 'kill $(jobs -p)' SIGINT
function upload() {
for apk in $outPath/*arm64*.apk; do
echo ">> Uploading $apk"
curl https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument \
-X POST \
-F chat_id="$TELEGRAM_CHANNEL" \
-F document="@$apk" \
--silent --show-error --fail >/dev/null &
done
for job in $(jobs -p); do
wait $job
done
}
outPath="TMessagesProj/build/outputs/apk/full/release"
upload