diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index f776b919..322e99a2 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -24,8 +24,8 @@ dependencies { } android { - compileSdkVersion 19 - buildToolsVersion '20.0.0' + compileSdkVersion 21 + buildToolsVersion '21.0.0' signingConfigs { debug { @@ -80,7 +80,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 359 + versionCode 361 versionName "1.9.5" } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java index aaa5d0e7..26b13aa7 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java @@ -108,6 +108,9 @@ public class ImageReceiver { if (img == null) { isPlaceholder = true; ImageLoader.getInstance().loadImage(fileLocation, httpUrl, this, size, cacheOnly); + if (parentView != null) { + parentView.invalidate(); + } } else { setImageBitmap(img, currentPath); } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java index 48e974fe..e9161291 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java @@ -2081,12 +2081,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel if (end < 0 || info.presentationTimeUs < end) { info.offset = 0; info.flags = extractor.getSampleFlags(); - if (!isAudio) { - buffer.limit(info.offset + info.size); - buffer.position(info.offset); - buffer.putInt(info.size - 4); - } - if (mediaMuxer.writeSampleData(muxerTrackIndex, buffer, info)) { + if (mediaMuxer.writeSampleData(muxerTrackIndex, buffer, info, isAudio)) { didWriteData(messageObject, file, false, false); } extractor.advance(); @@ -2168,6 +2163,23 @@ public class MediaController implements NotificationCenter.NotificationCenterDel resultWidth = temp; rotationValue = 90; rotateRender = 270; + } else if (Build.VERSION.SDK_INT > 20) { + if (rotationValue == 90) { + int temp = resultHeight; + resultHeight = resultWidth; + resultWidth = temp; + rotationValue = 0; + rotateRender = 270; + } else if (rotationValue == 180) { + rotateRender = 180; + rotationValue = 0; + } else if (rotationValue == 270) { + int temp = resultHeight; + resultHeight = resultWidth; + resultWidth = temp; + rotationValue = 0; + rotateRender = 90; + } } File inputFile = new File(videoPath); @@ -2374,10 +2386,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel } if (info.size > 1) { if ((info.flags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) == 0) { - encodedData.limit(info.offset + info.size); - encodedData.position(info.offset); - encodedData.putInt(Integer.reverseBytes(info.size - 4)); - if (mediaMuxer.writeSampleData(videoTrackIndex, encodedData, info)) { + if (mediaMuxer.writeSampleData(videoTrackIndex, encodedData, info, false)) { didWriteData(messageObject, cacheFile, false, false); } } else if (videoTrackIndex == -5) { diff --git a/TMessagesProj/src/main/java/org/telegram/android/video/MP4Builder.java b/TMessagesProj/src/main/java/org/telegram/android/video/MP4Builder.java index a04e8d4c..9d9eca96 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/video/MP4Builder.java +++ b/TMessagesProj/src/main/java/org/telegram/android/video/MP4Builder.java @@ -54,12 +54,13 @@ public class MP4Builder { private InterleaveChunkMdat mdat = null; private Mp4Movie currentMp4Movie = null; - FileOutputStream fos = null; + private FileOutputStream fos = null; private FileChannel fc = null; private long dataOffset = 0; private long writedSinceLastMdat = 0; private boolean writeNewMdat = true; - HashMap track2SampleSizes = new HashMap(); + private HashMap track2SampleSizes = new HashMap(); + private ByteBuffer sizeBuffer = null; public MP4Builder createMovie(Mp4Movie mp4Movie) throws Exception { currentMp4Movie = mp4Movie; @@ -74,6 +75,8 @@ public class MP4Builder { mdat = new InterleaveChunkMdat(); + sizeBuffer = ByteBuffer.allocateDirect(4); + return this; } @@ -87,7 +90,7 @@ public class MP4Builder { fos.flush(); } - public boolean writeSampleData(int trackIndex, ByteBuffer byteBuf, MediaCodec.BufferInfo bufferInfo) throws Exception { + public boolean writeSampleData(int trackIndex, ByteBuffer byteBuf, MediaCodec.BufferInfo bufferInfo, boolean isAudio) throws Exception { if (writeNewMdat) { mdat.setContentSize(0); mdat.getBox(fc); @@ -109,9 +112,16 @@ public class MP4Builder { } currentMp4Movie.addSample(trackIndex, dataOffset, bufferInfo); - byteBuf.position(bufferInfo.offset); + byteBuf.position(bufferInfo.offset + (isAudio ? 0 : 4)); byteBuf.limit(bufferInfo.offset + bufferInfo.size); + if (!isAudio) { + sizeBuffer.position(0); + sizeBuffer.putInt(bufferInfo.size - 4); + sizeBuffer.position(0); + fc.write(sizeBuffer); + } + fc.write(byteBuf); dataOffset += bufferInfo.size; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java index 6b030372..67a050c2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java @@ -370,6 +370,7 @@ public class TLClassStore { classStore.put(TLRPC.TL_userRequest_old.constructor, TLRPC.TL_userRequest_old.class); classStore.put(TLRPC.TL_userForeign_old.constructor, TLRPC.TL_userForeign_old.class); classStore.put(TLRPC.TL_userDeleted_old.constructor, TLRPC.TL_userDeleted_old.class); + classStore.put(TLRPC.TL_messageEcryptedAction.constructor, TLRPC.TL_messageEcryptedAction.class); } static TLClassStore store = null; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java index 7dd0b4c9..7b4cae56 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -278,9 +278,11 @@ public class ChatActionCell extends BaseCell { imageReceiver.draw(canvas, imageReceiver.getImageX(), imageReceiver.getImageY(), imageReceiver.getImageWidth(), imageReceiver.getImageHeight()); } - canvas.save(); - canvas.translate(textXLeft, textY); - textLayout.draw(canvas); - canvas.restore(); + if (textLayout != null) { + canvas.save(); + canvas.translate(textXLeft, textY); + textLayout.draw(canvas); + canvas.restore(); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index ac0fd5fc..eff669ec 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -926,7 +926,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (visibleItemCount > 0) { - if (firstVisibleItem <= 4) { + if (firstVisibleItem <= 10) { if (!endReached && !loading) { if (messagesByDays.size() != 0) { MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced, minDate, classGuid, false, false, null); diff --git a/TMessagesProj/src/main/res/values-v21/styles.xml b/TMessagesProj/src/main/res/values-v21/styles.xml new file mode 100644 index 00000000..c27fb073 --- /dev/null +++ b/TMessagesProj/src/main/res/values-v21/styles.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +