mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 06:25:14 +01:00
Bug fixes
This commit is contained in:
parent
fe9e23eccf
commit
1c74ed4587
14 changed files with 232 additions and 94 deletions
|
@ -1191,8 +1191,8 @@ public class ImageLoader {
|
|||
AndroidUtilities.addMediaToGallery(finalFile.toString());
|
||||
}
|
||||
}
|
||||
ImageLoader.this.fileDidLoaded(location, finalFile, type);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.FileDidLoaded, location);
|
||||
ImageLoader.this.fileDidLoaded(location, finalFile, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1673,6 +1673,8 @@ public class MessageObject {
|
|||
|
||||
public void checkMediaExistance() {
|
||||
File cacheFile = null;
|
||||
attachPathExists = false;
|
||||
mediaExists = false;
|
||||
if (type == 1) {
|
||||
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize());
|
||||
if (currentPhotoObject != null) {
|
||||
|
|
|
@ -268,18 +268,18 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
if (file != null && media != null) {
|
||||
if (message.type == 0) {
|
||||
media.file = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj.messageOwner, message.originalPath);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
} else if (message.type == 1) {
|
||||
if (media.file == null) {
|
||||
media.file = file;
|
||||
if (media.thumb == null && message.location != null) {
|
||||
performSendDelayedMessage(message);
|
||||
} else {
|
||||
performSendMessageRequest(message.sendRequest, message.obj.messageOwner, message.originalPath);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
} else {
|
||||
media.thumb = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj.messageOwner, message.originalPath);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
} else if (message.type == 2) {
|
||||
if (media.file == null) {
|
||||
|
@ -287,15 +287,15 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
if (media.thumb == null && message.location != null) {
|
||||
performSendDelayedMessage(message);
|
||||
} else {
|
||||
performSendMessageRequest(message.sendRequest, message.obj.messageOwner, message.originalPath);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
} else {
|
||||
media.thumb = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj.messageOwner, message.originalPath);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
} else if (message.type == 3) {
|
||||
media.file = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj.messageOwner, message.originalPath);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
arr.remove(a);
|
||||
a--;
|
||||
|
@ -838,6 +838,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
final ArrayList<TLRPC.Message> newMsgObjArr = arr;
|
||||
final ArrayList<MessageObject> newMsgArr = objArr;
|
||||
final HashMap<Long, TLRPC.Message> messagesByRandomIdsFinal = messagesByRandomIds;
|
||||
final boolean isMegagroupFinal = isMegagroup;
|
||||
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
|
||||
|
@ -875,12 +876,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
if (newMsgObj == null) {
|
||||
continue;
|
||||
}
|
||||
MessageObject msgObj = newMsgArr.get(newMsgObjArr.indexOf(newMsgObj));
|
||||
newMsgObjArr.remove(newMsgObj);
|
||||
final int oldId = newMsgObj.id;
|
||||
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
|
||||
sentMessages.add(message);
|
||||
newMsgObj.id = message.id;
|
||||
processSentMessage(newMsgObj, message, null, true);
|
||||
updateMediaPaths(msgObj, message, null, true);
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1479,7 +1481,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
reqSend.contacts = sendToPeers;
|
||||
reqSend.media = new TLRPC.TL_inputMediaEmpty();
|
||||
reqSend.random_id = random_ids;
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else {
|
||||
TLRPC.TL_messages_sendMessage reqSend = new TLRPC.TL_messages_sendMessage();
|
||||
reqSend.message = message;
|
||||
|
@ -1498,7 +1500,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
if (!searchLinks) {
|
||||
reqSend.no_webpage = true;
|
||||
}
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
} else {
|
||||
TLRPC.TL_decryptedMessage reqSend;
|
||||
|
@ -1694,32 +1696,32 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
reqSend = request;
|
||||
}
|
||||
if (type == 1) {
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else if (type == 2) {
|
||||
if (photo.access_hash == 0) {
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (document.access_hash == 0) {
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
} else if (type == 6) {
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else if (type == 7) {
|
||||
if (document.access_hash == 0 && delayedMessage != null) {
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, originalPath);
|
||||
performSendMessageRequest(reqSend, newMsgObj, originalPath);
|
||||
}
|
||||
} else if (type == 8) {
|
||||
if (document.access_hash == 0) {
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2010,7 +2012,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
if (asAdmin && reqSend.to_peer.channel_id != 0) {
|
||||
reqSend.broadcast = true;
|
||||
}
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else if (type == 9) {
|
||||
TLRPC.TL_messages_sendInlineBotResult reqSend = new TLRPC.TL_messages_sendInlineBotResult();
|
||||
reqSend.peer = sendToPeer;
|
||||
|
@ -2027,7 +2029,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
reqSend.query_id = Utilities.parseLong(params.get("query_id"));
|
||||
reqSend.id = params.get("id");
|
||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
|
@ -2185,7 +2187,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
return sendingMessages.containsKey(mid);
|
||||
}
|
||||
|
||||
private void performSendMessageRequest(final TLObject req, final TLRPC.Message newMsgObj, final String originalPath) {
|
||||
private void performSendMessageRequest(final TLObject req, final MessageObject msgObj, final String originalPath) {
|
||||
final TLRPC.Message newMsgObj = msgObj.messageOwner;
|
||||
putToSendingMessages(newMsgObj);
|
||||
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
|
||||
@Override
|
||||
|
@ -2252,7 +2255,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
if (message != null) {
|
||||
newMsgObj.id = message.id;
|
||||
processSentMessage(newMsgObj, message, originalPath, false);
|
||||
updateMediaPaths(msgObj, message, originalPath, false);
|
||||
} else {
|
||||
isSentError = true;
|
||||
}
|
||||
|
@ -2329,7 +2332,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
}, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter | (req instanceof TLRPC.TL_messages_sendMessage ? ConnectionsManager.RequestFlagNeedQuickAck : 0));
|
||||
}
|
||||
|
||||
private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage, String originalPath, boolean post) {
|
||||
private void updateMediaPaths(MessageObject newMsgObj, TLRPC.Message sentMessage, String originalPath, boolean post) {
|
||||
TLRPC.Message newMsg = newMsgObj.messageOwner;
|
||||
if (sentMessage == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -2436,6 +2440,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
sentMessage.attachPath = newMsg.attachPath;
|
||||
sentMessage.message = newMsg.message;
|
||||
} else if (!MessageObject.isVideoMessage(sentMessage)) {
|
||||
newMsgObj.mediaExists = newMsgObj.attachPathExists;
|
||||
newMsgObj.attachPathExists = false;
|
||||
newMsg.attachPath = "";
|
||||
if (originalPath != null && originalPath.startsWith("http")) {
|
||||
MessagesStorage.getInstance().addRecentLocalFile(originalPath, cacheFile2.toString(), newMsg.media.document);
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
|
@ -28,6 +29,7 @@ import android.widget.FrameLayout;
|
|||
import android.widget.LinearLayout;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
|
@ -50,6 +52,9 @@ public class ActionBarLayout extends FrameLayout {
|
|||
|
||||
public class LinearLayoutContainer extends LinearLayout {
|
||||
|
||||
private Rect rect = new Rect();
|
||||
private boolean isKeyboardVisible;
|
||||
|
||||
public LinearLayoutContainer(Context context) {
|
||||
super(context);
|
||||
setOrientation(VERTICAL);
|
||||
|
@ -87,12 +92,32 @@ public class ActionBarLayout extends FrameLayout {
|
|||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
|
||||
View rootView = getRootView();
|
||||
getWindowVisibleDisplayFrame(rect);
|
||||
int usableViewHeight = rootView.getHeight() - (rect.top != 0 ? AndroidUtilities.statusBarHeight : 0) - AndroidUtilities.getViewInset(rootView);
|
||||
isKeyboardVisible = usableViewHeight - (rect.bottom - rect.top) > 0;
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.e("tmessages", "keyboard visible = " + isKeyboardVisible + " for " + this);
|
||||
}
|
||||
if (waitingForKeyboardCloseRunnable != null && !containerView.isKeyboardVisible && !containerViewBack.isKeyboardVisible) {
|
||||
AndroidUtilities.cancelRunOnUIThread(waitingForKeyboardCloseRunnable);
|
||||
waitingForKeyboardCloseRunnable.run();
|
||||
waitingForKeyboardCloseRunnable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Drawable headerShadowDrawable;
|
||||
private static Drawable layerShadowDrawable;
|
||||
private static Paint scrimPaint;
|
||||
|
||||
private Runnable waitingForKeyboardCloseRunnable;
|
||||
|
||||
private LinearLayoutContainer containerView;
|
||||
private LinearLayoutContainer containerViewBack;
|
||||
private DrawerLayoutContainer drawerLayoutContainer;
|
||||
|
@ -494,6 +519,10 @@ public class ActionBarLayout extends FrameLayout {
|
|||
private void onAnimationEndCheck(boolean byCheck) {
|
||||
onCloseAnimationEnd(false);
|
||||
onOpenAnimationEnd(false);
|
||||
if (waitingForKeyboardCloseRunnable != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(waitingForKeyboardCloseRunnable);
|
||||
waitingForKeyboardCloseRunnable = null;
|
||||
}
|
||||
if (currentAnimation != null) {
|
||||
if (byCheck) {
|
||||
currentAnimation.cancel();
|
||||
|
@ -514,7 +543,7 @@ public class ActionBarLayout extends FrameLayout {
|
|||
}
|
||||
|
||||
public boolean checkTransitionAnimation() {
|
||||
if (transitionAnimationInProgress && transitionAnimationStartTime < System.currentTimeMillis() - 1000) {
|
||||
if (transitionAnimationInProgress && transitionAnimationStartTime < System.currentTimeMillis() - 1500) {
|
||||
onAnimationEndCheck(true);
|
||||
}
|
||||
return transitionAnimationInProgress;
|
||||
|
@ -718,7 +747,21 @@ public class ActionBarLayout extends FrameLayout {
|
|||
if (animation == null) {
|
||||
ViewProxy.setAlpha(containerView, 0.0f);
|
||||
ViewProxy.setTranslationX(containerView, 48.0f);
|
||||
startLayoutAnimation(true, true);
|
||||
if (containerView.isKeyboardVisible || containerViewBack.isKeyboardVisible) {
|
||||
waitingForKeyboardCloseRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.e("tmessages", "start delayed by keyboard open animation");
|
||||
if (waitingForKeyboardCloseRunnable != this) {
|
||||
return;
|
||||
}
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(waitingForKeyboardCloseRunnable, 200);
|
||||
} else {
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
//containerView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
|
@ -868,7 +911,21 @@ public class ActionBarLayout extends FrameLayout {
|
|||
}
|
||||
});
|
||||
if (animation == null) {
|
||||
startLayoutAnimation(false, true);
|
||||
if (containerView.isKeyboardVisible || containerViewBack.isKeyboardVisible) {
|
||||
waitingForKeyboardCloseRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (waitingForKeyboardCloseRunnable != this) {
|
||||
return;
|
||||
}
|
||||
FileLog.e("tmessages", "start delayed by keyboard close animation");
|
||||
startLayoutAnimation(false, true);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(waitingForKeyboardCloseRunnable, 200);
|
||||
} else {
|
||||
startLayoutAnimation(false, true);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
//containerView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
|
|
|
@ -112,10 +112,7 @@ public class ActionBarMenu extends LinearLayout {
|
|||
}
|
||||
|
||||
public void clearItems() {
|
||||
while(getChildCount() > 0) {
|
||||
View view = getChildAt(0);
|
||||
removeView(view);
|
||||
}
|
||||
removeAllViews();
|
||||
}
|
||||
|
||||
public void onMenuButtonPressed() {
|
||||
|
|
|
@ -233,6 +233,9 @@ public class BottomSheet extends Dialog {
|
|||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
if (lastInsets != null && Build.VERSION.SDK_INT >= 21) {
|
||||
width -= lastInsets.getSystemWindowInsetRight() + lastInsets.getSystemWindowInsetLeft();
|
||||
}
|
||||
|
||||
setMeasuredDimension(width, height);
|
||||
boolean isPortrait = width < height;
|
||||
|
@ -262,9 +265,6 @@ public class BottomSheet extends Dialog {
|
|||
if (child.getVisibility() == GONE || child == containerView) {
|
||||
continue;
|
||||
}
|
||||
if (lastInsets != null && Build.VERSION.SDK_INT >= 21) {
|
||||
child.dispatchApplyWindowInsets(lastInsets);
|
||||
}
|
||||
measureChildWithMargins(child, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 0, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY), 0);
|
||||
}
|
||||
}
|
||||
|
@ -272,15 +272,15 @@ public class BottomSheet extends Dialog {
|
|||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
if (containerView != null) {
|
||||
int l = ((right - left) - containerView.getMeasuredWidth()) / 2;
|
||||
int t = (bottom - top) - containerView.getMeasuredHeight();
|
||||
if (lastInsets != null && Build.VERSION.SDK_INT >= 21) {
|
||||
l += lastInsets.getSystemWindowInsetLeft() / 2;
|
||||
l -= lastInsets.getSystemWindowInsetRight() / 2;
|
||||
left += lastInsets.getSystemWindowInsetLeft();
|
||||
right += lastInsets.getSystemWindowInsetLeft();
|
||||
if (focusable) {
|
||||
t -= lastInsets.getSystemWindowInsetBottom();
|
||||
}
|
||||
}
|
||||
int l = ((right - left) - containerView.getMeasuredWidth()) / 2;
|
||||
containerView.layout(l, t, l + containerView.getMeasuredWidth(), t + getMeasuredHeight());
|
||||
}
|
||||
|
||||
|
@ -382,6 +382,12 @@ public class BottomSheet extends Dialog {
|
|||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
return super.drawChild(canvas, child, drawingTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
FileLog.e("tmessages", "container on layout");
|
||||
}
|
||||
};
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
containerView.setFitsSystemWindows(true);
|
||||
|
@ -548,7 +554,7 @@ public class BottomSheet extends Dialog {
|
|||
private void startRevealAnimation(final boolean open) {
|
||||
ViewProxy.setTranslationY(containerView, 0);
|
||||
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
final AnimatorSet animatorSet = new AnimatorSet();
|
||||
|
||||
View view = delegate.getRevealView();
|
||||
if (view.getVisibility() == View.VISIBLE && ((ViewGroup) view.getParent()).getVisibility() == View.VISIBLE) {
|
||||
|
@ -580,6 +586,7 @@ public class BottomSheet extends Dialog {
|
|||
for (int a = 0; a < 4; a++) {
|
||||
finalRevealRadius = Math.max(finalRevealRadius, (int) Math.ceil(Math.sqrt((revealX - corners[a][0]) * (revealX - corners[a][0]) + (revealY - corners[a][1]) * (revealY - corners[a][1]))));
|
||||
}
|
||||
int finalRevealX = revealX <= containerView.getMeasuredWidth() ? revealX : containerView.getMeasuredWidth();
|
||||
|
||||
ArrayList<Animator> animators = new ArrayList<>(3);
|
||||
animators.add(ObjectAnimator.ofFloat(this, "revealRadius", open ? 0 : finalRevealRadius, open ? finalRevealRadius : 0));
|
||||
|
@ -587,7 +594,7 @@ public class BottomSheet extends Dialog {
|
|||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
containerView.setElevation(AndroidUtilities.dp(10));
|
||||
try {
|
||||
animators.add(ViewAnimationUtils.createCircularReveal(containerView, revealX <= containerView.getMeasuredWidth() ? revealX : containerView.getMeasuredWidth(), revealY, open ? 0 : finalRevealRadius, open ? finalRevealRadius : 0));
|
||||
animators.add(ViewAnimationUtils.createCircularReveal(containerView, finalRevealX, revealY, open ? 0 : finalRevealRadius, open ? finalRevealRadius : 0));
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
@ -626,7 +633,7 @@ public class BottomSheet extends Dialog {
|
|||
}
|
||||
containerView.invalidate();
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
container.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
containerView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
if (!open) {
|
||||
containerView.setVisibility(View.INVISIBLE);
|
||||
|
@ -642,17 +649,20 @@ public class BottomSheet extends Dialog {
|
|||
}
|
||||
|
||||
private void startOpenAnimation() {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
if (containerView.getMeasuredHeight() == 0) {
|
||||
containerView.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.y, View.MeasureSpec.AT_MOST));
|
||||
}
|
||||
backgroundDrawable.setAlpha(0);
|
||||
containerView.setVisibility(View.VISIBLE);
|
||||
if (useRevealAnimation) {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
startRevealAnimation(true);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
ViewProxy.setTranslationY(containerView, containerView.getMeasuredHeight());
|
||||
backgroundDrawable.setAlpha(0);
|
||||
AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
|
||||
|
|
|
@ -233,6 +233,8 @@ public class Theme {
|
|||
public static PorterDuffColorFilter colorPressedFilter;
|
||||
private static int currentColor;
|
||||
|
||||
public static Drawable attachButtonDrawables[] = new Drawable[8];
|
||||
|
||||
private static Paint maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
public static void loadRecources(Context context) {
|
||||
|
@ -329,14 +331,14 @@ public class Theme {
|
|||
geoInDrawable = context.getResources().getDrawable(R.drawable.location_b);
|
||||
geoOutDrawable = context.getResources().getDrawable(R.drawable.location_g);
|
||||
|
||||
context.getResources().getDrawable(R.drawable.attach_camera_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_gallery_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_video_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_audio_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_file_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_contact_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_location_states);
|
||||
context.getResources().getDrawable(R.drawable.attach_hide_states);
|
||||
attachButtonDrawables[0] = context.getResources().getDrawable(R.drawable.attach_camera_states);
|
||||
attachButtonDrawables[1] = context.getResources().getDrawable(R.drawable.attach_gallery_states);
|
||||
attachButtonDrawables[2] = context.getResources().getDrawable(R.drawable.attach_video_states);
|
||||
attachButtonDrawables[3] = context.getResources().getDrawable(R.drawable.attach_audio_states);
|
||||
attachButtonDrawables[4] = context.getResources().getDrawable(R.drawable.attach_file_states);
|
||||
attachButtonDrawables[5] = context.getResources().getDrawable(R.drawable.attach_contact_states);
|
||||
attachButtonDrawables[6] = context.getResources().getDrawable(R.drawable.attach_location_states);
|
||||
attachButtonDrawables[7] = context.getResources().getDrawable(R.drawable.attach_hide_states);
|
||||
|
||||
cornerOuter[0] = context.getResources().getDrawable(R.drawable.corner_out_tl);
|
||||
cornerOuter[1] = context.getResources().getDrawable(R.drawable.corner_out_tr);
|
||||
|
|
|
@ -203,7 +203,7 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
|
|||
final ArrayList<MediaController.AudioEntry> newAudioEntries = new ArrayList<>();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = ApplicationLoader.applicationContext.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, MediaStore.Audio.Media.IS_MUSIC + " != 0", null, null);
|
||||
cursor = ApplicationLoader.applicationContext.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, MediaStore.Audio.Media.IS_MUSIC + " != 0", null, MediaStore.Audio.Media.TITLE);
|
||||
int id = -2000000000;
|
||||
while (cursor.moveToNext()) {
|
||||
MediaController.AudioEntry audioEntry = new MediaController.AudioEntry();
|
||||
|
|
|
@ -62,7 +62,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ChatMessageCell extends ChatBaseCell implements SeekBar.SeekBarDelegate {
|
||||
public class ChatMessageCell extends ChatBaseCell implements SeekBar.SeekBarDelegate, ImageReceiver.ImageReceiverDelegate {
|
||||
|
||||
private final static int DOCUMENT_ATTACH_TYPE_NONE = 0;
|
||||
private final static int DOCUMENT_ATTACH_TYPE_DOCUMENT = 1;
|
||||
|
@ -202,6 +202,7 @@ public class ChatMessageCell extends ChatBaseCell implements SeekBar.SeekBarDele
|
|||
super(context);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
photoImage = new ImageReceiver(this);
|
||||
photoImage.setDelegate(this);
|
||||
radialProgress = new RadialProgress(this);
|
||||
seekBar = new SeekBar(context);
|
||||
seekBar.setDelegate(this);
|
||||
|
@ -1703,6 +1704,7 @@ public class ChatMessageCell extends ChatBaseCell implements SeekBar.SeekBarDele
|
|||
}
|
||||
}
|
||||
} else if (webPage.photo != null) {
|
||||
drawImageButton = webPage.type != null && webPage.type.equals("photo");
|
||||
currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, drawImageButton ? AndroidUtilities.getPhotoSize() : maxPhotoWidth, !drawImageButton);
|
||||
currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
|
||||
if (currentPhotoObjectThumb == currentPhotoObject) {
|
||||
|
@ -3300,6 +3302,14 @@ public class ChatMessageCell extends ChatBaseCell implements SeekBar.SeekBarDele
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) {
|
||||
if (currentMessageObject != null && set && !thumb && !currentMessageObject.mediaExists && !currentMessageObject.attachPathExists) {
|
||||
currentMessageObject.mediaExists = true;
|
||||
updateButtonState(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressDownload(String fileName, float progress) {
|
||||
radialProgress.setProgress(progress, true);
|
||||
|
|
|
@ -250,7 +250,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private Runnable waitingForCharaterEnterRunnable;
|
||||
|
||||
private boolean openAnimationEnded;
|
||||
private boolean attachAttachViewFirstShow = true;
|
||||
|
||||
private int readWithDate;
|
||||
private int readWithMid;
|
||||
|
@ -702,7 +701,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
cantDeleteMessagesCount = 0;
|
||||
|
||||
hasOwnBackground = true;
|
||||
chatAttachView = null;
|
||||
if (chatAttachView != null){
|
||||
chatAttachView.onDestroy();
|
||||
chatAttachView = null;
|
||||
}
|
||||
chatAttachViewSheet = null;
|
||||
|
||||
Theme.loadRecources(context);
|
||||
|
@ -876,17 +878,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
chatAttachView.init(ChatActivity.this);
|
||||
if (attachAttachViewFirstShow) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showDialog(chatAttachViewSheet);
|
||||
}
|
||||
});
|
||||
attachAttachViewFirstShow = false;
|
||||
} else {
|
||||
showDialog(chatAttachViewSheet);
|
||||
}
|
||||
showDialog(chatAttachViewSheet);
|
||||
} else if (id == bot_help) {
|
||||
SendMessagesHelper.getInstance().sendMessage("/help", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null, null);
|
||||
} else if (id == bot_settings) {
|
||||
|
@ -2845,11 +2837,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
int totalItemCount = chatAdapter.getItemCount();
|
||||
int checkLoadCount;
|
||||
if (scroll) {
|
||||
if (lastLoadIndex < 3) {
|
||||
checkLoadCount = 5;
|
||||
} else {
|
||||
checkLoadCount = 25;
|
||||
}
|
||||
checkLoadCount = 25;
|
||||
} else {
|
||||
checkLoadCount = 5;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
|
@ -39,6 +40,7 @@ import org.telegram.messenger.support.widget.LinearLayoutManager;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.support.widget.RecyclerView;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.PhotoAttachPhotoCell;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
|
@ -97,9 +99,9 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No
|
|||
super.onMeasure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(85), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(90), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setTextAndIcon(CharSequence text, int icon) {
|
||||
public void setTextAndIcon(CharSequence text, Drawable drawable) {
|
||||
textView.setText(text);
|
||||
imageView.setBackgroundResource(icon);
|
||||
imageView.setBackgroundDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,19 +170,9 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No
|
|||
LocaleController.getString("ChatLocation", R.string.ChatLocation),
|
||||
""
|
||||
};
|
||||
int itemIcons[] = new int[] {
|
||||
R.drawable.attach_camera_states,
|
||||
R.drawable.attach_gallery_states,
|
||||
R.drawable.attach_video_states,
|
||||
R.drawable.attach_audio_states,
|
||||
R.drawable.attach_file_states,
|
||||
R.drawable.attach_contact_states,
|
||||
R.drawable.attach_location_states,
|
||||
R.drawable.attach_hide_states,
|
||||
};
|
||||
for (int a = 0; a < 8; a++) {
|
||||
AttachButton attachButton = new AttachButton(context);
|
||||
attachButton.setTextAndIcon(items[a], itemIcons[a]);
|
||||
attachButton.setTextAndIcon(items[a], Theme.attachButtonDrawables[a]);
|
||||
addView(attachButton, LayoutHelper.createFrame(85, 90, Gravity.LEFT | Gravity.TOP));
|
||||
attachButton.setTag(a);
|
||||
views[a] = attachButton;
|
||||
|
@ -282,10 +274,8 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No
|
|||
}
|
||||
|
||||
public void loadGalleryPhotos() {
|
||||
if (MediaController.allPhotosAlbumEntry == null) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
MediaController.loadGalleryPhotosAlbums(0);
|
||||
}
|
||||
if (MediaController.allPhotosAlbumEntry == null && Build.VERSION.SDK_INT >= 21) {
|
||||
MediaController.loadGalleryPhotosAlbums(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.telegram.ui.Components;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
|
@ -38,6 +39,8 @@ import org.telegram.ui.ActionBar.BottomSheet;
|
|||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WebFrameLayout extends FrameLayout {
|
||||
|
||||
|
@ -52,11 +55,67 @@ public class WebFrameLayout extends FrameLayout {
|
|||
private int height;
|
||||
private String openUrl;
|
||||
private boolean hasDescription;
|
||||
private String embedUrl;
|
||||
|
||||
final static Pattern youtubeIdRegex = Pattern.compile("(?:youtube(?:-nocookie)?\\.com\\/(?:[^\\/\\n\\s]+\\/\\S+\\/|(?:v|e(?:mbed)?)\\/|\\S*?[?&]v=)|youtu\\.be\\/)([a-zA-Z0-9_-]{11})");
|
||||
private final String youtubeFrame = "<!DOCTYPE html><html><head><style>" +
|
||||
"body { margin: 0; width:100%%; height:100%%; background-color:#000; }" +
|
||||
"html { width:100%%; height:100%%; background-color:#000; }" +
|
||||
".embed-container iframe," +
|
||||
".embed-container object," +
|
||||
" .embed-container embed {" +
|
||||
" position: absolute;" +
|
||||
" top: 0;" +
|
||||
" left: 0;" +
|
||||
" width: 100%% !important;" +
|
||||
" height: 100%% !important;" +
|
||||
" }" +
|
||||
" </style></head><body>" +
|
||||
" <div class=\"embed-container\">" +
|
||||
" <div id=\"player\"></div>" +
|
||||
" </div>" +
|
||||
" <script src=\"https://www.youtube.com/iframe_api\"></script>" +
|
||||
" <script>" +
|
||||
" var player;" +
|
||||
" YT.ready(function() {" +
|
||||
" player = new YT.Player(\"player\", {" +
|
||||
" \"width\" : \"100%%\"," +
|
||||
" \"events\" : {" +
|
||||
" \"onReady\" : \"onReady\"," +
|
||||
" }," +
|
||||
" \"videoId\" : \"%1$s\"," +
|
||||
" \"height\" : \"100%%\"," +
|
||||
" \"playerVars\" : {" +
|
||||
" \"start\" : 0," +
|
||||
" \"rel\" : 0," +
|
||||
" \"showinfo\" : 0," +
|
||||
" \"modestbranding\" : 1," +
|
||||
" \"iv_load_policy\" : 3," +
|
||||
" \"autohide\" : 1," +
|
||||
" \"cc_load_policy\" : 1," +
|
||||
" \"playsinline\" : 1," +
|
||||
" \"controls\" : 1" +
|
||||
" }" +
|
||||
" });" +
|
||||
" player.setSize(window.innerWidth, window.innerHeight);" +
|
||||
" });" +
|
||||
" function onReady(event) {" +
|
||||
" player.playVideo();" +
|
||||
" }" +
|
||||
" window.onresize = function() {" +
|
||||
" player.setSize(window.innerWidth, window.innerHeight);" +
|
||||
" }" +
|
||||
" </script>" +
|
||||
"</body>" +
|
||||
"</html>";
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public WebFrameLayout(Context context, final BottomSheet parentDialog, String title, String descripton, String originalUrl, final String url, int w, int h) {
|
||||
super(context);
|
||||
|
||||
embedUrl = url;
|
||||
if (embedUrl.toLowerCase().contains("youtube")) {
|
||||
//embedUrl += "&enablejsapi=1";
|
||||
}
|
||||
hasDescription = descripton != null && descripton.length() > 0;
|
||||
openUrl = originalUrl;
|
||||
width = w;
|
||||
|
@ -162,9 +221,6 @@ public class WebFrameLayout extends FrameLayout {
|
|||
progressBar = new ProgressBar(context);
|
||||
addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, (48 + 36 + (hasDescription ? 22 : 0)) / 2));
|
||||
|
||||
//TODO 16m
|
||||
//TODO 14
|
||||
|
||||
TextView textView;
|
||||
|
||||
if (hasDescription) {
|
||||
|
@ -282,11 +338,31 @@ public class WebFrameLayout extends FrameLayout {
|
|||
public void onOpenAnimationEnd() {
|
||||
HashMap<String, String> args = new HashMap<>();
|
||||
args.put("Referer", "http://youtube.com");
|
||||
boolean ok = false;
|
||||
try {
|
||||
webView.loadUrl(url, args);
|
||||
Uri uri = Uri.parse(openUrl);
|
||||
String host = uri.getHost().toLowerCase();
|
||||
if (host != null && host.endsWith("youtube.com") || host.endsWith("youtu.be")) {
|
||||
Matcher matcher = youtubeIdRegex.matcher(openUrl);
|
||||
String id = null;
|
||||
if (matcher.find()) {
|
||||
id = matcher.group(1);
|
||||
}
|
||||
if (id != null) {
|
||||
ok = true;
|
||||
webView.loadDataWithBaseURL("http://youtube.com", String.format(youtubeFrame, id), "text/html", "UTF-8", "http://youtube.com");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (!ok) {
|
||||
try {
|
||||
webView.loadUrl(embedUrl, args);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -779,7 +779,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
group = path.replace("joinchat/", "");
|
||||
} else if (path.startsWith("addstickers/")) {
|
||||
sticker = path.replace("addstickers/", "");
|
||||
} else if (path.startsWith("msg/")) {
|
||||
} else if (path.startsWith("msg/") || path.startsWith("share/")) {
|
||||
message = data.getQueryParameter("url");
|
||||
if (message == null) {
|
||||
message = "";
|
||||
|
@ -823,8 +823,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
url = url.replace("tg:addstickers", "tg://telegram.org").replace("tg://addstickers", "tg://telegram.org");
|
||||
data = Uri.parse(url);
|
||||
sticker = data.getQueryParameter("set");
|
||||
} else if (url.startsWith("tg:msg") || url.startsWith("tg://msg")) {
|
||||
url = url.replace("tg:msg", "tg://telegram.org").replace("tg://msg", "tg://telegram.org");
|
||||
} else if (url.startsWith("tg:msg") || url.startsWith("tg://msg") || url.startsWith("tg://share") || url.startsWith("tg:share")) {
|
||||
url = url.replace("tg:msg", "tg://telegram.org").replace("tg://msg", "tg://telegram.org").replace("tg://share", "tg://telegram.org").replace("tg:share", "tg://telegram.org");
|
||||
data = Uri.parse(url);
|
||||
message = data.getQueryParameter("url");
|
||||
if (message == null) {
|
||||
|
|
|
@ -890,7 +890,7 @@ public class LoginActivity extends BaseFragment {
|
|||
if (countryState == 1) {
|
||||
needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||
return;
|
||||
} else if (countryState == 2 && !BuildVars.DEBUG_VERSION) {
|
||||
} else if (countryState == 2 && !BuildVars.DEBUG_VERSION && !codeField.getText().toString().equals("999")) {
|
||||
needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("WrongCountry", R.string.WrongCountry));
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue