Commit ebe7ab78 authored by DrKLO's avatar DrKLO

Gif support, applying localization files from document messages

parent 5323e87b
......@@ -794,6 +794,9 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIE
return;
}
info->lastFrameReaminder = getRealTime() - info->nextStartTime;
if (info->lastFrameReaminder > 0) {
info->lastFrameReaminder = 0;
}
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_restoreRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
......
......@@ -198,7 +198,7 @@ public class FileLoadOperation {
}
final boolean dontDelete = isLocalFile;
if ((exist = cacheFileFinal.exists()) && !ignoreCache) {
Utilities.cacheOutQueue.postRunnable(new Runnable() {
FileLoader.cacheOutQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
......@@ -403,7 +403,7 @@ public class FileLoadOperation {
final boolean renamed = cacheFileTemp.renameTo(cacheFileFinal);
if (needBitmapCreate) {
Utilities.cacheOutQueue.postRunnable(new Runnable() {
FileLoader.cacheOutQueue.postRunnable(new Runnable() {
@Override
public void run() {
int delay = 20;
......@@ -520,7 +520,7 @@ public class FileLoadOperation {
int readed = httpConnectionStream.read(data);
if (readed > 0) {
fileOutputStream.write(data, 0, readed);
Utilities.imageLoadQueue.postRunnable(new Runnable() {
FileLoader.fileLoaderQueue.postRunnable(new Runnable() {
@Override
public void run() {
startDownloadHTTPRequest();
......
......@@ -12,9 +12,13 @@ import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.text.format.DateFormat;
import android.util.Xml;
import org.telegram.ui.ApplicationLoader;
import org.xmlpull.v1.XmlPullParser;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
......@@ -66,42 +70,42 @@ public class LocaleController {
}
public LocaleController() {
LocaleController.LocaleInfo localeInfo = new LocaleController.LocaleInfo();
LocaleInfo localeInfo = new LocaleInfo();
localeInfo.name = "English";
localeInfo.nameEnglish = "English";
localeInfo.shortName = "en";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleController.LocaleInfo();
localeInfo = new LocaleInfo();
localeInfo.name = "Italiano";
localeInfo.nameEnglish = "Italian";
localeInfo.shortName = "it";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleController.LocaleInfo();
localeInfo = new LocaleInfo();
localeInfo.name = "Español";
localeInfo.nameEnglish = "Spanish";
localeInfo.shortName = "es";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleController.LocaleInfo();
localeInfo = new LocaleInfo();
localeInfo.name = "Deutsch";
localeInfo.nameEnglish = "German";
localeInfo.shortName = "de";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleController.LocaleInfo();
localeInfo = new LocaleInfo();
localeInfo.name = "Nederlands";
localeInfo.nameEnglish = "Dutch";
localeInfo.shortName = "nl";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleController.LocaleInfo();
localeInfo = new LocaleInfo();
localeInfo.name = "العربية";
localeInfo.nameEnglish = "Arabic";
localeInfo.shortName = "ar";
......@@ -148,6 +152,75 @@ public class LocaleController {
}
}
public boolean applyLanguageFile(File file) {
try {
HashMap<String, String> stringMap = new HashMap<String, String>();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(new FileInputStream(file), "UTF-8");
int eventType = parser.getEventType();
String name = null;
String value = null;
String attrName = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG) {
name = parser.getName();
int c = parser.getAttributeCount();
if (c > 0) {
attrName = parser.getAttributeValue(0);
}
} else if(eventType == XmlPullParser.TEXT) {
if (attrName != null) {
value = parser.getText();
}
} else if (eventType == XmlPullParser.END_TAG) {
value = null;
attrName = null;
name = null;
}
if (name != null && name.equals("string") && value != null && attrName != null) {
stringMap.put(attrName, value);
name = null;
value = null;
attrName = null;
}
eventType = parser.next();
}
String languageName = stringMap.get("LanguageName");
String languageNameInEnglish = stringMap.get("LanguageNameInEnglish");
String languageCode = stringMap.get("LanguageCode");
if (languageName != null && languageName.length() > 0 &&
languageNameInEnglish != null && languageNameInEnglish.length() > 0 &&
languageCode != null && languageCode.length() > 0) {
LocaleInfo localeInfo = new LocaleInfo();
localeInfo.name = languageName;
localeInfo.nameEnglish = languageNameInEnglish;
localeInfo.shortName = languageCode;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
Collections.sort(sortedLanguages, new Comparator<LocaleInfo>() {
@Override
public int compare(LocaleController.LocaleInfo o, LocaleController.LocaleInfo o2) {
if (o.shortName == null) {
return -1;
} else if (o2.shortName == null) {
return 1;
}
return o.name.compareTo(o2.name);
}
});
applyLanguage(localeInfo, true);
localeValues = stringMap;
return true;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return false;
}
public void applyLanguage(LocaleInfo localeInfo, boolean override) {
if (localeInfo == null) {
return;
......@@ -196,7 +269,7 @@ public class LocaleController {
}
public static String getCurrentLanguageName() {
return getString("LanguangeName", R.string.LanguangeName);
return getString("LanguageName", R.string.LanguageName);
}
public static String getString(String key, int res) {
......
......@@ -20,9 +20,12 @@ import android.media.audiofx.AutomaticGainControl;
import android.net.Uri;
import android.os.Environment;
import android.os.Vibrator;
import android.view.View;
import org.telegram.objects.MessageObject;
import org.telegram.ui.ApplicationLoader;
import org.telegram.ui.Cells.ChatMediaCell;
import org.telegram.ui.Views.GifDrawable;
import java.io.File;
import java.io.FileInputStream;
......@@ -54,6 +57,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public void onFailedDownload(String fileName);
public void onSuccessDownload(String fileName);
public void onProgressDownload(String fileName, float progress);
public void onProgressUpload(String fileName, float progress, boolean isEncrypted);
public int getObserverTag();
}
......@@ -84,6 +88,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private ArrayList<FileDownloadProgressListener> deleteLaterArray = new ArrayList<FileDownloadProgressListener>();
private int lastTag = 0;
private GifDrawable currentGifDrawable;
private MessageObject currentGifMessageObject;
private ChatMediaCell currentMediaCell;
private boolean isPaused = false;
private MediaPlayer audioPlayer = null;
private AudioTrack audioTrackPlayer = null;
......@@ -226,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidFailedLoad);
NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidLoaded);
NotificationCenter.getInstance().addObserver(this, FileLoader.FileLoadProgressChanged);
NotificationCenter.getInstance().addObserver(this, FileLoader.FileUploadProgressChanged);
Timer progressTimer = new Timer();
progressTimer.schedule(new TimerTask() {
......@@ -273,6 +282,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public void cleanup() {
clenupPlayer(false);
if (currentGifDrawable != null) {
currentGifDrawable.recycle();
currentGifDrawable = null;
}
currentMediaCell = null;
currentGifMessageObject = null;
}
public int generateObserverTag() {
......@@ -377,6 +392,22 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
listenerInProgress = false;
processLaterArrays();
} else if (id == FileLoader.FileUploadProgressChanged) {
String location = (String)args[0];
listenerInProgress = true;
String fileName = (String)args[0];
ArrayList<WeakReference<FileDownloadProgressListener>> arrayList = loadingFileObservers.get(fileName);
if (arrayList != null) {
Float progress = (Float)args[1];
Boolean enc = (Boolean)args[2];
for (WeakReference<FileDownloadProgressListener> reference : arrayList) {
if (reference.get() != null) {
reference.get().onProgressUpload(fileName, progress, enc);
}
}
}
listenerInProgress = false;
processLaterArrays();
}
}
......@@ -1079,4 +1110,73 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
});
}
}
public GifDrawable getGifDrawable(ChatMediaCell cell, boolean create) {
if (cell == null) {
return null;
}
MessageObject messageObject = cell.getMessageObject();
if (messageObject == null) {
return null;
}
if (currentGifMessageObject != null && messageObject.messageOwner.id == currentGifMessageObject.messageOwner.id) {
currentMediaCell = cell;
currentGifDrawable.parentView = new WeakReference<View>(cell);
return currentGifDrawable;
}
if (create) {
if (currentMediaCell != null) {
if (currentGifDrawable != null) {
currentGifDrawable.stop();
currentGifDrawable.recycle();
}
currentMediaCell.clearGifImage();
}
currentGifMessageObject = cell.getMessageObject();
currentMediaCell = cell;
File cacheFile = null;
if (currentGifMessageObject.messageOwner.attachPath != null && currentGifMessageObject.messageOwner.attachPath.length() != 0) {
File f = new File(currentGifMessageObject.messageOwner.attachPath);
if (f.length() > 0) {
cacheFile = f;
}
} else {
cacheFile = new File(Utilities.getCacheDir(), messageObject.getFileName());
}
try {
currentGifDrawable = new GifDrawable(cacheFile);
currentGifDrawable.parentView = new WeakReference<View>(cell);
return currentGifDrawable;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
return null;
}
public void clearGifDrawable(ChatMediaCell cell) {
if (cell == null) {
return;
}
MessageObject messageObject = cell.getMessageObject();
if (messageObject == null) {
return;
}
if (currentGifMessageObject != null && messageObject.messageOwner.id == currentGifMessageObject.messageOwner.id) {
if (currentGifDrawable != null) {
currentGifDrawable.stop();
currentGifDrawable.recycle();
currentGifDrawable = null;
}
currentMediaCell = null;
currentGifMessageObject = null;
}
}
}
......@@ -76,9 +76,6 @@ public class Utilities {
public static volatile DispatchQueue stageQueue = new DispatchQueue("stageQueue");
public static volatile DispatchQueue globalQueue = new DispatchQueue("globalQueue");
public static volatile DispatchQueue cacheOutQueue = new DispatchQueue("cacheOutQueue");
public static volatile DispatchQueue imageLoadQueue = new DispatchQueue("imageLoadQueue");
public static volatile DispatchQueue fileUploadQueue = new DispatchQueue("fileUploadQueue");
public static int[] arrColors = {0xffee4928, 0xff41a903, 0xffe09602, 0xff0f94ed, 0xff8f3bf7, 0xfffc4380, 0xff00a1c4, 0xffeb7002};
public static int[] arrUsersAvatars = {
......
......@@ -35,6 +35,7 @@ public class MessageObject {
public TLRPC.Message messageOwner;
public CharSequence messageText;
public int type;
public int contentType;
public ArrayList<PhotoObject> photoThumbs;
public Bitmap imagePreview;
public PhotoObject previewPhoto;
......@@ -244,6 +245,11 @@ public class MessageObject {
} else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
messageText = LocaleController.getString("UnsuppotedMedia", R.string.UnsuppotedMedia);
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
if (!(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(message.media.document.thumb);
photoThumbs.add(obj);
}
messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument);
} else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
messageText = LocaleController.getString("AttachAudio", R.string.AttachAudio);
......@@ -255,68 +261,53 @@ public class MessageObject {
if (message instanceof TLRPC.TL_message || (message instanceof TLRPC.TL_messageForwarded && (message.media == null || !(message.media instanceof TLRPC.TL_messageMediaEmpty)))) {
if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) {
if (message.from_id == UserConfig.clientUserId) {
type = 0;
} else {
type = 1;
}
contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) {
if (message.from_id == UserConfig.clientUserId) {
type = 2;
} else {
type = 3;
}
contentType = type = 1;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaGeo) {
if (message.from_id == UserConfig.clientUserId) {
type = 4;
contentType = type = 4;
} else {
type = 5;
contentType = type = 5;
}
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaVideo) {
if (message.from_id == UserConfig.clientUserId) {
type = 6;
contentType = type = 6;
} else {
type = 7;
contentType = type = 7;
}
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaContact) {
if (message.from_id == UserConfig.clientUserId) {
type = 12;
contentType = type = 12;
} else {
type = 13;
contentType = type = 13;
}
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaUnsupported) {
if (message.from_id == UserConfig.clientUserId) {
type = 0;
} else {
type = 1;
}
contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) {
if (message.from_id == UserConfig.clientUserId) {
type = 16;
if (message.media.document.thumb != null && !(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty) && message.media.document.mime_type != null && message.media.document.mime_type.equals("image/gif")) {
contentType = 1;
type = 8;
} else {
type = 17;
if (message.from_id == UserConfig.clientUserId) {
contentType = type = 8;
} else {
contentType = type = 9;
}
}
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaAudio) {
if (message.from_id == UserConfig.clientUserId) {
type = 18;
} else {
type = 19;
}
contentType = type = 2;
}
} else if (message instanceof TLRPC.TL_messageService) {
if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
type = 1;
contentType = type = 0;
} else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto || message.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
type = 11;
contentType = type = 11;
} else {
type = 10;
contentType = type = 10;
}
} else if (message instanceof TLRPC.TL_messageForwarded) {
if (message.from_id == UserConfig.clientUserId) {
type = 8;
} else {
type = 9;
}
contentType = type = 0;
}
Calendar rightNow = new GregorianCalendar();
......
......@@ -60,8 +60,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
private TLRPC.FileLocation currentPhoto;
private String currentNameString;
public ChatAudioCell(Context context, boolean isChat) {
super(context, isChat);
public ChatAudioCell(Context context) {
super(context, false);
TAG = MediaController.getInstance().generateObserverTag();
avatarImage = new ImageReceiver();
......@@ -101,6 +101,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
avatarImage.clearImage();
currentPhoto = null;
}
MediaController.getInstance().removeLoadingFileObserver(this);
}
@Override
......@@ -230,7 +231,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
}
progressView.setProgress(0);
} else {
MediaController.getInstance().addLoadingFileObserver(currentMessageObject.getFileName(), this);
MediaController.getInstance().addLoadingFileObserver(fileName, this);
if (!FileLoader.getInstance().isLoadingFile(fileName)) {
buttonState = 2;
progressView.setProgress(0);
......@@ -263,6 +264,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
invalidate();
}
@Override
public void onProgressUpload(String fileName, float progress, boolean isEncrypted) {
}
@Override
public int getObserverTag() {
return TAG;
......@@ -281,7 +287,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(width, Utilities.dp(68));
if (chat) {
if (isChat) {
backgroundWidth = Math.min(width - Utilities.dp(102), Utilities.dp(300));
} else {
backgroundWidth = Math.min(width - Utilities.dp(50), Utilities.dp(300));
......@@ -298,7 +304,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
buttonX = layoutWidth - backgroundWidth + Utilities.dp(67);
timeX = layoutWidth - backgroundWidth + Utilities.dp(71);
} else {
if (chat) {
if (isChat) {
avatarImage.imageX = Utilities.dp(69);
seekBarX = Utilities.dp(158);
buttonX = Utilities.dp(128);
......@@ -355,10 +361,10 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if (messageObject.messageOwner.out) {
seekBar.type = 0;
progressView.type = 0;
progressView.setProgressColors(0xffb4e396, 0xff6ac453);
} else {
seekBar.type = 1;
progressView.type = 1;
progressView.setProgressColors(0xffd9e2eb, 0xff86c5f8);
}
super.setMessageObject(messageObject);
......@@ -405,10 +411,4 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
timeLayout.draw(canvas);
canvas.restore();
}
@Override
protected void finalize() throws Throwable {
MediaController.getInstance().removeLoadingFileObserver(this);
super.finalize();
}
}
......@@ -28,8 +28,8 @@ public class ChatMessageCell extends ChatBaseCell {
private int firstVisibleBlockNum = 0;
private int totalVisibleBlocksCount = 0;
public ChatMessageCell(Context context, boolean isChat) {
super(context, isChat);
public ChatMessageCell(Context context) {
super(context, false);
drawForwardedName = true;
}
......@@ -131,7 +131,7 @@ public class ChatMessageCell extends ChatBaseCell {
}
pressedLink = null;
int maxWidth;
if (chat) {
if (isChat) {
maxWidth = Utilities.displaySize.x - Utilities.dp(122);
drawName = true;
} else {
......@@ -180,7 +180,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX = layoutWidth - backgroundWidth + Utilities.dp(10);
textY = Utilities.dp(10) + namesOffset;
} else {
textX = Utilities.dp(19) + (chat ? Utilities.dp(52) : 0);
textX = Utilities.dp(19) + (isChat ? Utilities.dp(52) : 0);
textY = Utilities.dp(10) + namesOffset;
}
}
......@@ -196,7 +196,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX = layoutWidth - backgroundWidth + Utilities.dp(10);
textY = Utilities.dp(10) + namesOffset;
} else {
textX = Utilities.dp(19) + (chat ? Utilities.dp(52) : 0);
textX = Utilities.dp(19) + (isChat ? Utilities.dp(52) : 0);
textY = Utilities.dp(10) + namesOffset;
}
......
......@@ -409,7 +409,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
listView.invalidateViews();
}
} else if (i == languageRow) {
((LaunchActivity)parentActivity).presentFragment(new LanguageSelectActivity(), "settings_wallpapers", false);
((LaunchActivity)parentActivity).presentFragment(new LanguageSelectActivity(), "settings_lang", false);
} else if (i == switchBackendButtonRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
......
......@@ -24,6 +24,7 @@ THE SOFTWARE.
package org.telegram.ui.Views;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
......@@ -33,9 +34,11 @@ import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.MediaController;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.Locale;
public class GifDrawable extends Drawable implements Animatable, MediaController.MediaPlayerControl {
......@@ -68,6 +71,8 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private boolean mApplyTransformation;
private final Rect mDstRect = new Rect();
public WeakReference<View> parentView = null;
protected final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
protected final int[] mColors;
......@@ -82,7 +87,10 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public void run() {
restoreRemainder(mGifInfoPtr);
invalidateSelf();
if (parentView != null && parentView.get() != null) {
parentView.get().invalidate();
}
mMetaData[4] = 0;
}
};
......@@ -96,7 +104,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private final Runnable mInvalidateTask = new Runnable() {
@Override
public void run() {
invalidateSelf();
if (parentView != null && parentView.get() != null) {
parentView.get().invalidate();
}
}
};
......@@ -109,18 +119,12 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
}
public GifDrawable(String filePath) throws Exception {
if (filePath == null) {
throw new NullPointerException("Source is null");
}
mInputSourceLength = new File(filePath).length();
mGifInfoPtr = openFile(mMetaData, filePath);
mColors = new int[mMetaData[0] * mMetaData[1]];
}
public GifDrawable(File file) throws Exception {
if (file == null) {
throw new NullPointerException("Source is null");
}
mInputSourceLength = file.length();
mGifInfoPtr = openFile(mMetaData, file.getPath());
mColors = new int[mMetaData[0] * mMetaData[1]];
......@@ -169,6 +173,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public void start() {
if (mIsRunning) {
return;
}
mIsRunning = true;
runOnUiThread(mStartTask);
}
......@@ -240,7 +247,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public void run() {
seekToTime(mGifInfoPtr, position, mColors);
invalidateSelf();
if (parentView != null && parentView.get() != null) {
parentView.get().invalidate();
}
}
});
}
......@@ -253,7 +262,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public void run() {
seekToFrame(mGifInfoPtr, frameIndex, mColors);
invalidateSelf();
if (parentView != null && parentView.get() != null) {
parentView.get().invalidate();
}
}
});
}
......@@ -323,6 +334,11 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
return mColors[mMetaData[1] * y + x];
}
public Bitmap getBitmap() {
seekToFrame(mGifInfoPtr, 0, mColors);
return Bitmap.createBitmap(mColors, 0, mMetaData[0], mMetaData[0], mMetaData[1], Bitmap.Config.ARGB_8888);
}
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
......@@ -343,6 +359,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
} else {
mMetaData[4] = -1;
}
canvas.translate(mDstRect.left, mDstRect.top);
canvas.scale(mSx, mSy);
canvas.drawBitmap(mColors, 0, mMetaData[0], 0f, 0f, mMetaData[0], mMetaData[1], true, mPaint);
if (mMetaData[4] >= 0 && mMetaData[2] > 1) {
......@@ -365,13 +382,17 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public void setFilterBitmap(boolean filter) {
mPaint.setFilterBitmap(filter);
invalidateSelf();
if (parentView != null && parentView.get() != null) {
parentView.get().invalidate();
}
}
@Override
public void setDither(boolean dither) {
mPaint.setDither(dither);
invalidateSelf();
if (parentView != null && parentView.get() != null) {
parentView.get().invalidate();
}
}
@Override
......
......@@ -111,10 +111,47 @@ public class ImageReceiver {
}
}
public void setImageBitmap(Bitmap bitmap) {
currentPath = null;
last_path = null;
last_httpUrl = null;
last_filter = null;
last_placeholder = null;
last_size = 0;
FileLoader.getInstance().cancelLoadingForImageView(this);
if (bitmap != null) {
recycleBitmap(null);
currentImage = new BitmapDrawable(null, bitmap);
}
}
public void setImageBitmap(Drawable bitmap) {
currentPath = null;
last_path = null;
last_httpUrl = null;
last_filter = null;
last_placeholder = null;
last_size = 0;
FileLoader.getInstance().cancelLoadingForImageView(this);
if (bitmap != null) {
recycleBitmap(null);
currentImage = bitmap;
}
}
public void clearImage() {
recycleBitmap(null);
}
@Override
protected void finalize() throws Throwable {
try {
clearImage();
} finally {
super.finalize();
}
}
private void recycleBitmap(Bitmap newBitmap) {
if (currentImage == null || isPlaceholder) {
return;
......
......@@ -14,50 +14,35 @@ import android.graphics.Paint;
import org.telegram.messenger.Utilities;
public class ProgressView {
private static Paint innerPaint1;
private static Paint outerPaint1;
private static Paint innerPaint2;
private static Paint outerPaint2;
private Paint innerPaint;
private Paint outerPaint;
public int type;
public int thumbX = 0;
public float currentProgress = 0;
public int width;
public int height;
public float progressHeight = Utilities.dpf(2.0f);
public ProgressView() {
if (innerPaint1 == null) {
innerPaint1 = new Paint();
outerPaint1 = new Paint();
innerPaint2 = new Paint();
outerPaint2 = new Paint();
innerPaint1.setColor(0xffb4e396);
outerPaint1.setColor(0xff6ac453);
innerPaint2.setColor(0xffd9e2eb);
outerPaint2.setColor(0xff86c5f8);
}
innerPaint = new Paint();
outerPaint = new Paint();
}
public void setProgressColors(int innerColor, int outerColor) {
innerPaint.setColor(innerColor);
outerPaint.setColor(outerColor);
}
public void setProgress(float progress) {
thumbX = (int)Math.ceil(width * progress);
if (thumbX < 0) {
thumbX = 0;
} else if (thumbX > width) {
thumbX = width;
currentProgress = progress;
if (currentProgress < 0) {
currentProgress = 0;
} else if (currentProgress > 1) {
currentProgress = 1;
}
}
public void draw(Canvas canvas) {
Paint inner = null;
Paint outer = null;
if (type == 0) {
inner = innerPaint1;
outer = outerPaint1;
} else if (type == 1) {
inner = innerPaint2;
outer = outerPaint2;
}
canvas.drawRect(0, height / 2 - Utilities.dp(1), width, height / 2 + Utilities.dp(1), inner);
canvas.drawRect(0, height / 2 - Utilities.dp(1), thumbX, height / 2 + Utilities.dp(1), outer);
canvas.drawRect(0, height / 2 - progressHeight / 2.0f, width, height / 2 + progressHeight / 2.0f, innerPaint);
canvas.drawRect(0, height / 2 - progressHeight / 2.0f, width * currentProgress, height / 2 + progressHeight / 2.0f, outerPaint);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="1dp"
android:paddingTop="1dp"
android:layout_gravity="top">
<org.telegram.ui.Views.BackupImageView
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginLeft="6dp"
android:id="@+id/chat_group_avatar_image"
android:scaleType="fitCenter"
android:layout_marginBottom="2dp"
android:layout_gravity="bottom"/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_gravity="top"
android:id="@+id/chat_bubble_layout"
android:addStatesFromChildren="true">
<org.telegram.ui.Views.BackupImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="6dp"
android:layout_gravity="top"
android:scaleType="centerCrop"
android:minHeight="100dp"
android:minWidth="100dp"
android:id="@+id/chat_photo_image"/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height="44dp"
android:layout_width="44dp"
android:id="@+id/chat_view_action_layout"
android:layout_gravity="center"
android:visibility="visible">
<ImageView
android:layout_width="44dp"
android:layout_height="44dp"
android:scaleType="centerInside"
android:id="@+id/chat_view_action_cancel_button"
android:src="@drawable/photo_download_states"
android:layout_gravity="center"
android:clickable="true"/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="16dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="right|bottom"
android:gravity="right">
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width="0dp"
android:layout_height="16dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="1dp"
android:layout_marginRight="4dp"
android:background="@drawable/phototime"
android:id="@+id/photo_progress"
android:layout_weight="1">
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_gravity="right|center_vertical"
android:progressDrawable="@drawable/photo_progress_chat"
style="?android:attr/progressBarStyleHorizontal"
android:progress="50"
android:id="@+id/chat_view_action_progress"
android:max="100"/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="16dp"
android:id="@+id/chat_time_layout"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:background="@drawable/phototime">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#ffffff"
android:textSize="12dp"
android:layout_gravity="bottom"
android:layout_marginBottom="1dp"
android:id="@+id/chat_time_text"/>
</LinearLayout>
</LinearLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="1dp"
android:paddingTop="1dp"
android:layout_gravity="top">
<org.telegram.ui.Views.FrameLayoutFixed android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:id="@+id/chat_bubble_layout"
android:layout_gravity="top"
android:addStatesFromChildren="true">
<org.telegram.ui.Views.BackupImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="6dp"
android:layout_gravity="top"
android:scaleType="centerCrop"
android:minHeight="100dp"
android:minWidth="100dp"
android:id="@+id/chat_photo_image"/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height="44dp"
android:layout_width="44dp"
android:id="@+id/chat_view_action_layout"
android:layout_gravity="center"
android:visibility="visible">
<ImageView
android:layout_width="44dp"
android:layout_height="44dp"
android:scaleType="centerInside"
android:id="@+id/chat_view_action_cancel_button"
android:src="@drawable/photo_download_states"
android:layout_gravity="center"
android:clickable="true"/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="16dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="right|bottom"
android:gravity="right">
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width="0dp"
android:layout_height="16dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="1dp"
android:layout_marginRight="4dp"
android:background="@drawable/phototime"
android:id="@+id/photo_progress"
android:layout_weight="1">
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_gravity="right|center_vertical"
android:progressDrawable="@drawable/photo_progress_chat"
style="?android:attr/progressBarStyleHorizontal"
android:progress="50"
android:id="@+id/chat_view_action_progress"
android:max="100"/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="16dp"
android:id="@+id/chat_time_layout"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:background="@drawable/phototime">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#ffffff"
android:textSize="12dp"
android:layout_gravity="bottom"
android:layout_marginBottom="1dp"
android:id="@+id/chat_time_text"/>
</LinearLayout>
</LinearLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingBottom="1dp"
android:paddingTop="1dp">
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:id="@+id/chat_bubble_layout"
android:addStatesFromChildren="true">
<org.telegram.ui.Views.BackupImageView
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_margin="6dp"
android:layout_gravity="top|left"
android:scaleType="centerCrop"
android:minHeight="100dp"
android:minWidth="100dp"
android:id="@+id/chat_photo_image"/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height="44dp"
android:layout_width="44dp"
android:id="@+id/chat_view_action_layout"
android:layout_gravity="center"
android:visibility="visible">
<ImageView
android:layout_width="44dp"
android:layout_height="44dp"
android:scaleType="centerInside"
android:id="@+id/chat_view_action_cancel_button"
android:src="@drawable/photo_download_cancel_states"
android:layout_gravity="center"
android:clickable="true"/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="16dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="right|bottom"
android:gravity="right">
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width="0dp"
android:layout_height="16dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="1dp"
android:layout_marginRight="4dp"
android:background="@drawable/phototime"
android:id="@+id/photo_progress"
android:layout_weight="1">
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_gravity="right|center_vertical"
android:progressDrawable="@drawable/photo_progress_chat"
style="?android:attr/progressBarStyleHorizontal"
android:progress="50"
android:id="@+id/chat_view_action_progress"
android:max="100"/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="16dp"
android:id="@+id/chat_time_layout"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:background="@drawable/phototime">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#ffffff"
android:textSize="12dp"
android:layout_gravity="bottom"
android:layout_marginBottom="1dp"
android:id="@+id/chat_time_text"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/msg_check_w"
android:layout_marginTop="2dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="-8dp"
android:id="@+id/chat_row_check"
android:visibility="visible"
android:layout_gravity="top"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:id="@+id/chat_row_halfcheck"
android:visibility="visible"
android:src="@drawable/msg_halfcheck_w"
android:layout_gravity="top"/>
</LinearLayout>
</LinearLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
</LinearLayout>
\ No newline at end of file
......@@ -5,8 +5,9 @@
<resources>
<string name="AppName">Telegram</string>
<string name="LanguangeName">العربية</string>
<string name="LanguangeNameInEnglish">Arabic</string>
<string name="LanguageName">العربية</string>
<string name="LanguageNameInEnglish">Arabic</string>
<string name="LanguageCode">ar</string>
<!--signin view-->
<string name="YourPhone">رقم هاتفك المحمول</string>
......@@ -110,7 +111,7 @@
<string name="DeleteThisGroup">حذف المجموعة</string>
<string name="SlideToCancel">قم بالسحب للإلغاء</string>
<string name="SaveToDownloads">حفظ في الجهاز</string>
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="ApplyLocalizationFile">تطبيق ملف التعريب</string>
<!--notification-->
<string name="EncryptedChatRequested">تم طلب محادثة سرية</string>
......
......@@ -5,8 +5,9 @@
<resources>
<string name="AppName">Telegram</string>
<string name="LanguangeName">Deutsch</string>
<string name="LanguangeNameInEnglish">German</string>
<string name="LanguageName">Deutsch</string>
<string name="LanguageNameInEnglish">German</string>
<string name="LanguageCode">de</string>
<!--signin view-->
<string name="YourPhone">Dein Telefon</string>
......@@ -110,7 +111,7 @@
<string name="DeleteThisGroup">Diese Gruppe löschen</string>
<string name="SlideToCancel">WISCHEN UM ABZUBRECHEN</string>
<string name="SaveToDownloads">In Ordner Downloads speichern</string>
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="ApplyLocalizationFile">Sprachdatei benutzen</string>
<!--notification-->
<string name="EncryptedChatRequested">Geheimen Chat angefordert</string>
......
......@@ -5,8 +5,9 @@
<resources>
<string name="AppName">Telegram</string>
<string name="LanguangeName">Español</string>
<string name="LanguangeNameInEnglish">Spanish</string>
<string name="LanguageName">Español</string>
<string name="LanguageNameInEnglish">Spanish</string>
<string name="LanguageCode">es</string>
<!--signin view-->
<string name="YourPhone">Tu teléfono</string>
......@@ -110,7 +111,7 @@
<string name="DeleteThisGroup">Eliminar este grupo</string>
<string name="SlideToCancel">DESLIZA PARA CANCELAR</string>
<string name="SaveToDownloads">Guardar en descargas</string>
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="ApplyLocalizationFile">Aplicar fichero de localización</string>
<!--notification-->
<string name="EncryptedChatRequested">Chat secreto solicitado</string>
......
......@@ -5,8 +5,9 @@
<resources>
<string name="AppName">Telegram</string>
<string name="LanguangeName">Italiano</string>
<string name="LanguangeNameInEnglish">Italian</string>
<string name="LanguageName">Italiano</string>
<string name="LanguageNameInEnglish">Italian</string>
<string name="LanguageCode">it</string>
<!--signin view-->
<string name="YourPhone">Il tuo telefono</string>
......@@ -110,7 +111,7 @@
<string name="DeleteThisGroup">Elimina questo gruppo</string>
<string name="SlideToCancel">TRASCINA PER ANNULLARE</string>
<string name="SaveToDownloads">Salva in download</string>
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="ApplyLocalizationFile">Applica file di localizzazione</string>
<!--notification-->
<string name="EncryptedChatRequested">Chat segreta richiesta</string>
......
......@@ -5,8 +5,9 @@
<resources>
<string name="AppName">Telegram</string>
<string name="LanguangeName">Nederlands</string>
<string name="LanguangeNameInEnglish">Dutch</string>
<string name="LanguageName">Nederlands</string>
<string name="LanguageNameInEnglish">Dutch</string>
<string name="LanguageCode">nl</string>
<!--signin view-->
<string name="YourPhone">Uw telefoon</string>
......@@ -110,7 +111,7 @@
<string name="DeleteThisGroup">Deze groep verwijderen</string>
<string name="SlideToCancel">SLEEP OM TE ANNULEREN</string>
<string name="SaveToDownloads">Opslaan in downloads</string>
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="ApplyLocalizationFile">Vertaling toepassen</string>
<!--notification-->
<string name="EncryptedChatRequested">Privégesprek aangevraagd</string>
......
......@@ -5,8 +5,9 @@
<resources>
<string name="AppName">Telegram</string>
<string name="LanguangeName">English</string>
<string name="LanguangeNameInEnglish">English</string>
<string name="LanguageName">English</string>
<string name="LanguageNameInEnglish">English</string>
<string name="LanguageCode">en</string>
<!--signin view-->
<string name="YourPhone">Your phone</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment