Bug fixes

This commit is contained in:
DrKLO 2014-11-21 13:59:05 +03:00
parent baed4120bc
commit d69b5b3b36
15 changed files with 139 additions and 67 deletions

View File

@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 393
versionName "2.0.3"
versionCode 395
versionName "2.0.4"
}
}

View File

@ -1542,6 +1542,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (sourceFile.exists()) {
ProgressDialog progressDialog = null;
if (context != null) {
try {
progressDialog = new ProgressDialog(context);
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
@ -1549,6 +1550,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(100);
progressDialog.show();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
final ProgressDialog finalProgress = progressDialog;

View File

@ -238,7 +238,7 @@ public class NotificationsController {
PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class), 0);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
int minutes = preferences.getInt("repeat_messages", 60);
if (minutes > 0 || personal_count > 0) {
if (minutes > 0 && personal_count > 0) {
alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + minutes * 60 * 1000, pintent);
} else {
alarm.cancel(pintent);

View File

@ -16,6 +16,7 @@ import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.webkit.MimeTypeMap;
import android.widget.Toast;
import org.telegram.messenger.BuffersStorage;
import org.telegram.messenger.ByteBufferDesc;
@ -23,6 +24,7 @@ import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.MessageKeyData;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
@ -1856,9 +1858,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
}
private static void prepareSendingDocumentInternal(String path, String originalPath, Uri uri, String mime, final long dialog_id) {
private static boolean prepareSendingDocumentInternal(String path, String originalPath, Uri uri, String mime, final long dialog_id) {
if ((path == null || path.length() == 0) && uri == null) {
return;
return false;
}
MimeTypeMap myMime = MimeTypeMap.getSingleton();
if (uri != null) {
@ -1870,10 +1872,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
extension = "txt";
}
path = MediaController.copyDocumentToCache(uri, extension);
if (path == null) {
return false;
}
}
final File f = new File(path);
if (!f.exists() || f.length() == 0) {
return;
return false;
}
boolean isEncrypted = (int)dialog_id == 0;
@ -1938,6 +1943,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id);
}
});
return true;
}
public static void prepareSendingDocument(String path, String originalPath, Uri uri, String mine, long dialog_id) {
@ -1962,17 +1968,35 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
new Thread(new Runnable() {
@Override
public void run() {
boolean error = false;
if (paths != null) {
for (int a = 0; a < paths.size(); a++) {
prepareSendingDocumentInternal(paths.get(a), originalPaths.get(a), null, mime, dialog_id);
if (!prepareSendingDocumentInternal(paths.get(a), originalPaths.get(a), null, mime, dialog_id)) {
error = true;
}
}
}
if (uris != null) {
for (int a = 0; a < uris.size(); a++) {
prepareSendingDocumentInternal(null, null, uris.get(a), mime, dialog_id);
if (!prepareSendingDocumentInternal(null, null, uris.get(a), mime, dialog_id)) {
error = true;
}
}
}
if (error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
try {
Toast toast = Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment), Toast.LENGTH_SHORT);
toast.show();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
}
}).start();
}

View File

@ -567,6 +567,7 @@ public class ActionBarLayout extends FrameLayout {
containerViewBack.addView(fragment.actionBar);
fragment.actionBar.setTitleOverlayText(titleOverlayText);
}
containerViewBack.addView(fragmentView);
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
@ -623,6 +624,7 @@ public class ActionBarLayout extends FrameLayout {
public void run() {
presentFragmentInternalRemoveOld(removeLast, currentFragment);
fragment.onOpenAnimationEnd();
ViewProxy.setTranslationX(containerView, 0);
}
};
currentAnimation = new AnimatorSetProxy();

View File

