Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
}

def basicVersion = '1.2'
def customVersionCode = '1024';
def customVersionCode = '10240';

if (project.hasProperty('buildIndex')) {
project.version = basicVersion + '.' + project.buildIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ protected OutputStream openWrite(String path) throws FileNotFoundException {

@Override
protected InputStream openRead(String path, boolean error) throws IOException {
if (error) {
return context.getAssets().open(path);
} else {
return context.openFileInput(path);
}
return context.openFileInput(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public void load() throws IOException, ClassNotFoundException {
load(openRead(getClass().getName() + ".sav", false));
} catch (Exception e) {
// e.printStackTrace();
load(openRead(getClass().getName() + ".sav", true));
}
afterLoad();
}
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/java/org/telegram/android/StartActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ private void onInitUpdated() {

// Current version

definitions.add(new WhatsNewFragment.Definition(getString(R.string.whats_new_design_title),
new String[]{
getString(R.string.whats_new_design_0),
getString(R.string.whats_new_design_1),
getString(R.string.whats_new_design_2),
getString(R.string.whats_new_design_3),
}, null));
if (prevVersionCode < 672) {
definitions.add(new WhatsNewFragment.Definition(getString(R.string.whats_new_design_title),
new String[]{
getString(R.string.whats_new_design_0),
getString(R.string.whats_new_design_1),
getString(R.string.whats_new_design_2),
getString(R.string.whats_new_design_3),
}, null));
}

if (prevVersionCode < 517) {
definitions.add(new WhatsNewFragment.Definition(getString(R.string.whats_new_arabic_title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import android.graphics.Bitmap;
import android.graphics.Point;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.media.ThumbnailUtils;
import android.os.*;
import android.provider.MediaStore;
import com.crittercism.app.Crittercism;
import org.telegram.android.StelsApplication;
import org.telegram.android.core.EngineUtils;
import org.telegram.android.core.files.UploadController;
Expand Down Expand Up @@ -468,9 +472,49 @@ public void onPartUploaded(int percent, int downloadedSize) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(uploadingVideo.getFileName());
timeInmillisec = Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
img = retriever.getFrameAtTime(0);
width = img.getWidth();
height = img.getHeight();

if (Build.VERSION.SDK_INT < 10) {
img = ThumbnailUtils.createVideoThumbnail(uploadingVideo.getFileName(),
MediaStore.Images.Thumbnails.MINI_KIND);

MediaPlayer mp = new MediaPlayer();
final Object locker = new Object();
final int[] sizes = new int[2];
try {
mp.setDataSource(uploadingVideo.getFileName());
mp.prepare();
mp.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
synchronized (locker) {
sizes[0] = width;
sizes[1] = height;
locker.notify();
}
}
});

synchronized (locker) {
if (sizes[0] == 0 || sizes[1] == 1) {
locker.wait(5000);
}
}

if (sizes[0] == 0 || sizes[1] == 1) {
throw new IOException();
}

width = sizes[0];
height = sizes[1];
} catch (Exception e) {
Crittercism.logHandledException(e);
throw new IOException();
}
} else {
img = retriever.getFrameAtTime(0);
width = img.getWidth();
height = img.getHeight();
}
} catch (Exception e) {
Logger.t(TAG, e);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public void onClick(View view) {
DownloadListener listener = new DownloadListener() {
@Override
public void onStateChanged(String _key, DownloadState state, int percent) {
if (_key == null) {
return;
}

if (res.getTag() != this) {
application.getDownloadManager().unregisterListener(this);
return;
Expand Down Expand Up @@ -428,12 +432,14 @@ public void onPageScrollStateChanged(int i) {
}

private void onImageTap() {
if (getSherlockActivity().getSupportActionBar().isShowing()) {
getSherlockActivity().getSupportActionBar().hide();
hideView(bottomPanel);
} else {
getSherlockActivity().getSupportActionBar().show();
showView(bottomPanel);
if (getSherlockActivity() != null && getSherlockActivity().getSupportActionBar() != null) {
if (getSherlockActivity().getSupportActionBar() != null && getSherlockActivity().getSupportActionBar().isShowing()) {
getSherlockActivity().getSupportActionBar().hide();
hideView(bottomPanel);
} else {
getSherlockActivity().getSupportActionBar().show();
showView(bottomPanel);
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/org/telegram/android/kernel/SyncKernel.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public void logIn() {

public void logOut() {
typingStates.clearState();
updateProcessor.destroy();
updateProcessor.clearData();
updateProcessor = null;
if (updateProcessor != null) {
updateProcessor.destroy();
updateProcessor.clearData();
updateProcessor = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ private static Object convert(Object object) {
res.setPreviewHeight(video.getPreviewHeight());
res.setPreviewWidth(video.getPreviewWidth());
return res;
} else if (object == null) {
return null;
} else {
Logger.d(TAG, "Unknown java object:" + object.toString());
return null;
}
Logger.d(TAG, "Unknown java object:" + object.toString());
return null;
}

public static TLObject deserialize(byte[] data) {
Expand Down
42 changes: 37 additions & 5 deletions app/src/main/java/org/telegram/android/media/DownloadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import android.graphics.*;
import android.media.MediaScannerConnection;
import android.os.*;
import android.widget.Toast;
import com.extradea.framework.images.utils.ImageUtils;
import org.telegram.android.R;
import org.telegram.android.StelsApplication;
import org.telegram.android.core.model.media.*;
import org.telegram.android.log.Logger;
Expand Down Expand Up @@ -132,6 +134,12 @@ public synchronized void requestDownload(TLLocalPhoto photo) {
if (downloadPersistence.isDownloaded(resourceKey))
return;

String fileName = getDownloadImageFile(resourceKey);
if (fileName == null) {
Toast.makeText(application, R.string.error_sd_card, Toast.LENGTH_SHORT).show();
return;
}

final DownloadRecord record;
if (records.containsKey(resourceKey)) {
record = records.get(resourceKey);
Expand Down Expand Up @@ -164,6 +172,12 @@ public synchronized void requestDownload(TLLocalVideo video) {
if (downloadPersistence.isDownloaded(resourceKey))
return;

String fileName = getDownloadImageFile(resourceKey);
if (fileName == null) {
Toast.makeText(application, R.string.error_sd_card, Toast.LENGTH_SHORT).show();
return;
}

final DownloadRecord record;
if (records.containsKey(resourceKey)) {
record = records.get(resourceKey);
Expand All @@ -187,7 +201,7 @@ record = new DownloadRecord();
}

requestDownload(resourceKey, record,
getDownloadVideoFile(resourceKey),
fileName,
video.getVideoLocation());
}

Expand Down Expand Up @@ -279,6 +293,12 @@ public void onFailed() {
Logger.d(TAG, "@" + key + " = saving thumb");
FileOutputStream outputStream = null;
try {
String thumbFileName = getPhotoThumbSmallFileName(key);
if (thumbFileName == null) {
Toast.makeText(application, "SD card not available", Toast.LENGTH_SHORT).show();
updateState(key, DownloadState.FAILURE, 100, size);
return;
}
outputStream = new FileOutputStream(getPhotoThumbSmallFileName(key));
thumb.compress(Bitmap.CompressFormat.JPEG, 87, outputStream);
} catch (FileNotFoundException e) {
Expand Down Expand Up @@ -367,19 +387,31 @@ public String getPhotoThumbSmallFileName(String key) {
}

private String getDownloadVideoFile(String key) {
return application.getExternalCacheDir().getAbsolutePath() + "/video_" + key + ".mp4";
if (application.getExternalCacheDir() != null) {
return application.getExternalCacheDir().getAbsolutePath() + "/video_" + key + ".mp4";
}
return null;
}

private String getDownloadImageFile(String key) {
return application.getExternalCacheDir().getAbsolutePath() + "/image_" + key + ".jpg";
if (application.getExternalCacheDir() != null) {
return application.getExternalCacheDir().getAbsolutePath() + "/image_" + key + ".jpg";
}
return null;
}

private String getDownloadImageThumbFile(String key) {
return application.getExternalCacheDir().getAbsolutePath() + "/image_thumb_" + key + ".jpg";
if (application.getExternalCacheDir() != null) {
return application.getExternalCacheDir().getAbsolutePath() + "/image_thumb_" + key + ".jpg";
}
return null;
}

private String getDownloadTempFile() {
return application.getExternalCacheDir().getAbsolutePath() + "/download_" + Entropy.generateRandomId() + ".bin";
if (application.getExternalCacheDir() != null) {
return application.getExternalCacheDir().getAbsolutePath() + "/download_" + Entropy.generateRandomId() + ".bin";
}
return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ private void buildLayout() {

// Group sender
if (isGroup) {
String wName = senderTitle.replace("\n", " ");
String wName = senderTitle != null ? senderTitle.replace("\n", " ") : "UNKNOWN";
if (wName.length() > 100) {
wName = wName.substring(100) + "...";
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/common_text.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="error_sd_card">SD Card not available</string>
<string name="lang_common_typing">typing...</string>
<string name="lang_common_typing_single">{content} is typing...</string>
<string name="lang_common_typing_multiple">{content} are typing...</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/ui_whats_new.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<resources>
<string name="whats_new_design_title">Design, speed and stability</string>
<string name="whats_new_design_0">New blue design</string>
<string name="whats_new_design_1">Speed up photo, video and message delivery</string>
<string name="whats_new_design_2">Optimizations to "firewalled" countries</string>
<string name="whats_new_design_3">Much better stability</string>
<string name="whats_new_design_1">Faster message, photo and video delivery</string>
<string name="whats_new_design_2">Optimized for firewalled countries</string>
<string name="whats_new_design_3">Highly improved stability</string>

<string name="whats_new_secret_title">Added secret chats</string>
<string name="whats_new_secret_hint">Start a secret chat from the "Write to" menu or from a contact\'s profile.
Expand Down
2 changes: 1 addition & 1 deletion libraries/telegram-api