Skip to content

Commit 27972c8

Browse files
author
DrKLO
committed
Update locales, bug fixes
1 parent ab44b87 commit 27972c8

27 files changed

+193
-153
lines changed

TMessagesProj/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ android {
8080
defaultConfig {
8181
minSdkVersion 8
8282
targetSdkVersion 19
83-
versionCode 329
83+
versionCode 330
8484
versionName "1.9.0"
8585
}
8686
}

TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,14 @@ public void run() {
585585

586586
private HashMap<Integer, File> createMediaPaths() {
587587
HashMap<Integer, File> mediaDirs = new HashMap<Integer, File>();
588-
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, AndroidUtilities.getCacheDir());
588+
File cachePath = AndroidUtilities.getCacheDir();
589+
try {
590+
cachePath.mkdirs();
591+
new File(cachePath, ".nomedia").createNewFile();
592+
} catch (Exception e) {
593+
FileLog.e("tmessages", e);
594+
}
595+
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
589596
try {
590597
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
591598
File telegramPath = new File(Environment.getExternalStorageDirectory(), LocaleController.getString("AppName", R.string.AppName));
@@ -780,7 +787,7 @@ public void loadImage(final TLRPC.FileLocation fileLocation, final String httpUr
780787
if (!added) {
781788
boolean onlyCache = false;
782789
File cacheFile = null;
783-
if (size == 0 || httpUrl != null || fileLocation != null && fileLocation.key != null) {
790+
if (size == 0 || httpUrl != null || fileLocation != null && (fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0)) {
784791
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), url);
785792
} else {
786793
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_IMAGE), url);

TMessagesProj/src/main/java/org/telegram/android/MessagesController.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,11 +1654,6 @@ public TLRPC.TL_photo generatePhotoSizes(String path, Uri imageUri) {
16541654
size.type = "s";
16551655
sizes.add(size);
16561656
}
1657-
size = ImageLoader.scaleAndSaveImage(bitmap, 320, 320, 80, false);
1658-
if (size != null) {
1659-
size.type = "m";
1660-
sizes.add(size);
1661-
}
16621657
size = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false);
16631658
if (size != null) {
16641659
size.type = "x";

TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,12 @@ private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage,
10641064
break;
10651065
}
10661066
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
1067-
File cacheFile2 = FileLoader.getPathToAttach(size);
1067+
File cacheFile2 = null;
1068+
if (sentMessage.media.photo.sizes.size() == 1 || size.w > 80 || size.h > 80) {
1069+
cacheFile2 = FileLoader.getPathToAttach(size);
1070+
} else {
1071+
cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
1072+
}
10681073
cacheFile.renameTo(cacheFile2);
10691074
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2);
10701075
size2.location = size.location;
@@ -1086,7 +1091,7 @@ private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage,
10861091
String fileName2 = size.location.volume_id + "_" + size.location.local_id;
10871092
if (!fileName.equals(fileName2)) {
10881093
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
1089-
File cacheFile2 = FileLoader.getPathToAttach(size);
1094+
File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
10901095
cacheFile.renameTo(cacheFile2);
10911096
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2);
10921097
size2.location = size.location;
@@ -1107,7 +1112,7 @@ private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage,
11071112
String fileName2 = size.location.volume_id + "_" + size.location.local_id;
11081113
if (!fileName.equals(fileName2)) {
11091114
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
1110-
File cacheFile2 = FileLoader.getPathToAttach(size);
1115+
File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
11111116
cacheFile.renameTo(cacheFile2);
11121117
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2);
11131118
size2.location = size.location;

TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ public static File getPathToAttach(TLObject attach) {
606606
}
607607
} else if (attach instanceof TLRPC.PhotoSize) {
608608
TLRPC.PhotoSize photoSize = (TLRPC.PhotoSize)attach;
609-
if (photoSize.location == null || photoSize.location.key != null) {
609+
if (photoSize.location == null || photoSize.location.key != null || photoSize.location.volume_id == Integer.MIN_VALUE && photoSize.location.local_id < 0) {
610610
dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
611611
} else {
612612
dir = getInstance().getDirectory(MEDIA_DIR_IMAGE);
@@ -620,7 +620,7 @@ public static File getPathToAttach(TLObject attach) {
620620
}
621621
} else if (attach instanceof TLRPC.FileLocation) {
622622
TLRPC.FileLocation fileLocation = (TLRPC.FileLocation)attach;
623-
if (fileLocation.key != null) {
623+
if (fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0) {
624624
dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
625625
} else {
626626
dir = getInstance().getDirectory(MEDIA_DIR_IMAGE);

TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
4242

4343
public static interface ChatMediaCellDelegate {
4444
public abstract void didPressedImage(ChatMediaCell cell);
45+
public abstract void didPressedOther(ChatMediaCell cell);
4546
}
4647

4748
private static Drawable placeholderInDrawable;
@@ -77,6 +78,7 @@ public static interface ChatMediaCellDelegate {
7778
private int buttonState = 0;
7879
private int buttonPressed = 0;
7980
private boolean imagePressed = false;
81+
private boolean otherPressed = false;
8082
private int buttonX;
8183
private int buttonY;
8284

@@ -182,6 +184,9 @@ public boolean onTouchEvent(MotionEvent event) {
182184
if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(50) && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
183185
imagePressed = true;
184186
result = true;
187+
} else if (x >= photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(50) && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
188+
otherPressed = true;
189+
result = true;
185190
}
186191
} else {
187192
if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
@@ -223,9 +228,32 @@ public boolean onTouchEvent(MotionEvent event) {
223228
imagePressed = false;
224229
invalidate();
225230
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
226-
if (!photoImage.isInsideImage(x, y)) {
227-
imagePressed = false;
228-
invalidate();
231+
if (currentMessageObject.type == 9) {
232+
if (!(x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(50) && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight())) {
233+
imagePressed = false;
234+
invalidate();
235+
}
236+
} else {
237+
if (!photoImage.isInsideImage(x, y)) {
238+
imagePressed = false;
239+
invalidate();
240+
}
241+
}
242+
}
243+
} else if (otherPressed) {
244+
if (event.getAction() == MotionEvent.ACTION_UP) {
245+
otherPressed = false;
246+
playSoundEffect(SoundEffectConstants.CLICK);
247+
if (mediaDelegate != null) {
248+
mediaDelegate.didPressedOther(this);
249+
}
250+
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
251+
otherPressed = false;
252+
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
253+
if (currentMessageObject.type == 9) {
254+
if (!(x >= photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(50) && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight())) {
255+
otherPressed = false;
256+
}
229257
}
230258
}
231259
}

TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,6 +3375,11 @@ public void didPressedImage(ChatMediaCell cell) {
33753375
}
33763376
}
33773377
}
3378+
3379+
@Override
3380+
public void didPressedOther(ChatMediaCell cell) {
3381+
createMenu(cell, true);
3382+
}
33783383
};
33793384
}
33803385

@@ -3477,11 +3482,7 @@ public void update() {
34773482
if (type == 11 || type == 10) {
34783483
int width = 0;
34793484
if (AndroidUtilities.isTablet()) {
3480-
int leftWidth = AndroidUtilities.displaySize.x / 100 * 35;
3481-
if (leftWidth < AndroidUtilities.dp(320)) {
3482-
leftWidth = AndroidUtilities.dp(320);
3483-
}
3484-
width = AndroidUtilities.displaySize.x - leftWidth - AndroidUtilities.dp(30);
3485+
width = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(30);
34853486
} else {
34863487
width = AndroidUtilities.displaySize.x - AndroidUtilities.dp(30);
34873488
}

TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ private void updateVideoEditedInfo() {
412412
}
413413
int width = rotationValue == 90 || rotationValue == 270 ? resultHeight : resultWidth;
414414
int height = rotationValue == 90 || rotationValue == 270 ? resultWidth : resultHeight;
415-
String videoDimension = String.format("%dx%d", resultWidth, resultHeight);
415+
String videoDimension = String.format("%dx%d", width, height);
416416

417417
esimatedDuration = (long)Math.max(1000, (videoTimelineView.getRightProgress() - videoTimelineView.getLeftProgress()) * videoDuration);
418418
estimatedSize = calculateEstimatedSize((float)esimatedDuration / videoDuration);
@@ -638,7 +638,9 @@ private void didWriteData(final String videoPath, final long finalSize) {
638638
@Override
639639
public void run() {
640640
if (firstWrite) {
641-
delegate.didStartVideoConverting(videoPath, VideoEditorActivity.this.videoPath, estimatedSize, (int)esimatedDuration, resultWidth, resultHeight);
641+
int width = rotationValue == 90 || rotationValue == 270 ? resultHeight : resultWidth;
642+
int height = rotationValue == 90 || rotationValue == 270 ? resultWidth : resultHeight;
643+
delegate.didStartVideoConverting(videoPath, VideoEditorActivity.this.videoPath, estimatedSize, (int)esimatedDuration, width, height);
642644
firstWrite = false;
643645
finishFragment();
644646
} else {
@@ -880,7 +882,7 @@ private boolean startConvert2() {
880882
colorFormat = selectColorFormat(codecInfo, MIME_TYPE);
881883
if (codecInfo.getName().contains("OMX.qcom.")) {
882884
processorType = PROCESSOR_TYPE_QCOM;
883-
if (Build.MANUFACTURER.toLowerCase().equals("nokia")) {
885+
if (Build.VERSION.SDK_INT == 16) { //nokia, lge
884886
swapUV = 1;
885887
}
886888
}
@@ -900,9 +902,11 @@ private boolean startConvert2() {
900902
bufferSize += padding * 5 / 4;
901903
}
902904
} else if (processorType == PROCESSOR_TYPE_QCOM) {
903-
int uvoffset = (resultWidth * resultHeight + 2047) & ~2047;
904-
padding = uvoffset - (resultWidth * resultHeight);
905-
bufferSize += padding;
905+
if (!Build.MANUFACTURER.toLowerCase().equals("lge")) {
906+
int uvoffset = (resultWidth * resultHeight + 2047) & ~2047;
907+
padding = uvoffset - (resultWidth * resultHeight);
908+
bufferSize += padding;
909+
}
906910
}
907911

908912
extractor.selectTrack(videoIndex);

TMessagesProj/src/main/res/drawable-hdpi/msg_clock.png

100644100755
-83 Bytes
Loading
759 Bytes
Loading

0 commit comments

Comments
 (0)