1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

Merge upstream 7.4.1 (2225)

This commit is contained in:
世界 2021-01-29 15:20:11 +08:00
commit bb0e10e3dc
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
10 changed files with 82 additions and 53 deletions

View File

@ -1,8 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
def verName = "7.4.0-preview01"
def verCode = 168
def verName = "7.4.1-preview02"
def verCode = 169
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")

View File

@ -90,7 +90,6 @@ import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Timer;
@ -4080,24 +4079,32 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
public static String getFileName(Uri uri) {
String result = null;
if (uri.getScheme().equals("content")) {
try (Cursor cursor = ApplicationLoader.applicationContext.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)) {
if (cursor.moveToFirst()) {
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
if (uri == null) {
return "";
}
try {
String result = null;
if (uri.getScheme().equals("content")) {
try (Cursor cursor = ApplicationLoader.applicationContext.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)) {
if (cursor.moveToFirst()) {
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
}
} catch (Exception e) {
FileLog.e(e);
}
} catch (Exception e) {
FileLog.e(e);
}
}
if (result == null) {
result = uri.getPath();
int cut = result.lastIndexOf('/');
if (cut != -1) {
result = result.substring(cut + 1);
if (result == null) {
result = uri.getPath();
int cut = result.lastIndexOf('/');
if (cut != -1) {
result = result.substring(cut + 1);
}
}
return result;
} catch (Exception e) {
FileLog.e(e);
}
return result;
return "";
}
@SuppressLint("DiscouragedPrivateApi")

View File

@ -825,12 +825,15 @@ public class MessagesController extends BaseController implements NotificationCe
pendingSuggestions = new HashSet<>();
}
exportUri = mainPreferences.getStringSet("exportUri", null);
exportUri = mainPreferences.getStringSet("exportUri2", null);
if (exportUri != null) {
exportUri = new HashSet<>(exportUri);
} else {
exportUri = new HashSet<>();
exportUri.add("content://com.whatsapp.provider.media/export_chat/");
exportUri.add("content://(\\d+@)?com\\.whatsapp\\.provider\\.media/export_chat/");
exportUri.add("content://(\\d+@)?com\\.whatsapp\\.w4b\\.provider\\.media/export_chat/");
exportUri.add("content://jp\\.naver\\.line\\.android\\.line\\.common\\.FileProvider/export-chat/");
exportUri.add(".*WhatsApp.*\\.txt$");
}
exportGroupUri = mainPreferences.getStringSet("exportGroupUri", null);
@ -1612,7 +1615,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
case "export_urls": {
case "export_regex": {
HashSet<String> newExport = new HashSet<>();
if (value.value instanceof TLRPC.TL_jsonArray) {
TLRPC.TL_jsonArray array = (TLRPC.TL_jsonArray) value.value;
@ -1626,7 +1629,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
if (!exportUri.equals(newExport)) {
exportUri = newExport;
editor.putStringSet("exportUri", exportUri);
editor.putStringSet("exportUri2", exportUri);
changed = true;
}
break;

View File

@ -43,6 +43,10 @@ import android.os.Build;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.SparseIntArray;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
@ -53,11 +57,6 @@ import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
import android.text.TextUtils;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.SparseIntArray;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -78,8 +77,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import tw.nekomimi.nekogram.NekoConfig;
public class NotificationsController extends BaseController {
public static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
@ -694,7 +691,7 @@ public class NotificationsController extends BaseController {
for (int a = 0; a < messageObjects.size(); a++) {
MessageObject messageObject = messageObjects.get(a);
if (messageObject.messageOwner != null && messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined)) {
if (messageObject.messageOwner != null && (messageObject.isImportedForward() || messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined))) {
continue;
}
long mid = messageObject.getId();
@ -1009,7 +1006,7 @@ public class NotificationsController extends BaseController {
if (messages != null) {
for (int a = 0; a < messages.size(); a++) {
TLRPC.Message message = messages.get(a);
if (message != null && message.silent && (message.action instanceof TLRPC.TL_messageActionContactSignUp || message.action instanceof TLRPC.TL_messageActionUserJoined)) {
if (message != null && (message.fwd_from != null && message.fwd_from.imported || message.silent && (message.action instanceof TLRPC.TL_messageActionContactSignUp || message.action instanceof TLRPC.TL_messageActionUserJoined))) {
continue;
}
long mid = message.id;

View File

@ -67,7 +67,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
@ -2899,6 +2898,11 @@ public boolean retriedToSend;
}
}
} else {
boolean canSendStickers = true;
if (lower_id < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lower_id);
canSendStickers = ChatObject.canSendStickers(chat);
}
if (message != null) {
if (encryptedChat != null) {
newMsg = new TLRPC.TL_message_secret();
@ -2914,7 +2918,7 @@ public boolean retriedToSend;
webPage = null;
}
}
if (message.length() < 30 && webPage == null && (entities == null || entities.isEmpty()) && getMessagesController().diceEmojies.contains(message.replace("\ufe0f", "")) && encryptedChat == null && scheduleDate == 0) {
if (canSendStickers && message.length() < 30 && webPage == null && (entities == null || entities.isEmpty()) && getMessagesController().diceEmojies.contains(message.replace("\ufe0f", "")) && encryptedChat == null && scheduleDate == 0) {
TLRPC.TL_messageMediaDice mediaDice = new TLRPC.TL_messageMediaDice();
mediaDice.emoticon = message;
mediaDice.value = -1;
@ -3023,8 +3027,7 @@ public boolean retriedToSend;
newMsg = new TLRPC.TL_message();
}
if (lower_id < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lower_id);
if (chat != null && !ChatObject.canSendStickers(chat)) {
if (!canSendStickers) {
for (int a = 0, N = document.attributes.size(); a < N; a++) {
if (document.attributes.get(a) instanceof TLRPC.TL_documentAttributeAnimated) {
document.attributes.remove(a);

View File

@ -1393,7 +1393,7 @@ public class DialogCell extends BaseCell {
nameLeft += w;
}
} else if (drawScam != 0) {
int w = AndroidUtilities.dp(6) + (drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth();
int w = AndroidUtilities.dp(6) + (drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth();
nameWidth -= w;
if (LocaleController.isRTL) {
nameLeft += w;
@ -1613,7 +1613,7 @@ public class DialogCell extends BaseCell {
} else if (drawVerified) {
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - Theme.dialogs_verifiedDrawable.getIntrinsicWidth());
} else if (drawScam != 0) {
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - (drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth());
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - (drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth());
}
if (left == 0) {
if (widthpx < nameWidth) {
@ -2511,8 +2511,8 @@ public class DialogCell extends BaseCell {
Theme.dialogs_verifiedDrawable.draw(canvas);
Theme.dialogs_verifiedCheckDrawable.draw(canvas);
} else if (drawScam != 0) {
setDrawableBounds((drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable), nameMuteLeft, AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 12 : 15));
(drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).draw(canvas);
setDrawableBounds((drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable), nameMuteLeft, AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 12 : 15));
(drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).draw(canvas);
}
if (drawReorder || reorderIconProgress != 0) {

View File

@ -99,7 +99,7 @@ public class LinkActionView extends LinearLayout {
copyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
copyView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
copyView.setLines(1);
linearLayout.addView(copyView, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, 0, 4, 0, 4, 0));
linearLayout.addView(copyView, LayoutHelper.createLinear(0, 40, 1f, 0, 4, 0, 4, 0));
shareView = new TextView(context);
shareView.setGravity(Gravity.CENTER_HORIZONTAL);
@ -114,7 +114,7 @@ public class LinkActionView extends LinearLayout {
shareView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
shareView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
shareView.setLines(1);
linearLayout.addView(shareView, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, 4, 0, 4, 0));
linearLayout.addView(shareView, LayoutHelper.createLinear(0, 40, 1f, 4, 0, 4, 0));
removeView = new TextView(context);

View File

@ -358,6 +358,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
private float colorChangeProgress;
private long lastUpdateTime;
private float[] volumeAlphas = new float[3];
private boolean dragging;
public VolumeSlider(Context context, TLRPC.TL_groupCallParticipant participant) {
super(context);
@ -446,14 +447,14 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
} else if (thumbX > getMeasuredWidth()) {
thumbX = getMeasuredWidth();
}
pressed = true;
dragging = true;
}
}
if (pressed) {
if (dragging) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
onSeekBarDrag(thumbX / (double) getMeasuredWidth(), true);
}
pressed = false;
dragging = false;
invalidate();
return true;
}
@ -473,13 +474,13 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
} else if (thumbX > getMeasuredWidth()) {
thumbX = getMeasuredWidth();
}
pressed = true;
dragging = true;
invalidate();
return true;
}
}
} else {
if (pressed) {
if (dragging) {
thumbX = (int) ev.getX();
if (thumbX < 0) {
thumbX = 0;

View File

@ -1422,11 +1422,20 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else {
String originalPath = uri.toString();
if (dialogId == 0 && originalPath != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("export path = " + originalPath);
}
Set<String> exportUris = MessagesController.getInstance(intentAccount[0]).exportUri;
String fileName = FileLoader.fixFileName(MediaController.getFileName(uri));
for (String u : exportUris) {
if (originalPath.startsWith(u)) {
exportingChatUri = uri;
break;
try {
Pattern pattern = Pattern.compile(u);
if (pattern.matcher(originalPath).find() || pattern.matcher(fileName).find()) {
exportingChatUri = uri;
break;
}
} catch (Exception e) {
FileLog.e(e);
}
}
if (exportingChatUri == null) {
@ -1520,13 +1529,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
originalPath = path;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("export path = " + originalPath);
}
if (dialogId == 0 && originalPath != null && exportingChatUri == null) {
boolean ok = false;
String fileName = FileLoader.fixFileName(MediaController.getFileName(uri));
for (String u : exportUris) {
if (originalPath.startsWith(u)) {
exportingChatUri = uri;
ok = true;
break;
try {
Pattern pattern = Pattern.compile(u);
if (pattern.matcher(originalPath).find() || pattern.matcher(fileName).find()) {
exportingChatUri = uri;
ok = true;
break;
}
} catch (Exception e) {
FileLog.e(e);
}
}
if (ok) {

View File

@ -9,7 +9,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21-2"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3'
classpath 'com.github.triplet.gradle:play-publisher:3.0.0'