@ -18,6 +18,8 @@ import android.view.ViewTreeObserver;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import org.telegram.messenger.FileLog;
import java.lang.reflect.Field;
public class ActionBarPopupWindow extends PopupWindow {
@ -157,8 +159,12 @@ public class ActionBarPopupWindow extends PopupWindow {
@Override
public void showAsDropDown(View anchor, int xoff, int yoff) {
try {
super.showAsDropDown(anchor, xoff, yoff);
registerListener(anchor);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
@Override

View File

@ -290,7 +290,9 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
view = new UserCell(mContext, 1);
}
TLRPC.User user = MessagesController.getInstance().getUser(MessagesController.getInstance().blockedUsers.get(i));
if (user != null) {
((UserCell) view).setData(user, null, user.phone != null && user.phone.length() != 0 ? PhoneFormat.getInstance().format("+" + user.phone) : LocaleController.getString("NumberUnknown", R.string.NumberUnknown), 0);
}
} else if (type == 1) {
if (view == null) {
view = new TextInfoCell(mContext);

View File

@ -458,6 +458,7 @@ public class DialogCell extends BaseCell {
}
}
nameWidth = Math.max(AndroidUtilities.dp(12), nameWidth);
CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
try {
nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
@ -510,9 +511,13 @@ public class DialogCell extends BaseCell {
}
messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(17));
}
messageWidth = Math.max(AndroidUtilities.dp(12), messageWidth);
CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
try {
messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
double widthpx = 0;
float left = 0;
@ -526,7 +531,7 @@ public class DialogCell extends BaseCell {
}
}
}
if (messageLayout.getLineCount() > 0) {
if (messageLayout != null && messageLayout.getLineCount() > 0) {
left = messageLayout.getLineLeft(0);
if (left == 0) {
widthpx = Math.ceil(messageLayout.getLineWidth(0));
@ -545,7 +550,7 @@ public class DialogCell extends BaseCell {
}
}
}
if (messageLayout.getLineCount() > 0) {
if (messageLayout != null && messageLayout.getLineCount() > 0) {
left = messageLayout.getLineRight(0);
if (left == messageWidth) {
widthpx = Math.ceil(messageLayout.getLineWidth(0));
@ -677,10 +682,12 @@ public class DialogCell extends BaseCell {
timeLayout.draw(canvas);
canvas.restore();
if (messageLayout != null) {
canvas.save();
canvas.translate(messageLeft, messageTop);
messageLayout.draw(canvas);
canvas.restore();
}
if (drawClock) {
setDrawableBounds(clockDrawable, checkDrawLeft, checkDrawTop);

View File

@ -386,7 +386,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (Intent.ACTION_SEND.equals(intent.getAction())) {
boolean error = false;
String type = intent.getType();
if (type != null && type.equals("text/plain")) {
if (type != null && type.equals("text/plain") && intent.getStringExtra(Intent.EXTRA_TEXT) != null) {
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
@ -950,6 +950,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.appDidLogout) {
if (drawerLayoutAdapter != null) {
drawerLayoutAdapter.notifyDataSetChanged();
}
for (BaseFragment fragment : actionBarLayout.fragmentsStack) {
fragment.onFragmentDestroy();
}

View File

@ -778,6 +778,7 @@ public class LoginActivity extends BaseFragment {
private void updatePhoneField() {
ignoreOnPhoneChange = true;
try {
String codeText = codeField.getText().toString();
String phone = PhoneFormat.getInstance().format("+" + codeText + phoneField.getText().toString());
int idx = phone.indexOf(" ");
@ -796,6 +797,9 @@ public class LoginActivity extends BaseFragment {
} else {
phoneField.setSelection(phoneField.length());
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ignoreOnPhoneChange = false;
}

View File

@ -22,6 +22,7 @@ import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
@ -32,6 +33,7 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController;
import org.telegram.android.MessagesController;
@ -537,6 +539,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
dialogsSearchAdapter.notifyDataSetChanged();
}
if (messagesListView != null) {
try {
if (messagesListView.getAdapter() != null && messagesListView.getAdapter() instanceof BaseAdapter) {
((BaseAdapter) messagesListView.getAdapter()).notifyDataSetChanged();
}
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
searchEmptyView.setVisibility(View.GONE);
emptyView.setVisibility(View.GONE);
@ -551,6 +557,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
progressView.setVisibility(View.GONE);
}
} catch (Exception e) {
FileLog.e("tmessages", e); //TODO fix it in other way?
}
}
} else if (id == NotificationCenter.emojiDidLoaded) {
if (messagesListView != null) {

View File

@ -242,12 +242,12 @@ public class PhotoCropActivity extends BaseFragment {
}
try {
return Bitmap.createBitmap(imageToCrop, x, y, size, size);
} catch (Exception e) {
} catch (Throwable e) {
FileLog.e("tmessags", e);
System.gc();
try {
return Bitmap.createBitmap(imageToCrop, x, y, size, size);
} catch (Exception e2) {
} catch (Throwable e2) {
FileLog.e("tmessages", e2);
}
}

View File

@ -1579,14 +1579,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return;
}
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.userPhotosLoaded);
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
@ -1596,9 +1588,24 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
FileLog.e("tmessages", e);
}
placeProvider = provider;
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
try {
wm.addView(windowView, windowLayoutParams);
} catch (Exception e) {
FileLog.e("tmessages", e);
return;
}
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.userPhotosLoaded);
placeProvider = provider;
if (velocityTracker == null) {
velocityTracker = VelocityTracker.obtain();

View File

@ -287,10 +287,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.clear().commit();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout);
MessagesController.getInstance().unregistedPush();
MessagesController.getInstance().logOut();
UserConfig.clearConfig();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout);
MessagesStorage.getInstance().cleanUp(false);
MessagesController.getInstance().cleanUp();
ContactsController.getInstance().deleteAllAppAccounts();

View File

@ -631,7 +631,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
}
try {
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.LEFT, 0, 0);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (!keyboardVisible) {
if (sizeNotifierRelativeLayout != null) {
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);