Commit dd61bbaa authored by DrKLO's avatar DrKLO

Bug fixes

parent ba4cf583
......@@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 388
versionName "2.0.1"
versionCode 391
versionName "2.0.2"
}
}
......@@ -1616,6 +1616,7 @@ public class ContactsController {
public void reloadContactsStatuses() {
saveContactsLoadTime();
MessagesController.getInstance().clearFullUsers();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
final SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("needGetStatuses", true).commit();
......
......@@ -68,6 +68,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
private boolean startingSecretChat = false;
private ArrayList<Integer> loadingFullUsers = new ArrayList<Integer>();
private ArrayList<Integer> loadedFullUsers = new ArrayList<Integer>();
private ArrayList<Integer> loadingFullChats = new ArrayList<Integer>();
private ArrayList<Integer> loadedFullChats = new ArrayList<Integer>();
private HashMap<Integer, ArrayList<TLRPC.TL_decryptedMessageHolder>> secretHolesQueue = new HashMap<Integer, ArrayList<TLRPC.TL_decryptedMessageHolder>>();
......@@ -323,6 +325,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
sendingTypings.clear();
loadingFullUsers.clear();
loadedFullUsers.clear();
loadingFullUsers.clear();
loadedFullUsers.clear();
secretHolesQueue.clear();
updatesStartWaitTime = 0;
......@@ -470,6 +474,55 @@ public class MessagesController implements NotificationCenter.NotificationCenter
loadingFullUsers.remove((Integer) uid);
}
public void cancelLoadFullChat(int cid) {
loadingFullChats.remove((Integer) cid);
}
protected void clearFullUsers() {
loadedFullUsers.clear();
loadedFullChats.clear();
}
public void loadFullChat(final int chat_id, final int classGuid) {
if (loadingFullChats.contains(chat_id) || loadedFullChats.contains(chat_id)) {
return;
}
loadingFullChats.add(chat_id);
TLRPC.TL_messages_getFullChat req = new TLRPC.TL_messages_getFullChat();
req.chat_id = chat_id;
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
final TLRPC.TL_messages_chatFull res = (TLRPC.TL_messages_chatFull) response;
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
MessagesStorage.getInstance().updateChatInfo(chat_id, res.full_chat.participants, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
loadingFullChats.remove((Integer)chat_id);
loadedFullChats.add(chat_id);
putUsers(res.users, false);
putChats(res.chats, false);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, chat_id, res.full_chat.participants);
}
});
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
loadingFullChats.remove((Integer) chat_id);
}
});
}
}
});
if (classGuid != 0) {
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
}
}
public void loadFullUser(final TLRPC.User user, final int classGuid) {
if (user == null || loadingFullUsers.contains(user.id) || loadedFullUsers.contains(user.id)) {
return;
......@@ -1089,29 +1142,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public void processChatInfo(final int chat_id, final TLRPC.ChatParticipants info, final ArrayList<TLRPC.User> usersArr, final boolean fromCache) {
if (info == null && fromCache) {
TLRPC.TL_messages_getFullChat req = new TLRPC.TL_messages_getFullChat();
req.chat_id = chat_id;
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error != null) {
return;
if (fromCache && chat_id > 0) {
loadFullChat(chat_id, 0);
}
final TLRPC.TL_messages_chatFull res = (TLRPC.TL_messages_chatFull) response;
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
MessagesStorage.getInstance().updateChatInfo(chat_id, res.full_chat.participants, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
putUsers(res.users, false);
putChats(res.chats, false);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, chat_id, res.full_chat.participants);
}
});
}
});
} else {
if (info != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
......
......@@ -18,6 +18,7 @@ import org.telegram.messenger.Utilities;
import java.util.ArrayList;
public class PhotoObject {
public TLRPC.PhotoSize photoOwner;
public Bitmap image;
......
......@@ -68,7 +68,7 @@ public class ActionBarLayout extends FrameLayout {
if (view == child) {
continue;
}
if (view instanceof ActionBar) {
if (view instanceof ActionBar && view.getVisibility() == VISIBLE) {
actionBarHeight = view.getMeasuredHeight();
wasActionBar = true;
break;
......
......@@ -67,6 +67,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private int photoWidth;
private int photoHeight;
private PhotoObject currentPhotoObject;
private PhotoObject currentPhotoObjectThumb;
private String currentUrl;
private String currentPhotoFilter;
private ImageReceiver photoImage;
......@@ -174,6 +175,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (photoImage != null) {
photoImage.clearImage();
currentPhotoObject = null;
currentPhotoObjectThumb = null;
}
currentUrl = null;
if (gifDrawable != null) {
......@@ -413,6 +415,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
buttonState = -1;
gifDrawable = null;
currentPhotoObject = null;
currentPhotoObjectThumb = null;
currentUrl = null;
photoNotSet = false;
......@@ -527,6 +530,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
}
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
if (messageObject.type == 1) {
currentPhotoObjectThumb = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, 80);
}
if (currentPhotoObject != null) {
boolean noSize = false;
if (currentMessageObject.type == 3 || currentMessageObject.type == 8) {
......@@ -609,7 +615,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
}
} else {
photoNotSet = true;
if (messageObject.imagePreview != null) {
photoImage.setImageBitmap(messageObject.imagePreview);
} else if (currentPhotoObjectThumb != null) {
photoImage.setImage(currentPhotoObjectThumb.photoOwner.location, currentPhotoFilter, null, 0, true);
}
}
}
} else {
......
......@@ -11,6 +11,7 @@ package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Build;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.TextView;
......@@ -74,6 +75,10 @@ public class TextCheckCell extends FrameLayoutFixed {
public void setTextAndCheck(String text, boolean checked, boolean divider) {
textView.setText(text);
if (Build.VERSION.SDK_INT < 11) {
checkBox.resetLayout();
checkBox.requestLayout();
}
checkBox.setChecked(checked);
needDivider = divider;
setWillNotDraw(!divider);
......
......@@ -48,7 +48,7 @@ public class TextSettingsCell extends FrameLayout {
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(textView);
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = LayoutParams.MATCH_PARENT;
layoutParams.leftMargin = AndroidUtilities.dp(17);
layoutParams.rightMargin = AndroidUtilities.dp(17);
......@@ -100,7 +100,7 @@ public class TextSettingsCell extends FrameLayout {
} else {
width = availableWidth;
}
textView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
textView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
}
public void setTextColor(int color) {
......@@ -110,6 +110,7 @@ public class TextSettingsCell extends FrameLayout {
public void setText(String text, boolean divider) {
textView.setText(text);
valueTextView.setVisibility(GONE);
valueImageView.setVisibility(GONE);
needDivider = divider;
setWillNotDraw(!divider);
}
......
......@@ -12,6 +12,7 @@ import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
......@@ -69,6 +70,13 @@ public class IdenticonActivity extends BaseFragment {
TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
textView.setText(Html.fromHtml(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
}
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
......
......@@ -654,7 +654,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
drawerLayoutContainer.setAllowOpenDrawer(false);
if (AndroidUtilities.isTablet()) {
layersActionBarLayout.showLastFragment();
actionBarLayout.showLastFragment();
rightActionBarLayout.showLastFragment();
}
pushOpened = true;
......
......@@ -1272,12 +1272,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (!init) {
currentThumb = null;
}
placeProvider.willSwitchFromPhoto(currentMessageObject, currentFileLocation, currentIndex);
int prevIndex = currentIndex;
currentIndex = index;
currentFileNames[0] = getFileName(index);
currentFileNames[1] = getFileName(index + 1);
currentFileNames[2] = getFileName(index - 1);
placeProvider.willSwitchFromPhoto(currentMessageObject, currentFileLocation, currentIndex);
int prevIndex = currentIndex;
currentIndex = index;
boolean sameImage = false;
if (!imagesArr.isEmpty()) {
......@@ -1975,25 +1976,23 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (animationStartTime == 0) {
AndroidUtilities.unlockOrientation(parentActivity);
}
//return false;
return false;
}
if(ev.getPointerCount() == 1 && gestureDetector.onTouchEvent(ev) && doubleTap) {
doubleTap = false;
moving = false;
zooming = false;
if (animationInProgress == 0 && animationStartTime == 0) {
checkMinMax(false);
return true;
}
}
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN || ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
if (!scroller.isFinished()) {
scroller.abortAnimation();
}
if (!draggingDown) {
if (canZoom && ev.getPointerCount() == 2 && !changingPage) {
if (!draggingDown && !changingPage) {
if (canZoom && ev.getPointerCount() == 2) {
pinchStartDistance = (float) Math.hypot(ev.getX(1) - ev.getX(0), ev.getY(1) - ev.getY(0));
pinchStartScale = scale;
pinchCenterX = (ev.getX(0) + ev.getX(1)) / 2.0f;
......@@ -2040,7 +2039,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else if (draggingDown) {
translationY = ev.getY() - dragY;
containerView.invalidate();
} else if (!invalidCoords/* && animationStartTime == 0*/) {
} else if (!invalidCoords && animationStartTime == 0) {
float moveDx = moveStartX - ev.getX();
float moveDy = moveStartY - ev.getY();
if (moving || scale == 1 && Math.abs(moveDy) + AndroidUtilities.dp(12) < Math.abs(moveDx) || scale != 1) {
......
......@@ -763,7 +763,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if (user_id != 0) {
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateProfileData();
}
} else if (chat_id != 0) {
......@@ -1042,8 +1042,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
photo = user.photo.photo_small;
photoBig = user.photo.photo_big;
}
AvatarDrawable avatarDrawable = new AvatarDrawable(user, true);
avatarDrawable.setColor(0xff5c98cd);
AvatarDrawable avatarDrawable = new AvatarDrawable(user);
avatarImage.setImage(photo, "50_50", avatarDrawable);
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
......
......@@ -69,6 +69,7 @@ public class AvatarDrawable extends Drawable {
}
public AvatarDrawable(TLRPC.User user, boolean profile) {
this();
isProfile = profile;
if (user != null) {
setInfo(user.id, user.first_name, user.last_name, false);
......@@ -76,6 +77,7 @@ public class AvatarDrawable extends Drawable {
}
public AvatarDrawable(TLRPC.Chat chat, boolean profile) {
this();
isProfile = profile;
if (chat != null) {
setInfo(chat.id, chat.title, null, chat.id < 0);
......
......@@ -400,6 +400,10 @@ public class Switch extends CompoundButton {
wasLayout = false;
}
public void resetLayout() {
wasLayout = false;
}
@Override
public void setChecked(boolean checked) {
super.setChecked(checked);
......
......@@ -12,7 +12,6 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Layout;
import android.text.StaticLayout;
......@@ -37,9 +36,9 @@ public class TimerDrawable extends Drawable {
emptyTimerDrawable = context.getResources().getDrawable(R.drawable.header_timer);
timerDrawable = context.getResources().getDrawable(R.drawable.header_timer2);
timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
timePaint.setTextSize(AndroidUtilities.dp(10));
timePaint.setColor(0xffd7e8f7);
timePaint.setTypeface(Typeface.DEFAULT_BOLD);
timePaint.setTextSize(AndroidUtilities.dp(11));
timePaint.setColor(0xffffffff);
timePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
}
}
......@@ -90,8 +89,8 @@ public class TimerDrawable extends Drawable {
@Override
public void draw(Canvas canvas) {
int width = getBounds().width();
int height = getBounds().height();
int width = timerDrawable.getIntrinsicWidth();
int height = timerDrawable.getIntrinsicHeight();
Drawable drawable = null;
if (time == 0) {
drawable = timerDrawable;
......@@ -105,7 +104,11 @@ public class TimerDrawable extends Drawable {
drawable.draw(canvas);
if (time != 0 && timeLayout != null) {
canvas.translate((int)(width / 2 - Math.ceil(timeWidth / 2)), (height - timeHeight) / 2 + AndroidUtilities.dpf2(1.5f));
int xOffxet = 0;
if (AndroidUtilities.density == 3) {
xOffxet = -1;
}
canvas.translate((int)(width / 2 - Math.ceil(timeWidth / 2)) + xOffxet, (height - timeHeight) / 2);
timeLayout.draw(canvas);
}
}
......@@ -127,11 +130,11 @@ public class TimerDrawable extends Drawable {
@Override
public int getIntrinsicWidth() {
return -1;
return timerDrawable.getIntrinsicWidth();
}
@Override
public int getIntrinsicHeight() {
return -1;
return timerDrawable.getIntrinsicHeight();
}
}
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