Commit 01103c6e authored by DrKLO's avatar DrKLO

Update to 1.3.30

parent 8ecb9e97
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.telegram.messenger"
android:versionCode="185"
android:versionName="1.3.26">
android:versionCode="194"
android:versionName="1.3.30">
<supports-screens android:anyDensity="true"
android:smallScreens="true"
......@@ -25,7 +25,7 @@
<uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!--<uses-permission android:name="android.permission.RECORD_AUDIO" />-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
......@@ -50,7 +50,6 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER" />
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<permission android:name="org.telegram.messenger.permission.C2D_MESSAGE" android:protectionLevel="signature" />
......@@ -65,9 +64,9 @@
android:largeHeap="true">
<!--release-->
<!--<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k" />-->
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k" />
<!--debug-->
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCTNmNqbWovP9ETcAob98YlrfOQEAC0CJ4" />
<!--<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCTNmNqbWovP9ETcAob98YlrfOQEAC0CJ4" />-->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity
......
......@@ -17,15 +17,34 @@ import android.os.PowerManager;
public class GcmBroadcastReceiver extends BroadcastReceiver {
public static final int NOTIFICATION_ID = 1;
private static PowerManager.WakeLock wakeLock = null;
private static final Integer sync = 1;
@Override
public void onReceive(final Context context, final Intent intent) {
FileLog.d("tmessages", "GCM received intent: " + intent);
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
final PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
wl.acquire();
synchronized (sync) {
try {
if (wakeLock == null) {
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
}
if (!wakeLock.isHeld()) {
wakeLock.acquire(5000);
}
} catch (Exception e) {
try {
if (wakeLock != null) {
wakeLock.release();
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
}
FileLog.e("tmessages", e);
}
}
// SharedPreferences preferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
// boolean globalEnabled = preferences.getBoolean("EnableAll", true);
......@@ -34,14 +53,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
// return;
// }
Thread thread = new Thread(new Runnable() {
public void run() {
ConnectionsManager.Instance.resumeNetworkMaybe();
wl.release();
}
});
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
ConnectionsManager.Instance.resumeNetworkMaybe();
} else if (intent.getAction().equals("com.google.android.c2dm.intent.REGISTRATION")) {
String registration = intent.getStringExtra("registration_id");
if (intent.getStringExtra("error") != null) {
......
......@@ -65,37 +65,39 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
NotificationCenter.Instance.addObserver(this, FileLoader.FileDidLoaded);
NotificationCenter.Instance.addObserver(this, FileLoader.FileLoadProgressChanged);
Timer progressTimer = new Timer();
progressTimer.schedule(new TimerTask() {
@Override
public void run() {
synchronized (sync) {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (playingMessageObject != null && audioPlayer != null && !isPaused) {
try {
int progress = audioPlayer.getCurrentPosition();
if (progress <= lastProgress) {
return;
if (ConnectionsManager.enableAudio) {
Timer progressTimer = new Timer();
progressTimer.schedule(new TimerTask() {
@Override
public void run() {
synchronized (sync) {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (playingMessageObject != null && audioPlayer != null && !isPaused) {
try {
int progress = audioPlayer.getCurrentPosition();
if (progress <= lastProgress) {
return;
}
lastProgress = progress;
final float value = (float)lastProgress / (float)audioPlayer.getDuration();
playingMessageObject.audioProgress = value;
playingMessageObject.audioProgressSec = lastProgress / 1000;
NotificationCenter.Instance.postNotificationName(audioProgressDidChanged, playingMessageObject.messageOwner.id, value);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
lastProgress = progress;
final float value = (float)lastProgress / (float)audioPlayer.getDuration();
playingMessageObject.audioProgress = value;
playingMessageObject.audioProgressSec = lastProgress / 1000;
NotificationCenter.Instance.postNotificationName(audioProgressDidChanged, playingMessageObject.messageOwner.id, value);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (audioRecorder != null) {
NotificationCenter.Instance.postNotificationName(recordProgressChanged, System.currentTimeMillis() - recordStartTime);
}
}
if (audioRecorder != null) {
NotificationCenter.Instance.postNotificationName(recordProgressChanged, System.currentTimeMillis() - recordStartTime);
}
}
});
});
}
}
}
}, 100, 17);
}, 100, 17);
}
}
public void cleanup() {
......
......@@ -16,6 +16,7 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.util.Linkify;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
......@@ -26,6 +27,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import java.io.File;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -298,9 +300,17 @@ public class MessageObject {
}
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaAudio) {
if (message.from_id == UserConfig.clientUserId) {
type = 18;
if (ConnectionsManager.enableAudio) {
type = 18;
} else {
type = 0;
}
} else {
type = 19;
if (ConnectionsManager.enableAudio) {
type = 19;
} else {
type = 1;
}
}
}
} else if (message instanceof TLRPC.TL_messageService) {
......@@ -369,7 +379,7 @@ public class MessageObject {
}
private void generateLayout() {
if (type != 0 && type != 1 && type != 8 && type != 9 || messageOwner.to_id == null || messageText == null || messageText.length() == 0 || !(messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) && !(messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported) && !(messageOwner.media == null)) {
if (type != 0 && type != 1 && type != 8 && type != 9 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
return;
}
......@@ -392,7 +402,15 @@ public class MessageObject {
maxWidth = Math.min(Utilities.displaySize.x, Utilities.displaySize.y) - Utilities.dp(80);
}
StaticLayout textLayout = new StaticLayout(messageText, textPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
StaticLayout textLayout = null;
try {
textLayout = new StaticLayout(messageText, textPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
} catch (Exception e) {
FileLog.e("tmessages", e);
return;
}
textHeight = textLayout.getHeight();
int linesCount = textLayout.getLineCount();
......@@ -416,18 +434,35 @@ public class MessageObject {
continue;
}
block.charactersOffset = startCharacter;
CharSequence str = messageText.subSequence(startCharacter, endCharacter);
block.textLayout = new StaticLayout(str, textPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
block.textYOffset = textLayout.getLineTop(linesOffset);
if (a != blocksCount - 1) {
blockHeight = Math.min(blockHeight, block.textLayout.getHeight());
try {
CharSequence str = messageText.subSequence(startCharacter, endCharacter);
block.textLayout = new StaticLayout(str, textPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
block.textYOffset = textLayout.getLineTop(linesOffset);
if (a != blocksCount - 1) {
blockHeight = Math.min(blockHeight, block.textLayout.getHeight());
}
} catch (Exception e) {
FileLog.e("tmessages", e);
continue;
}
}
textLayoutBlocks.add(block);
float lastLeft = block.textXOffset = block.textLayout.getLineLeft(currentBlockLinesCount - 1);
float lastLine = block.textLayout.getLineWidth(currentBlockLinesCount - 1);
float lastLeft = block.textXOffset = 0;
try {
lastLeft = block.textXOffset = block.textLayout.getLineLeft(currentBlockLinesCount - 1);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
float lastLine = 0;
try {
lastLine = block.textLayout.getLineWidth(currentBlockLinesCount - 1);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
int linesMaxWidth;
int lastLineWidthWithLeft;
int linesMaxWidthWithLeft;
......@@ -449,13 +484,20 @@ public class MessageObject {
for (int n = 0; n < currentBlockLinesCount; ++n) {
try {
lineWidth = block.textLayout.getLineWidth(n);
} catch (Exception e) {
FileLog.e("tmessages", e);
lineWidth = 0;
}
try {
lineLeft = block.textLayout.getLineLeft(n);
block.textXOffset = Math.min(block.textXOffset, lineLeft);
} catch (Exception e) {
FileLog.e("tmessages", e);
return;
lineLeft = 0;
}
block.textXOffset = Math.min(block.textXOffset, lineLeft);
if (lineLeft == 0) {
hasNonRTL = true;
}
......
......@@ -67,30 +67,37 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
}
private void processSearch(final String query) {
Utilities.globalQueue.postRunnable(new Runnable() {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
String q = query.trim().toLowerCase();
if (q.length() == 0) {
updateSearchResults(new ArrayList<TLRPC.User>(), new ArrayList<CharSequence>());
return;
}
long time = System.currentTimeMillis();
ArrayList<TLRPC.User> resultArray = new ArrayList<TLRPC.User>();
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
for (TLRPC.TL_contact contact : ContactsController.Instance.contacts) {
TLRPC.User user = MessagesController.Instance.users.get(contact.user_id);
if (user.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.clientUserId) {
continue;
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
contactsCopy.addAll(ContactsController.Instance.contacts);
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
String q = query.trim().toLowerCase();
if (q.length() == 0) {
updateSearchResults(new ArrayList<TLRPC.User>(), new ArrayList<CharSequence>());
return;
}
long time = System.currentTimeMillis();
ArrayList<TLRPC.User> resultArray = new ArrayList<TLRPC.User>();
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.Instance.users.get(contact.user_id);
if (user.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.clientUserId) {
continue;
}
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
}
}
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
}
}
updateSearchResults(resultArray, resultArrayNames);
updateSearchResults(resultArray, resultArrayNames);
}
});
}
});
}
......
......@@ -13,6 +13,7 @@ import android.graphics.drawable.Drawable;
import android.view.View;
public class BaseCell extends View {
public BaseCell(Context context) {
super(context);
}
......
......@@ -14,6 +14,7 @@ import android.text.Spannable;
import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities;
import org.telegram.objects.MessageObject;
......@@ -34,7 +35,7 @@ public class ChatMessageCell extends ChatBaseCell {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (currentMessageObject != null && currentMessageObject.messageText instanceof Spannable && !isPressed) {
if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && !isPressed) {
if (event.getAction() == MotionEvent.ACTION_DOWN || pressedLink != null && event.getAction() == MotionEvent.ACTION_UP) {
int x = (int)event.getX();
int y = (int)event.getY();
......@@ -59,7 +60,11 @@ public class ChatMessageCell extends ChatBaseCell {
return true;
} else {
if (link[0] == pressedLink) {
pressedLink.onClick(this);
try {
pressedLink.onClick(this);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return true;
}
}
......@@ -83,6 +88,9 @@ public class ChatMessageCell extends ChatBaseCell {
}
public void setVisiblePart(int position, int height) {
if (currentMessageObject == null || currentMessageObject.textLayoutBlocks == null) {
return;
}
int newFirst = -1, newLast = -1, newCount = 0;
for (int a = Math.max(0, (position - textY) / currentMessageObject.blockHeight); a < currentMessageObject.textLayoutBlocks.size(); a++) {
......@@ -117,6 +125,10 @@ public class ChatMessageCell extends ChatBaseCell {
@Override
public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject != messageObject || isUserDataChanged()) {
if (currentMessageObject != messageObject) {
firstVisibleBlockNum = 0;
lastVisibleBlockNum = 0;
}
pressedLink = null;
int maxWidth;
if (chat) {
......@@ -160,6 +172,19 @@ public class ChatMessageCell extends ChatBaseCell {
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), totalHeight);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (currentMessageObject.messageOwner.out) {
textX = layoutWidth - backgroundWidth + Utilities.dp(10);
textY = Utilities.dp(10) + namesOffset;
} else {
textX = Utilities.dp(19) + (chat ? Utilities.dp(52) : 0);
textY = Utilities.dp(10) + namesOffset;
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
......@@ -176,10 +201,17 @@ public class ChatMessageCell extends ChatBaseCell {
}
for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) {
if (a >= currentMessageObject.textLayoutBlocks.size()) {
break;
}
MessageObject.TextLayoutBlock block = currentMessageObject.textLayoutBlocks.get(a);
canvas.save();
canvas.translate(textX - (int)Math.ceil(block.textXOffset), textY + block.textYOffset);
block.textLayout.draw(canvas);
try {
block.textLayout.draw(canvas);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
canvas.restore();
}
}
......
......@@ -68,6 +68,7 @@ import android.widget.TextView;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.FileLog;
......@@ -91,6 +92,7 @@ import org.telegram.ui.Views.LayoutListView;
import org.telegram.ui.Views.MessageActionLayout;
import org.telegram.ui.Views.OnSwipeTouchListener;
import org.telegram.ui.Views.SizeNotifierRelativeLayout;
import org.telegram.ui.Views.TimerButton;
import java.io.File;
import java.util.ArrayList;
......@@ -128,6 +130,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private MessageObject selectedObject;
private MessageObject forwaringMessage;
private TextView secretViewStatusTextView;
private TimerButton timerButton;
private Point displaySize = new Point();
private boolean paused = true;
private boolean readWhenResume = false;
......@@ -777,14 +780,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
private void checkSendButton() {
// sendButton.setVisibility(View.VISIBLE);
// audioSendButton.setVisibility(View.INVISIBLE);
if (messsageEditText.length() > 0) {
if (ConnectionsManager.enableAudio) {
if (messsageEditText.length() > 0) {
sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE);
} else {
sendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.VISIBLE);
}
} else {
sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE);
} else {
sendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.VISIBLE);
}
}
......@@ -1172,6 +1178,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
parentActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
if (manager == null || manager.getDefaultDisplay() == null) {
return;
}
int rotation = manager.getDefaultDisplay().getRotation();
if (height > Emoji.scale(50)) {
......@@ -1638,6 +1647,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
boolean currentMarkAsRead = false;
for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageActionTTLChange && timerButton != null) {
timerButton.setTime(obj.messageOwner.action.ttl);
}
if (messagesDict.containsKey(obj.messageOwner.id)) {
continue;
}
......@@ -1673,6 +1685,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
boolean markAsRead = false;
int oldCount = messages.size();
for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageActionTTLChange && timerButton != null) {
timerButton.setTime(obj.messageOwner.action.ttl);
}
if (messagesDict.containsKey(obj.messageOwner.id)) {
continue;
}
......@@ -2356,10 +2371,69 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.chat_menu, menu);
if (currentEncryptedChat != null) {
inflater.inflate(R.menu.chat_enc_menu, menu);
} else {
inflater.inflate(R.menu.chat_menu, menu);
}
SupportMenuItem timeItem = (SupportMenuItem)menu.findItem(R.id.chat_enc_timer);
if (currentEncryptedChat != null && !(currentEncryptedChat instanceof TLRPC.TL_encryptedChat) || currentChat != null && (currentChat instanceof TLRPC.TL_chatForbidden || currentChat.left)) {
SupportMenuItem item = (SupportMenuItem)menu.findItem(R.id.chat_menu_attach);
item.setVisible(false);
if (item != null) {
item.setVisible(false);
}
if (timeItem != null) {
timeItem.setVisible(false);
}
}
if (timeItem != null && timeItem.getActionView() != null) {
timerButton = (TimerButton)timeItem.getActionView().findViewById(R.id.chat_timer);
timerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(getStringEntry(R.string.MessageLifetime));
builder.setItems(new CharSequence[]{
getStringEntry(R.string.ShortMessageLifetimeForever),
getStringEntry(R.string.ShortMessageLifetime2s),
getStringEntry(R.string.ShortMessageLifetime5s),
getStringEntry(R.string.ShortMessageLifetime1m),
getStringEntry(R.string.ShortMessageLifetime1h),
getStringEntry(R.string.ShortMessageLifetime1d),
getStringEntry(R.string.ShortMessageLifetime1w)
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int oldValue = currentEncryptedChat.ttl;
if (which == 0) {
currentEncryptedChat.ttl = 0;
} else if (which == 1) {
currentEncryptedChat.ttl = 2;
} else if (which == 2) {
currentEncryptedChat.ttl = 5;
} else if (which == 3) {
currentEncryptedChat.ttl = 60;
} else if (which == 4) {
currentEncryptedChat.ttl = 60 * 60;
} else if (which == 5) {
currentEncryptedChat.ttl = 60 * 60 * 24;
} else if (which == 6) {
currentEncryptedChat.ttl = 60 * 60 * 24 * 7;
}
if (oldValue != currentEncryptedChat.ttl) {
MessagesController.Instance.sendTTLMessage(currentEncryptedChat);
MessagesStorage.Instance.updateEncryptedChat(currentEncryptedChat);
}
}
});
builder.setNegativeButton(getStringEntry(R.string.Cancel), null);
builder.show().setCanceledOnTouchOutside(true);
}
});
timerButton.setTime(currentEncryptedChat.ttl);
}
SupportMenuItem avatarItem = (SupportMenuItem)menu.findItem(R.id.chat_menu_avatar);
......
......@@ -691,6 +691,9 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
break;
case R.id.gallery_menu_save:
TLRPC.FileLocation file = getCurrentFile();
if (file == null) {
return;
}
File f = new File(Utilities.getCacheDir(), file.volume_id + "_" + file.local_id + ".jpg");
File dstFile = Utilities.generatePicturePath();
try {
......@@ -710,7 +713,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (fromAll) {
finish();
} else {
if (!localPagerAdapter.imagesArr.isEmpty() && currentDialog != 0) {
if (localPagerAdapter != null && localPagerAdapter.imagesArr != null && !localPagerAdapter.imagesArr.isEmpty() && currentDialog != 0) {
finish();
NotificationCenter.Instance.postNotificationName(needShowAllMedia, currentDialog);
}
......
......@@ -361,30 +361,37 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
private void processSearch(final String query) {
Utilities.globalQueue.postRunnable(new Runnable() {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (query.length() == 0) {
updateSearchResults(new ArrayList<TLRPC.User>(), new ArrayList<CharSequence>());
return;
}
long time = System.currentTimeMillis();
ArrayList<TLRPC.User> resultArray = new ArrayList<TLRPC.User>();
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
String q = query.toLowerCase();
for (TLRPC.TL_contact contact : ContactsController.Instance.contacts) {
TLRPC.User user = MessagesController.Instance.users.get(contact.user_id);
if (user.first_name.toLowerCase().startsWith(q) || user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.clientUserId) {
continue;
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
contactsCopy.addAll(ContactsController.Instance.contacts);
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (query.length() == 0) {
updateSearchResults(new ArrayList<TLRPC.User>(), new ArrayList<CharSequence>());
return;
}
long time = System.currentTimeMillis();
ArrayList<TLRPC.User> resultArray = new ArrayList<TLRPC.User>();
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
String q = query.toLowerCase();
for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.Instance.users.get(contact.user_id);
if (user.first_name.toLowerCase().startsWith(q) || user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.clientUserId) {
continue;
}
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
}
}
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
}
}
updateSearchResults(resultArray, resultArrayNames);
updateSearchResults(resultArray, resultArrayNames);
}
});
}
});
}
......
......@@ -132,7 +132,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
ApplicationLoader.fragmentsStack.add(fragment);
}
handleIntent(getIntent(), false);
handleIntent(getIntent(), false, savedInstanceState != null);
}
@SuppressWarnings("unchecked")
......@@ -164,7 +164,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
getSupportActionBar().hide();
}
private void handleIntent(Intent intent, boolean isNew) {
private void handleIntent(Intent intent, boolean isNew, boolean restore) {
boolean pushOpened = false;
Integer push_user_id = 0;
......@@ -179,7 +179,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
imagesPathArray = null;
documentsPathArray = null;
if (intent != null && intent.getAction() != null) {
if (intent != null && intent.getAction() != null && !restore) {
if (Intent.ACTION_SEND.equals(intent.getAction())) {
boolean error = false;
String type = intent.getType();
......@@ -282,7 +282,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
}
}
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0 && !restore) {
int chatId = getIntent().getIntExtra("chatId", 0);
int userId = getIntent().getIntExtra("userId", 0);
int encId = getIntent().getIntExtra("encId", 0);
......@@ -373,7 +373,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(intent, true);
handleIntent(intent, true, false);
}
@Override
......@@ -750,8 +750,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
fTrans.setCustomAnimations(R.anim.scale_in, R.anim.no_anim);
}
}
fTrans.replace(R.id.container, fragment, tag);
fTrans.commitAllowingStateLoss();
try {
fTrans.replace(R.id.container, fragment, tag);
fTrans.commitAllowingStateLoss();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ApplicationLoader.fragmentsStack.add(fragment);
}
......
......@@ -141,6 +141,9 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
@Override
public void needShowAlert(String text) {
if (text == null) {
return;
}
ShowAlertDialog(LoginActivity.this, text);
}
......
......@@ -264,6 +264,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
ignoreOnTextChange = true;
codeField.setText(countriesMap.get(name));
countryButton.setText(name);
countryState = 0;
}
}
......
......@@ -270,6 +270,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (parentActivity == null) {
return;
}
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("support_id", res.user.id);
SerializedData data = new SerializedData();
......
/*
* This is the source code of Telegram for Android v. 1.3.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
public class TimerButton extends View {
private static Drawable emptyTimerDrawable;
private static Drawable timerDrawable;
private static TextPaint timePaint;
private StaticLayout timeLayout;
private float timeWidth = 0;
private int timeHeight = 0;
private int time = 0;
private void init() {
if (emptyTimerDrawable == null) {
emptyTimerDrawable = getResources().getDrawable(R.drawable.header_timer);
timerDrawable = getResources().getDrawable(R.drawable.header_timer2);
timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
timePaint.setTextSize(Utilities.dp(10));
timePaint.setColor(0xffd7e8f7);
timePaint.setTypeface(Typeface.DEFAULT_BOLD);
}
setBackgroundResource(R.drawable.bar_selector);
}
public TimerButton(Context context) {
super(context);
init();
}
public TimerButton(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TimerButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public void setTime(int value) {
time = value;
String timeString = null;
if (time == 2) {
timeString = getResources().getString(R.string.ShortMessageLifetime2s);
} else if (time == 5) {
timeString = getResources().getString(R.string.ShortMessageLifetime5s);
} else if (time == 60) {
timeString = getResources().getString(R.string.ShortMessageLifetime1m);
} else if (time == 60 * 60) {
timeString = getResources().getString(R.string.ShortMessageLifetime1h);
} else if (time == 60 * 60 * 24) {
timeString = getResources().getString(R.string.ShortMessageLifetime1d);
} else if (time == 60 * 60 * 24 * 7) {
timeString = getResources().getString(R.string.ShortMessageLifetime1w);
} else {
timeString = "c";
}
timeWidth = timePaint.measureText(timeString);
try {
timeLayout = new StaticLayout(timeString, timePaint, (int)Math.ceil(timeWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
timeHeight = timeLayout.getHeight();
} catch (Exception e) {
timeLayout = null;
FileLog.e("tmessages", e);
}
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
int width = getMeasuredWidth();
int height = getMeasuredHeight();
Drawable drawable = null;
if (time == 0) {
drawable = timerDrawable;
} else {
drawable = emptyTimerDrawable;
}
int x = (width - drawable.getIntrinsicWidth()) / 2;
int y = (height - drawable.getIntrinsicHeight()) / 2;
drawable.setBounds(x, y, x + drawable.getIntrinsicWidth(), y + drawable.getIntrinsicHeight());
drawable.draw(canvas);
if (time != 0 && timeLayout != null) {
canvas.translate((width - timeWidth) / 2, (height - timeHeight) / 2 + Utilities.dp(1));
timeLayout.draw(canvas);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<org.telegram.ui.Views.TimerButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="48dp"
android:id="@+id/chat_timer"/>
</RelativeLayout>
\ No newline at end of file
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sabd="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/chat_enc_timer"
sabd:showAsAction="always"
sabd:actionLayout="@layout/chat_header_enc_layout"/>
<item
android:id="@+id/chat_menu_attach"
android:icon="@drawable/ic_ab_attach"
android:title="@string/Attach"
sabd:showAsAction="always">
<menu>
<item
android:icon="@drawable/ic_attach_photo"
android:title="@string/ChatTakePhoto"
android:id="@+id/attach_photo"/>
<item
android:icon="@drawable/ic_attach_gallery"
android:title="@string/ChatGallery"
android:id="@+id/attach_gallery"/>
<item
android:icon="@drawable/ic_attach_video"
android:title="@string/ChatVideo"
android:id="@+id/attach_video"/>
<item
android:icon="@drawable/ic_ab_doc"
android:title="@string/ChatDocument"
android:id="@+id/attach_document"/>
<item
android:icon="@drawable/ic_attach_location"
android:title="@string/ChatLocation"
android:id="@+id/attach_location"/>
</menu>
</item>
<item
android:id="@+id/chat_menu_avatar"
sabd:showAsAction="always"
sabd:actionLayout="@layout/chat_header_layout"/>
</menu>
\ No newline at end of file
......@@ -240,7 +240,7 @@
<string name="Support">SUPPORT</string>
<string name="ChatBackground">Chat-Hintergrundbild</string>
<string name="MessagesSettings">NACHRICHTEN</string>
<string name="SendByEnter">Mit <![CDATA[<b>Enter</b>]]> senden</string>
<string name="SendByEnter">Mit Enter senden</string>
<string name="TerminateAllSessions">Alle anderen Sitzungen beenden</string>
<string name="AutomaticPhotoDownload">AUTOMATISCHER BILDERDOWNLOAD</string>
<string name="AutomaticPhotoDownloadGroups">Gruppen</string>
......
This diff is collapsed.
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