1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-12 11:19:29 +01:00

Merge official v8.2.7

This commit is contained in:
luvletter2333 2021-11-15 22:23:53 +08:00
commit b68bb4932c
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
10 changed files with 60 additions and 17 deletions

View File

@ -88,6 +88,7 @@
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ"/>
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE"/>
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" /> -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />

View File

@ -3952,6 +3952,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
final String folderName = "NekoX";
if (Build.VERSION.SDK_INT >= 29) {
try {
int selectedType = type;
ContentValues contentValues = new ContentValues();
String extension = MimeTypeMap.getFileExtensionFromUrl(sourceFile.getAbsolutePath());
String mimeType = null;
@ -3959,19 +3960,27 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
}
Uri uriToInsert = null;
if (type == 0) {
if ((type == 0 || type == 1) && mimeType != null) {
if (mimeType.startsWith("image")) {
selectedType = 0;
}
if (mimeType.startsWith("video")) {
selectedType = 1;
}
}
if (selectedType == 0) {
uriToInsert = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
File dirDest = new File(Environment.DIRECTORY_PICTURES, folderName);
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, AndroidUtilities.generateFileName(0, extension));
contentValues.put(MediaStore.Images.Media.MIME_TYPE, mimeType);
} else if (type == 1) {
} else if (selectedType == 1) {
File dirDest = new File(Environment.DIRECTORY_MOVIES, folderName);
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
uriToInsert = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
contentValues.put(MediaStore.Video.Media.DISPLAY_NAME, AndroidUtilities.generateFileName(1, extension));
contentValues.put(MediaStore.Video.Media.MIME_TYPE, mimeType);
} else if (type == 2) {
} else if (selectedType == 2) {
File dirDest = new File(Environment.DIRECTORY_DOWNLOADS, folderName);
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
uriToInsert = MediaStore.Downloads.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);

View File

@ -6019,7 +6019,6 @@ public class MessageObject {
attachPathExists = f.exists();
}
if (!attachPathExists) {
File file = FileLoader.getPathToMessage(messageOwner);
if (type == 3 && needDrawBluredPreview()) {
mediaExists = new File(file.getAbsolutePath() + ".enc").exists();

View File

@ -1874,7 +1874,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (currentMessageObject.type == 12) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(currentMessageObject.messageOwner.media.user_id);
long uid = currentMessageObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user == null) {
imagePressed = false;
result = false;
@ -2682,7 +2686,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
didPressButton(true, false);
}
} else if (currentMessageObject.type == 12) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(currentMessageObject.messageOwner.media.user_id);
long uid = currentMessageObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
delegate.didPressUserAvatar(this, user, lastTouchX, lastTouchY);
} else if (currentMessageObject.type == MessageObject.TYPE_ROUND_VIDEO) {
if (buttonState != -1) {
@ -4432,7 +4440,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
availableTimeWidth = backgroundWidth - AndroidUtilities.dp(31);
long uid = messageObject.messageOwner.media.user_id;
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(uid);
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
int maxWidth = getMaxNameWidth() - AndroidUtilities.dp(80);
if (maxWidth < 0) {

View File

@ -24,6 +24,7 @@ import androidx.core.graphics.ColorUtils;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.DownloadController;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.ImageLocation;
@ -166,7 +167,8 @@ public class SharedPhotoVideoCell2 extends View {
if (messageObject.strippedThumb != null) {
imageReceiver.setImage(null, null, null, null, messageObject.strippedThumb, 0, null, messageObject, 0);
} else {
imageReceiver.clearImage();
TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50);
imageReceiver.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", null, 0, null, messageObject, 0);
}
}
} else {

View File

@ -1220,7 +1220,11 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
}
options.add(9);
} else if (type == 8) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(selectedObject.messageOwner.media.user_id);
long uid = selectedObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user != null && user.id != UserConfig.getInstance(currentAccount).getClientUserId() && ContactsController.getInstance(currentAccount).contactsDict.get(user.id) == null) {
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
options.add(15);

View File

@ -20399,7 +20399,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
} else if (type == 8) {
TLRPC.User user = getMessagesController().getUser(selectedObject.messageOwner.media.user_id);
long uid = selectedObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user != null && user.id != getUserConfig().getClientUserId() && getContactsController().contactsDict.get(user.id) == null) {
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
options.add(15);
@ -20642,7 +20646,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(9);
icons.add(R.drawable.deproko_baseline_stickers_24);
} else if (type == 8) {
TLRPC.User user = getMessagesController().getUser(selectedObject.messageOwner.media.user_id);
long uid = selectedObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user != null && user.id != getUserConfig().getClientUserId() && getContactsController().contactsDict.get(user.id) == null) {
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
options.add(15);
@ -24229,7 +24237,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ArticleViewer.getInstance().open(messageObject);
}
} else if (type == 5) {
openVCard(getMessagesController().getUser(messageObject.messageOwner.media.user_id), messageObject.messageOwner.media.vcard, messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name);
long uid = messageObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
openVCard(user, messageObject.messageOwner.media.vcard, messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name);
} else {
if (messageObject.isSponsored()) {
Bundle args = new Bundle();

View File

@ -173,7 +173,7 @@ public class JoinGroupAlert extends BottomSheet {
layout.titleTextView.setText(LocaleController.getString("RequestToJoinSent", R.string.RequestToJoinSent));
String subTitle = isChannel
? LocaleController.getString("RequestToJoinChannelSentDescription", R.string.RequestToJoinChannelSentDescription)
: LocaleController.getString("RequestToJoinSentDescription", R.string.RequestToJoinGroupSentDescription);
: LocaleController.getString("RequestToJoinGroupSentDescription", R.string.RequestToJoinGroupSentDescription);
layout.subtitleTextView.setText(subTitle);
Bulletin.make(fragment, layout, Bulletin.DURATION_LONG).show();
});

View File

@ -9,6 +9,8 @@ import android.view.MotionEvent;
import android.view.TextureView;
import android.view.View;
import com.google.android.exoplayer2.util.Log;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
@ -64,7 +66,6 @@ public class RenderView extends TextureView {
if (surface == null || internal != null) {
return;
}
internal = new CanvasInternal(surface);
internal.setBufferSize(width, height);
updateTransform();
@ -263,7 +264,7 @@ public class RenderView extends TextureView {
private EGLContext eglContext;
private EGLSurface eglSurface;
private boolean initialized;
private boolean ready;
private volatile boolean ready;
private int bufferWidth;
private int bufferHeight;
@ -438,7 +439,7 @@ public class RenderView extends TextureView {
}
if (!ready) {
queue.postRunnable(() -> ready = true, 200);
ready = true;
}
}
};

View File

@ -81,7 +81,10 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
phone = getArguments().getString("phone");
addContact = getArguments().getBoolean("addContact", false);
needAddException = MessagesController.getNotificationsSettings(currentAccount).getBoolean("dialog_bar_exception" + user_id, false);
TLRPC.User user = getMessagesController().getUser(user_id);
TLRPC.User user = null;
if (user_id != 0) {
user = getMessagesController().getUser(user_id);
}
return user != null && super.onFragmentCreate();
}