Bug fixes

This commit is contained in:
DrKLO 2017-07-23 20:29:17 +03:00
parent 5faa453835
commit 7fcd94d5c9
7 changed files with 59 additions and 69 deletions

View file

@ -11,7 +11,7 @@ package org.telegram.messenger;
public class BuildVars {
public static boolean DEBUG_VERSION = false;
public static boolean DEBUG_PRIVATE_VERSION = false;
public static int BUILD_VERSION = 1041;
public static int BUILD_VERSION = 1042;
public static String BUILD_VERSION_STRING = "4.2";
public static int APP_ID = 0; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id
public static String APP_HASH = ""; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id

View file

@ -174,7 +174,8 @@ public class NotificationCenter {
public void setAnimationInProgress(boolean value) {
animationInProgress = value;
if (!animationInProgress && !delayedPosts.isEmpty()) {
for (DelayedPost delayedPost : delayedPosts) {
for (int a = 0; a < delayedPosts.size(); a++) {
DelayedPost delayedPost = delayedPosts.get(a);
postNotificationNameInternal(delayedPost.id, true, delayedPost.args);
}
delayedPosts.clear();

View file

@ -39,6 +39,7 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PopupNotificationActivity;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
@ -1826,12 +1827,15 @@ public class NotificationsController {
mBuilder.setLargeIcon(img.getBitmap());
} else {
try {
float scaleFactor = 160.0f / AndroidUtilities.dp(50);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photoPath, true).toString(), options);
if (bitmap != null) {
mBuilder.setLargeIcon(bitmap);
File file = FileLoader.getPathToAttach(photoPath, true);
if (file.exists()) {
float scaleFactor = 160.0f / AndroidUtilities.dp(50);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
if (bitmap != null) {
mBuilder.setLargeIcon(bitmap);
}
}
} catch (Throwable e) {
//ignore
@ -2085,12 +2089,15 @@ public class NotificationsController {
builder.setLargeIcon(img.getBitmap());
} else {
try {
float scaleFactor = 160.0f / AndroidUtilities.dp(50);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photoPath, true).toString(), options);
if (bitmap != null) {
builder.setLargeIcon(bitmap);
File file = FileLoader.getPathToAttach(photoPath, true);
if (file.exists()) {
float scaleFactor = 160.0f / AndroidUtilities.dp(50);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
if (bitmap != null) {
builder.setLargeIcon(bitmap);
}
}
} catch (Throwable e) {
//ignore

View file

@ -19,7 +19,6 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@ -234,9 +233,9 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation = null;
}
if (onCloseAnimationEndRunnable != null) {
onCloseAnimationEnd(false);
onCloseAnimationEnd();
} else if (onOpenAnimationEndRunnable != null) {
onOpenAnimationEnd(false);
onOpenAnimationEnd();
}
}
if (!fragmentsStack.isEmpty()) {
@ -523,9 +522,9 @@ public class ActionBarLayout extends FrameLayout {
}
}
private void onAnimationEndCheck(boolean byCheck, boolean customAnimation) {
onCloseAnimationEnd(customAnimation);
onOpenAnimationEnd(customAnimation);
private void onAnimationEndCheck(boolean byCheck) {
onCloseAnimationEnd();
onOpenAnimationEnd();
if (waitingForKeyboardCloseRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(waitingForKeyboardCloseRunnable);
waitingForKeyboardCloseRunnable = null;
@ -551,7 +550,7 @@ public class ActionBarLayout extends FrameLayout {
public boolean checkTransitionAnimation() {
if (transitionAnimationInProgress && transitionAnimationStartTime < System.currentTimeMillis() - 1500) {
onAnimationEndCheck(true, false);
onAnimationEndCheck(true);
}
return transitionAnimationInProgress;
}
@ -627,7 +626,7 @@ public class ActionBarLayout extends FrameLayout {
if (animationProgress < 1) {
startLayoutAnimation(open, false);
} else {
onAnimationEndCheck(false, false);
onAnimationEndCheck(false);
}
}
});
@ -730,7 +729,7 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
onAnimationEndCheck(false, true);
onAnimationEndCheck(false);
}
});
currentAnimation.start();
@ -750,7 +749,7 @@ public class ActionBarLayout extends FrameLayout {
AnimatorSet animation = fragment.onCustomTransitionAnimation(true, new Runnable() {
@Override
public void run() {
onAnimationEndCheck(false, true);
onAnimationEndCheck(false);
}
});
if (animation == null) {
@ -921,7 +920,7 @@ public class ActionBarLayout extends FrameLayout {
AnimatorSet animation = currentFragment.onCustomTransitionAnimation(false, new Runnable() {
@Override
public void run() {
onAnimationEndCheck(false, true);
onAnimationEndCheck(false);
}
});
if (animation == null) {
@ -985,7 +984,7 @@ public class ActionBarLayout extends FrameLayout {
@Override
public void onAnimationEnd(Animator animation) {
onAnimationEndCheck(false, true);
onAnimationEndCheck(false);
}
});
currentAnimation.start();
@ -1113,21 +1112,12 @@ public class ActionBarLayout extends FrameLayout {
inActionMode = false;
}
private void onCloseAnimationEnd(boolean post) {
private void onCloseAnimationEnd() {
if (transitionAnimationInProgress && onCloseAnimationEndRunnable != null) {
transitionAnimationInProgress = false;
transitionAnimationStartTime = 0;
if (post) {
new Handler().post(new Runnable() {
public void run() {
onCloseAnimationEndRunnable.run();
onCloseAnimationEndRunnable = null;
}
});
} else {
onCloseAnimationEndRunnable.run();
onCloseAnimationEndRunnable = null;
}
onCloseAnimationEndRunnable.run();
onCloseAnimationEndRunnable = null;
checkNeedRebuild();
}
}
@ -1139,22 +1129,12 @@ public class ActionBarLayout extends FrameLayout {
}
}
private void onOpenAnimationEnd(boolean post) {
private void onOpenAnimationEnd() {
if (transitionAnimationInProgress && onOpenAnimationEndRunnable != null) {
transitionAnimationInProgress = false;
transitionAnimationStartTime = 0;
if (post) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
onOpenAnimationEndRunnable.run();
onOpenAnimationEndRunnable = null;
}
});
} else {
onOpenAnimationEndRunnable.run();
onOpenAnimationEndRunnable = null;
}
onOpenAnimationEndRunnable.run();
onOpenAnimationEndRunnable = null;
checkNeedRebuild();
}
}
@ -1169,9 +1149,9 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation = null;
}
if (onCloseAnimationEndRunnable != null) {
onCloseAnimationEnd(false);
onCloseAnimationEnd();
} else if (onOpenAnimationEndRunnable != null) {
onOpenAnimationEnd(false);
onOpenAnimationEnd();
}
containerView.invalidate();
if (intent != null) {

View file

@ -17,6 +17,7 @@ import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.view.Gravity;
@ -80,11 +81,7 @@ public class AboutLinkCell extends FrameLayout {
}
public void setTextAndIcon(String text, int resId, boolean parseLinks) {
if (text == null || text.length() == 0) {
setVisibility(GONE);
return;
}
if (text != null && oldText != null && text.equals(oldText)) {
if (TextUtils.isEmpty(text) || text != null && oldText != null && text.equals(oldText)) {
return;
}
oldText = text;
@ -174,8 +171,10 @@ public class AboutLinkCell extends FrameLayout {
@SuppressLint("DrawAllocation")
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
textLayout = new StaticLayout(stringBuilder, Theme.profile_aboutTextPaint, MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(71 + 16), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(textLayout.getHeight() + AndroidUtilities.dp(16), MeasureSpec.EXACTLY));
if (stringBuilder != null) {
textLayout = new StaticLayout(stringBuilder, Theme.profile_aboutTextPaint, MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(71 + 16), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((textLayout != null ? textLayout.getHeight() : AndroidUtilities.dp(20)) + AndroidUtilities.dp(16), MeasureSpec.EXACTLY));
}
@Override

View file

@ -947,7 +947,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
permissons.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
String[] items = permissons.toArray(new String[permissons.size()]);
activity.requestPermissions(items, 1);
try {
activity.requestPermissions(items, 1);
} catch (Exception ignore) {
}
}
@Override

View file

@ -2212,10 +2212,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if ((user == null || !user.bot) && !TextUtils.isEmpty(user.phone)) {
phoneRow = rowCount++;
}
TLRPC.TL_userFull userFull = MessagesController.getInstance().getUserFull(user.id);
String about = userFull != null ? userFull.about : null;
boolean hasUsername = user != null && !TextUtils.isEmpty(user.username);
if (about != null) {
if (userFull != null && !TextUtils.isEmpty(userFull.about)) {
if (phoneRow != -1) {
userSectionRow = rowCount++;
}
@ -2228,7 +2228,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (hasUsername) {
usernameRow = rowCount++;
}
sectionRow = rowCount++;
if (phoneRow != -1 || userInfoRow != -1 || userInfoDetailedRow != -1 || usernameRow != -1) {
sectionRow = rowCount++;
}
if (user_id != UserConfig.getClientUserId()) {
settingsNotificationsRow = rowCount++;
}
@ -2721,7 +2723,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else if (i == usernameRow) {
String text;
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user != null && user.username != null && user.username.length() != 0) {
if (user != null && !TextUtils.isEmpty(user.username)) {
text = "@" + user.username;
} else {
text = "-";
@ -2741,9 +2743,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
textDetailCell.setTextAndValue(text, MessagesController.getInstance().linkPrefix + "/" + currentChat.username);
} else if (i == userInfoDetailedRow) {
TLRPC.TL_userFull userFull = MessagesController.getInstance().getUserFull(user_id);
String about = userFull != null ? userFull.about : null;
textDetailCell.setMultiline(true);
textDetailCell.setTextAndValueAndIcon(about, LocaleController.getString("UserBio", R.string.UserBio), R.drawable.profile_info, 11);
textDetailCell.setTextAndValueAndIcon(userFull != null ? userFull.about : null, LocaleController.getString("UserBio", R.string.UserBio), R.drawable.profile_info, 11);
}
break;
case 3:
@ -2903,8 +2904,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
AboutLinkCell aboutLinkCell = (AboutLinkCell) holder.itemView;
if (i == userInfoRow) {
TLRPC.TL_userFull userFull = MessagesController.getInstance().getUserFull(user_id);
String about = userFull != null ? userFull.about : null;
aboutLinkCell.setTextAndIcon(about, R.drawable.profile_info, false);
aboutLinkCell.setTextAndIcon(userFull != null ? userFull.about : null, R.drawable.profile_info, false);
} else if (i == channelInfoRow) {
String text = info.about;
while (text.contains("\n\n\n")) {