Bug fixes

This commit is contained in:
DrKLO 2014-11-19 04:23:46 +03:00
parent a137f7a22f
commit 77f2395428
56 changed files with 464 additions and 184 deletions

View file

@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 383
versionCode 384
versionName "2.0.0"
}
}

View file

@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages.2
LOCAL_MODULE := tmessages.3
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0

View file

@ -229,7 +229,7 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_blurBitmap(JNIEnv *env, jcl
AndroidBitmap_unlockPixels(env, bitmap);
}
JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jobject bitmap, int scale) {
JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jobject bitmap, int scale, int width, int height, int stride) {
AndroidBitmapInfo info;
int i;
@ -260,13 +260,13 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jcl
unsigned char *pixels;
if ((i = AndroidBitmap_lockPixels(env, bitmap, &pixels)) >= 0) {
int rowCount = min(cinfo.output_height, info.height);
int colCount = min(cinfo.output_width, info.width);
int rowCount = min(cinfo.output_height, height);
int colCount = min(cinfo.output_width, width);
while (cinfo.output_scanline < rowCount) {
jpeg_read_scanlines(&cinfo, buffer, 1);
if (info.format == ANDROID_BITMAP_FORMAT_RGBA_8888) {
//if (info.format == ANDROID_BITMAP_FORMAT_RGBA_8888) {
if (cinfo.out_color_space == JCS_GRAYSCALE) {
for (i = 0; i < colCount; i++) {
float alpha = buffer[0][i] / 255.0f;
@ -285,11 +285,11 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jcl
c += 4;
}
}
} else if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) {
//} else if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) {
}
//}
pixels += info.stride;
pixels += stride;
}
AndroidBitmap_unlockPixels(env, bitmap);

View file

@ -1604,6 +1604,15 @@ public class ContactsController {
for (Object object : vector.objects) {
TLRPC.User toDbUser = new TLRPC.User();
TLRPC.TL_contactStatus status = (TLRPC.TL_contactStatus) object;
if (status.status instanceof TLRPC.TL_userStatusRecently) {
status.status.expires = -100;
} else if (status.status instanceof TLRPC.TL_userStatusLastWeek) {
status.status.expires = -101;
} else if (status.status instanceof TLRPC.TL_userStatusLastMonth) {
status.status.expires = -102;
}
TLRPC.User user = MessagesController.getInstance().getUser(status.user_id);
if (user != null) {
user.status = status.status;

View file

@ -246,8 +246,12 @@ public class Emoji {
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imageFile.getAbsolutePath(), opts);
final Bitmap bitmap = Bitmap.createBitmap(opts.outWidth / imageResize, opts.outHeight / imageResize, Bitmap.Config.ARGB_8888);
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize);
int width = opts.outWidth / imageResize;
int height = opts.outHeight / imageResize;
int stride = width * 4;
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, width, height, stride);
imageName = String.format(Locale.US, "emoji%.01fx_a_%d.jpg", scale, page);
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
@ -257,7 +261,7 @@ public class Emoji {
is.close();
}
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize);
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, width, height, stride);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override

View file

@ -782,6 +782,15 @@ public class LocaleController {
}
public static String formatUserStatus(TLRPC.User user) {
if (user != null && user.status != null && user.status.expires == 0) {
if (user.status instanceof TLRPC.TL_userStatusRecently) {
user.status.expires = -100;
} else if (user.status instanceof TLRPC.TL_userStatusLastWeek) {
user.status.expires = -101;
} else if (user.status instanceof TLRPC.TL_userStatusLastMonth) {
user.status.expires = -102;
}
}
if (user == null || user.status == null || user.status.expires == 0 || user instanceof TLRPC.TL_userDeleted || user instanceof TLRPC.TL_userEmpty) {
return getString("ALongTimeAgo", R.string.ALongTimeAgo);
} else {

View file

@ -1334,7 +1334,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
public void loadMessages(final long dialog_id, final int count, final int max_id, boolean fromCache, int midDate, final int classGuid, final int load_type) {
public void loadMessages(final long dialog_id, final int count, final int max_id, boolean fromCache, int midDate, final int classGuid, final int load_type, final int last_message_id, final int first_message_id, final boolean allowCache) {
int lower_part = (int)dialog_id;
if (fromCache || lower_part == 0) {
MessagesStorage.getInstance().getMessages(dialog_id, count, max_id, midDate, classGuid, load_type);
@ -1356,6 +1356,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
if (load_type == 3) {
req.offset = -count / 2;
} else if (load_type == 1) {
req.offset = -count - 1;
} else {
req.offset = 0;
}
@ -1366,7 +1368,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
final TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
processLoadedMessages(res, dialog_id, count, max_id, false, classGuid, 0, 0, 0, 0, load_type);
processLoadedMessages(res, dialog_id, count, max_id, false, classGuid, 0, last_message_id, first_message_id, 0, 0, load_type, allowCache);
}
}
});
@ -1374,20 +1376,21 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
public void processLoadedMessages(final TLRPC.messages_Messages messagesRes, final long dialog_id, final int count, final int max_id, final boolean isCache, final int classGuid, final int first_unread, final int last_message_id, final int unread_count, final int last_date, final int load_type) {
public void processLoadedMessages(final TLRPC.messages_Messages messagesRes, final long dialog_id, final int count, final int max_id, final boolean isCache, final int classGuid,
final int first_unread, final int last_message_id, final int first_message_id, final int unread_count, final int last_date, final int load_type, final boolean allowCache) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
int lower_id = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (!isCache) {
if (!isCache && allowCache) {
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
}
if (high_id != 1 && lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 2 || load_type == 3)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
loadMessages(dialog_id, count, max_id, false, 0, classGuid, load_type);
loadMessages(dialog_id, count, max_id, false, 0, classGuid, load_type, last_message_id, first_message_id, allowCache);
}
});
return;
@ -1406,7 +1409,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run() {
putUsers(messagesRes.users, isCache);
putChats(messagesRes.chats, isCache);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDidLoaded, dialog_id, count, objects, isCache, first_unread, last_message_id, unread_count, last_date, load_type);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDidLoaded, dialog_id, count, objects, isCache, first_unread, last_message_id, first_message_id, unread_count, last_date, load_type);
}
});
}

View file

@ -130,8 +130,8 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE sent_files_v2(uid TEXT, type INTEGER, data BLOB, PRIMARY KEY (uid, type))").stepThis().dispose();
database.executeFast("CREATE TABLE messages_holes(uid INTEGER, start INTEGER, end INTEGER, PRIMARY KEY(uid, start));").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS type_uid_end_messages_holes ON messages_holes(uid, end);").stepThis().dispose();
//database.executeFast("CREATE TABLE messages_holes(uid INTEGER, start INTEGER, end INTEGER, PRIMARY KEY(uid, start));").stepThis().dispose();
//database.executeFast("CREATE INDEX IF NOT EXISTS type_uid_end_messages_holes ON messages_holes(uid, end);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS type_date_idx_download_queue ON download_queue(type, date);").stepThis().dispose();
@ -323,12 +323,12 @@ public class MessagesStorage {
database.executeFast("PRAGMA user_version = 8").stepThis().dispose();
version = 8;
}*/
if ((version == 7 || version == 8) && version < 9) {
/*if ((version == 7 || version == 8) && version < 9) {
database.executeFast("CREATE TABLE IF NOT EXISTS messages_holes(uid INTEGER, start INTEGER, end INTEGER, PRIMARY KEY(uid, start));").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS type_uid_end_messages_holes ON messages_holes(uid, end);").stepThis().dispose();
database.executeFast("PRAGMA user_version = 9").stepThis().dispose();
version = 9;
}
}*/
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -1615,6 +1615,29 @@ public class MessagesStorage {
});
}
/*private ArrayList<Range<Integer>> getHoles(long dialog_id) {
int lower_id = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_id == 0 || lower_id != 0 && high_id == 1) {
return null;
}
ArrayList<Range<Integer>> holes = null;
try {
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT start, end FROM messages_holes WHERE uid = %d", dialog_id));
while (cursor.next()) {
if (holes == null) {
holes = new ArrayList<Range<Integer>>();
}
holes.add(new Range<Integer>(cursor.intValue(0), cursor.intValue(1)));
}
cursor.dispose();
} catch (Exception e) {
FileLog.e("tmessages" , e);
}
return holes;
}*/
public void getMessages(final long dialog_id, final int count, final int max_id, final int minDate, final int classGuid, final int load_type) {
storageQueue.postRunnable(new Runnable() {
@Override
@ -1625,6 +1648,7 @@ public class MessagesStorage {
int offset_query = 0;
int min_unread_id = 0;
int last_message_id = 0;
int first_message_id = 0;
int max_unread_date = 0;
int hole_start = Integer.MAX_VALUE;
int hole_end = Integer.MAX_VALUE;
@ -1637,9 +1661,10 @@ public class MessagesStorage {
if (lower_id != 0) {
if (load_type == 3) {
cursor = database.queryFinalized(String.format(Locale.US, "SELECT max(mid) FROM messages WHERE uid = %d AND mid > 0", dialog_id));
cursor = database.queryFinalized(String.format(Locale.US, "SELECT max(mid), min(mid) FROM messages WHERE uid = %d AND mid > 0", dialog_id));
if (cursor.next()) {
last_message_id = cursor.intValue(0);
first_message_id = cursor.intValue(1);
}
cursor.dispose();
@ -1750,12 +1775,6 @@ public class MessagesStorage {
while (cursor.next()) {
ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1));
if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) {
/*if (load_type == 3 && res.messages.isEmpty()) {
int id = cursor.intValue(3);
if (id > max_id) {
break;
}
}*/
TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
MessageObject.setIsUnread(message, cursor.intValue(0) != 1);
message.id = cursor.intValue(3);
@ -1803,52 +1822,56 @@ public class MessagesStorage {
@Override
public int compare(TLRPC.Message lhs, TLRPC.Message rhs) {
if (lhs.id > 0 && rhs.id > 0) {
if (load_type != 1) {
if (lhs.id > rhs.id) {
return -1;
} else if (lhs.id < rhs.id) {
return 1;
}
} else {
if (lhs.id < rhs.id) {
return -1;
} else if (lhs.id > rhs.id) {
return 1;
}
}
} else if (lhs.id < 0 && rhs.id < 0) {
if (load_type != 1) {
if (lhs.id < rhs.id) {
return -1;
} else if (lhs.id > rhs.id) {
return 1;
}
} else {
if (lhs.id > rhs.id) {
return -1;
} else if (lhs.id < rhs.id) {
return 1;
}
}
} else {
if (load_type != 1) {
if (lhs.date > rhs.date) {
return -1;
} else if (lhs.date < rhs.date) {
return 1;
}
} else {
if (lhs.date < rhs.date) {
return -1;
} else if (lhs.date > rhs.date) {
return 1;
}
}
}
return 0;
}
});
/*ArrayList<Range<Integer>> holes = getHoles(dialog_id);
if (holes != null && !res.messages.isEmpty()) {
int start = res.messages.get(res.messages.size() - 1).id;
int end = res.messages.get(0).id;
for (Range<Integer> range : holes) {
if (range.contains(start) && range.contains(end)) {
res.messages.clear();
} else if (range.contains(start)) {
while (!res.messages.isEmpty() && range.contains(res.messages.get(res.messages.size() - 1).id)) {
res.messages.remove(res.messages.size() - 1);
}
if (!res.messages.isEmpty()) {
start = res.messages.get(res.messages.size() - 1).id;
}
} else if (range.contains(end)) {
while (!res.messages.isEmpty() && range.contains(res.messages.get(0).id)) {
res.messages.remove(0);
}
if (!res.messages.isEmpty()) {
end = res.messages.get(0).id;
}
} else if (start >= )
if (res.messages.isEmpty()) {
break;
}
}
}*/
StringBuilder usersToLoad = new StringBuilder();
for (int uid : fromUser) {
if (!loadedUsers.contains(uid)) {
@ -1868,7 +1891,7 @@ public class MessagesStorage {
res.users.clear();
FileLog.e("tmessages", e);
} finally {
MessagesController.getInstance().processLoadedMessages(res, dialog_id, count_query, max_id, true, classGuid, min_unread_id, last_message_id, count_unread, max_unread_date, load_type);
MessagesController.getInstance().processLoadedMessages(res, dialog_id, count_query, max_id, true, classGuid, min_unread_id, last_message_id, first_message_id, count_unread, max_unread_date, load_type, false);
}
}
});
@ -2202,6 +2225,13 @@ public class MessagesStorage {
state.bindInteger(1, user.id);
state.bindString(2, formatUserSearchName(user));
if (user.status != null) {
if (user.status instanceof TLRPC.TL_userStatusRecently) {
user.status.expires = -100;
} else if (user.status instanceof TLRPC.TL_userStatusLastWeek) {
user.status.expires = -101;
} else if (user.status instanceof TLRPC.TL_userStatusLastMonth) {
user.status.expires = -102;
}
state.bindInteger(3, user.status.expires);
} else {
state.bindInteger(3, 0);

View file

@ -23,7 +23,7 @@ import java.util.zip.ZipFile;
public class NativeLoader {
private final static int LIB_VERSION = 2;
private final static int LIB_VERSION = 3;
private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";

View file

@ -108,7 +108,7 @@ public class Utilities {
}
public native static long doPQNative(long _what);
public native static void loadBitmap(String path, Bitmap bitmap, int scale);
public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride);
public native static void blurBitmap(Object bitmap, int radius);
public native static int convertVideoFrame(ByteBuffer src, ByteBuffer dest, int destFormat, int width, int height, int padding, int swap);
private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length);

View file

@ -284,6 +284,7 @@ public class ActionBarLayout extends FrameLayout {
bringChildToFront(containerView);
lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
currentActionBar = lastFragment.actionBar;
lastFragment.onResume();
} else {
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
@ -302,7 +303,7 @@ public class ActionBarLayout extends FrameLayout {
}
}
containerViewBack.setVisibility(View.GONE);
AndroidUtilities.unlockOrientation(parentActivity);
//AndroidUtilities.unlockOrientation(parentActivity);
startedTracking = false;
animationInProgress = false;
@ -345,7 +346,7 @@ public class ActionBarLayout extends FrameLayout {
}
lastFragment.onResume();
AndroidUtilities.lockOrientation(parentActivity);
//AndroidUtilities.lockOrientation(parentActivity);
}
public boolean onTouchEvent(MotionEvent ev) {

View file

@ -247,6 +247,10 @@ public class DrawerLayoutContainer extends FrameLayout {
public void setAllowOpenDrawer(boolean value) {
allowOpenDrawer = value;
if (!allowOpenDrawer && drawerPosition != 0) {
setDrawerPosition(0);
onDrawerAnimationEnd(false);
}
}
private void prepareForDrawerOpen(MotionEvent ev) {
@ -287,7 +291,7 @@ public class DrawerLayoutContainer extends FrameLayout {
int dx = (int) (ev.getX() - startedTrackingX);
int dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev);
if (maybeStartTracking && !startedTracking && Math.abs(dx) / 3 > Math.abs(dy)) {
if (maybeStartTracking && !startedTracking && Math.abs(dx) / 3 > Math.abs(dy) && (dx < 0 || dx > 0 && dx > AndroidUtilities.dp(10))) {
prepareForDrawerOpen(ev);
startedTrackingX = (int) ev.getX();
} else if (startedTracking) {

View file

@ -9,16 +9,15 @@
package org.telegram.ui.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.Cells.DialogCell;
import org.telegram.ui.Cells.LoadingCell;
public class DialogsAdapter extends BaseFragmentAdapter {
@ -92,8 +91,7 @@ public class DialogsAdapter extends BaseFragmentAdapter {
int type = getItemViewType(i);
if (type == 1) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.loading_more_layout, viewGroup, false);
view = new LoadingCell(mContext);
}
} else if (type == 0) {
if (view == null) {

View file

@ -32,6 +32,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Cells.DialogCell;
import org.telegram.ui.Cells.GreySectionCell;
import org.telegram.ui.Cells.LoadingCell;
import org.telegram.ui.Cells.ProfileSearchCell;
import java.util.ArrayList;
@ -49,6 +50,8 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
private int lastReqId;
private MessagesActivitySearchAdapterDelegate delegate;
private boolean needMessagesSearch;
private boolean messagesSearchEndReached;
private String lastMessagesSearchString;
public static interface MessagesActivitySearchAdapterDelegate {
public abstract void searchStateChanged(boolean searching);
@ -57,13 +60,20 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
public DialogsSearchAdapter(Context context, boolean messagesSearch) {
mContext = context;
needMessagesSearch = messagesSearch;
needMessagesSearch = false;
}
public void setDelegate(MessagesActivitySearchAdapterDelegate delegate) {
this.delegate = delegate;
}
public boolean isMessagesSearchEndReached() {
return messagesSearchEndReached;
}
public void loadMoreSearchMessages() {
searchMessagesInternal(lastMessagesSearchString);
}
private void searchMessagesInternal(final String query) {
if (!needMessagesSearch) {
return;
@ -75,16 +85,21 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
if (query == null || query.length() == 0) {
searchResultMessages.clear();
lastReqId = 0;
lastMessagesSearchString = null;
notifyDataSetChanged();
if (delegate != null) {
delegate.searchStateChanged(false);
}
return;
}
TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
req.limit = 128;
final TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
req.limit = 20;
req.peer = new TLRPC.TL_inputPeerEmpty();
req.q = query;
if (lastMessagesSearchString != null && query.equals(lastMessagesSearchString) && !searchResultMessages.isEmpty()) {
req.max_id = searchResultMessages.get(searchResultMessages.size() - 1).messageOwner.id;
}
lastMessagesSearchString = query;
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
final int currentReqId = ++lastReqId;
if (delegate != null) {
@ -102,10 +117,13 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
MessagesController.getInstance().putUsers(res.users, false);
MessagesController.getInstance().putChats(res.chats, false);
if (req.max_id == 0) {
searchResultMessages.clear();
}
for (TLRPC.Message message : res.messages) {
searchResultMessages.add(new MessageObject(message, null, 0));
}
messagesSearchEndReached = res.messages.size() != 20;
notifyDataSetChanged();
}
}
@ -278,7 +296,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
}
public void searchDialogs(final String query, final boolean serverOnly) {
if (query == null && lastSearchText == null || query != null && lastSearchText != null && query.equals(lastSearchText)) {
if (query != null && lastSearchText != null && query.equals(lastSearchText)) {
return;
}
try {
@ -337,7 +355,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
count += globalCount + 1;
}
if (messagesCount != 0) {
count += messagesCount + 1;
count += messagesCount + 1 + (messagesSearchEndReached ? 0 : 1);
}
return count;
}
@ -433,6 +451,10 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
((DialogCell) view).useSeparator = (i != getCount() - 1);
MessageObject messageObject = (MessageObject)getItem(i);
((DialogCell) view).setDialog(messageObject.getDialogId(), messageObject, false, messageObject.messageOwner.date, 0);
} else if (type == 3) {
if (view == null) {
view = new LoadingCell(mContext);
}
}
return view;
@ -447,13 +469,15 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
return 0;
} else if (i > globalCount + localCount && i < globalCount + localCount + messagesCount) {
return 2;
} else if (messagesCount != 0 && i == globalCount + localCount + messagesCount) {
return 3;
}
return 1;
}
@Override
public int getViewTypeCount() {
return 3;
return 4;
}
@Override

View file

@ -35,9 +35,12 @@ public class View10 extends Animation {
public static View10 wrap(View view) {
View10 proxy = PROXIES.get(view);
if (proxy == null || proxy != view.getAnimation()) {
Animation animation = view.getAnimation();
if (proxy == null || proxy != animation && animation != null) {
proxy = new View10(view);
PROXIES.put(view, proxy);
} else if (animation == null) {
view.setAnimation(proxy);
}
return proxy;
}

View file

@ -161,9 +161,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
selectedUserId = MessagesController.getInstance().blockedUsers.get(i);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] {LocaleController.getString("Unblock", R.string.Unblock)};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {

View file

@ -0,0 +1,36 @@
/*
* This is the source code of Telegram for Android v. 1.7.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.Cells;
import android.content.Context;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import org.telegram.android.AndroidUtilities;
public class LoadingCell extends FrameLayout {
public LoadingCell(Context context) {
super(context);
ProgressBar progressBar = new ProgressBar(context);
addView(progressBar);
LayoutParams layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.CENTER;
progressBar.setLayoutParams(layoutParams);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(54), MeasureSpec.EXACTLY));
}
}

View file

@ -106,6 +106,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private ActionBarMenuItem timeItem;
private TimerDrawable timerDrawable;
private ActionBarMenuItem menuItem;
//private ActionBarMenuItem attachItem;
//private ActionBarMenuItem headerItem;
private TextView addContactItem;
private LayoutListView chatListView;
private BackupImageView avatarImageView;
@ -121,6 +123,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TextView secretViewStatusTextView;
private TextView selectedMessagesCountTextView;
private AnimatorSetProxy runningAnimation2;
private MessageObject selectedObject;
private MessageObject forwaringMessage;
private boolean paused = true;
@ -150,6 +154,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean cacheEndReaced = false;
private boolean firstLoading = true;
private int loadsCount = 0;
private int startLoadFromMessageId = 0;
private int minDate = 0;
@ -157,6 +162,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int unread_to_load = 0;
private int first_unread_id = 0;
private int last_message_id = 0;
private int first_message_id = 0;
private boolean forward_end_reached = true;
private boolean loadingForward = false;
private MessageObject unreadMessageObject = null;
@ -358,6 +364,62 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void needSendTyping() {
MessagesController.getInstance().sendTyping(dialog_id, classGuid);
}
@Override
public void onAttachButtonHidden() {
/*if (runningAnimation2 != null) {
runningAnimation2.cancel();
runningAnimation2 = null;
}
attachItem.setVisibility(View.VISIBLE);
runningAnimation2 = new AnimatorSetProxy();
runningAnimation2.playTogether(
ObjectAnimatorProxy.ofFloat(attachItem, "alpha", 1.0f),
ObjectAnimatorProxy.ofFloat(headerItem, "alpha", 0.0f)
//ObjectAnimatorProxy.ofFloat(attachItem, "scaleX", 1.0f),
//ObjectAnimatorProxy.ofFloat(headerItem, "scaleX", 0.0f)
);
runningAnimation2.setDuration(100);
runningAnimation2.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animation) {
if (runningAnimation2.equals(animation)) {
headerItem.setVisibility(View.INVISIBLE);
headerItem.clearAnimation();
}
}
});
runningAnimation2.start();*/
}
@Override
public void onAttachButtonShow() {
/*if (runningAnimation2 != null) {
runningAnimation2.cancel();
runningAnimation2 = null;
}
headerItem.setVisibility(View.VISIBLE);
runningAnimation2 = new AnimatorSetProxy();
runningAnimation2.playTogether(
ObjectAnimatorProxy.ofFloat(attachItem, "alpha", 0.0f),
ObjectAnimatorProxy.ofFloat(headerItem, "alpha", 1.0f)
//ObjectAnimatorProxy.ofFloat(attachItem, "scaleX", 0.0f),
//ObjectAnimatorProxy.ofFloat(headerItem, "scaleX", 1.0f)
);
runningAnimation2.setDuration(100);
runningAnimation2.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animation) {
if (runningAnimation2.equals(animation)) {
attachItem.setVisibility(View.INVISIBLE);
attachItem.clearAnimation();
}
}
});
runningAnimation2.start();*/
}
});
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
@ -387,9 +449,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
loading = true;
if (startLoadFromMessageId != 0) {
MessagesController.getInstance().loadMessages(dialog_id, AndroidUtilities.isTablet() ? 30 : 20, startLoadFromMessageId, true, 0, classGuid, 3);
MessagesController.getInstance().loadMessages(dialog_id, AndroidUtilities.isTablet() ? 30 : 20, startLoadFromMessageId, true, 0, classGuid, 3, 0, 0, false);
} else {
MessagesController.getInstance().loadMessages(dialog_id, AndroidUtilities.isTablet() ? 30 : 20, 0, true, 0, classGuid, 2);
MessagesController.getInstance().loadMessages(dialog_id, AndroidUtilities.isTablet() ? 30 : 20, 0, true, 0, classGuid, 2, 0, 0, true);
}
if (currentUser != null) {
@ -635,6 +697,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
showAlertDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat));
} else if (id == clear_history || id == delete_chat) {
if (getParentActivity() == null) {
return;
}
final boolean isChat = (int)dialog_id < 0 && (int)(dialog_id >> 32) != 1;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
@ -792,6 +857,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat != null) {
timeItem = menu.addItem(chat_enc_timer, timerDrawable = new TimerDrawable(getParentActivity()));
//headerItem = timeItem;
} else {
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
if (currentUser != null) {
@ -803,8 +869,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
item.addSubItem(delete_chat, LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser), 0);
}
//headerItem = item;
}
/*LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) headerItem.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(-48);
headerItem.setLayoutParams(layoutParams);
attachItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach3);
attachItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo);
attachItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery);
attachItem.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video);
attachItem.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc);
attachItem.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location);
ViewProxy.setPivotX(attachItem, AndroidUtilities.dp(48));
ViewProxy.setPivotX(headerItem, 0);*/
menuItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach);
menuItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo);
menuItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery);
@ -1091,16 +1171,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (firstVisibleItem <= 10) {
if (!endReached && !loading) {
if (messagesByDays.size() != 0) {
MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced, minDate, classGuid, 0);
MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced && startLoadFromMessageId == 0, minDate, classGuid, 0, 0, 0, startLoadFromMessageId == 0);
} else {
MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced, minDate, classGuid, 0);
MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced && startLoadFromMessageId == 0, minDate, classGuid, 0, 0, 0, startLoadFromMessageId == 0);
}
loading = true;
}
}
if (firstVisibleItem + visibleItemCount >= totalItemCount - 6) {
if (!forward_end_reached && !loadingForward) {
MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, true, maxDate, classGuid, 1);
MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, startLoadFromMessageId == 0, maxDate, classGuid, 1, 0, 0, startLoadFromMessageId == 0);
loadingForward = true;
}
}
@ -1200,7 +1280,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void scrollToLastMessage() {
if (forward_end_reached || first_unread_id == 0) {
if ((forward_end_reached || first_unread_id == 0) && startLoadFromMessageId == 0) {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
} else {
messages.clear();
@ -1219,8 +1299,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
minDate = 0;
forward_end_reached = true;
loading = true;
startLoadFromMessageId = 0;
chatAdapter.notifyDataSetChanged();
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, 0);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, 0, 0, 0, true);
}
}
@ -1274,6 +1355,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (currentEncryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) {
bottomOverlayText.setText(LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected));
bottomOverlay.setVisibility(View.VISIBLE);
chatActivityEnterView.setFieldText("");
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
preferences.edit().remove("dialog_" + dialog_id).commit();
hideKeyboard = true;
} else if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
bottomOverlay.setVisibility(View.GONE);
@ -1759,15 +1843,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int count = (Integer)args[1];
boolean isCache = (Boolean)args[3];
int fnid = (Integer)args[4];
int last_unread_date = (Integer)args[7];
int load_type = (Integer)args[8];
int last_unread_date = (Integer)args[8];
int load_type = (Integer)args[9];
boolean wasUnread = false;
if (fnid != 0) {
first_unread_id = fnid;
last_message_id = (Integer)args[5];
unread_to_load = (Integer)args[6];
} else if (startLoadFromMessageId != 0) {
unread_to_load = (Integer)args[7];
} else if (startLoadFromMessageId != 0 && load_type == 3) {
last_message_id = (Integer)args[5];
first_message_id = (Integer)args[6];
}
ArrayList<MessageObject> messArr = (ArrayList<MessageObject>)args[2];
@ -1797,6 +1882,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
firstLoading = false;
}
if (load_type == 1) {
Collections.reverse(messArr);
}
for (int a = 0; a < messArr.size(); a++) {
MessageObject obj = messArr.get(a);
if (messagesDict.containsKey(obj.messageOwner.id)) {
@ -1872,8 +1961,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (load_type == 3 && obj.messageOwner.id == startLoadFromMessageId) {
highlightMessageId = obj.messageOwner.id;
scrollToMessage = obj;
if (isCache) {
startLoadFromMessageId = 0;
}
scrollToMessageMiddleScreen = true;
} else if (load_type == 1 && startLoadFromMessageId != 0 && first_message_id != 0 && obj.messageOwner.id >= first_message_id) {
startLoadFromMessageId = 0;
}
if (obj.messageOwner.id == last_message_id) {
@ -1883,6 +1976,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (forward_end_reached) {
first_unread_id = 0;
first_message_id = 0;
last_message_id = 0;
}
@ -1891,6 +1985,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
forward_end_reached = true;
first_unread_id = 0;
last_message_id = 0;
first_message_id = 0;
startLoadFromMessageId = 0;
}
chatAdapter.notifyDataSetChanged();
@ -1975,13 +2071,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (first && messages.size() > 0) {
final boolean wasUnreadFinal = wasUnread;
final int last_unread_date_final = last_unread_date;
final int lastid = messages.get(0).messageOwner.id;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (last_message_id != 0) {
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, last_message_id, 0, last_unread_date_final, wasUnreadFinal, false);
MessagesController.getInstance().markDialogAsRead(dialog_id, lastid, last_message_id, 0, last_unread_date_final, wasUnreadFinal, false);
} else {
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, wasUnreadFinal, false);
MessagesController.getInstance().markDialogAsRead(dialog_id, lastid, minMessageId, 0, maxDate, wasUnreadFinal, false);
}
}
}, 700);
@ -2266,7 +2363,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
maxDate = Integer.MIN_VALUE;
minDate = 0;
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReaced, minDate, classGuid, 0);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReaced, minDate, classGuid, 0, 0, 0, true);
loading = true;
}
}
@ -2544,9 +2641,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
String lastMessageText = preferences.getString("dialog_" + dialog_id, null);
if (lastMessageText != null) {
SharedPreferences.Editor editor = preferences.edit();
editor.remove("dialog_" + dialog_id);
editor.commit();
preferences.edit().remove("dialog_" + dialog_id).commit();
chatActivityEnterView.setFieldText(lastMessageText);
}
if (bottomOverlayChat.getVisibility() != View.VISIBLE) {

View file

@ -392,6 +392,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
if (selectedContacts.containsKey(user.id)) {
try {
XImageSpan span = selectedContacts.get(user.id);
selectedContacts.remove(user.id);
SpannableStringBuilder text = new SpannableStringBuilder(userSelectEditText.getText());
@ -401,6 +402,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
userSelectEditText.setText(text);
userSelectEditText.setSelection(text.length());
ignoreChange = false;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
if (selectedContacts.size() == maxCount) {
return;

View file

@ -46,6 +46,7 @@ import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.AvatarUpdater;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Views.FrameLayoutFixed;
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
@ -200,11 +201,12 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
LinearLayout linearLayout = (LinearLayout) fragmentView;
linearLayout.setOrientation(LinearLayout.VERTICAL);
FrameLayout frameLayout = new FrameLayout(getParentActivity());
FrameLayout frameLayout = new FrameLayoutFixed(getParentActivity());
linearLayout.addView(frameLayout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
frameLayout.setLayoutParams(layoutParams);
avatarImage = new BackupImageView(getParentActivity());
@ -217,7 +219,9 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
layoutParams1.height = AndroidUtilities.dp(64);
layoutParams1.topMargin = AndroidUtilities.dp(12);
layoutParams1.bottomMargin = AndroidUtilities.dp(12);
layoutParams1.leftMargin = AndroidUtilities.dp(16);
layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0;
layoutParams1.gravity = Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
avatarImage.setLayoutParams(layoutParams1);
if (!isBroadcast) {
avatarDrawable.setDrawPhoto(true);
@ -263,7 +267,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
nameToSet = null;
}
nameTextView.setMaxLines(4);
nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
nameTextView.setHintTextColor(0xff979797);
nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
@ -275,8 +279,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams1.leftMargin = AndroidUtilities.dp(96);
layoutParams1.rightMargin = AndroidUtilities.dp(16);
layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96);
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16);
layoutParams1.gravity = Gravity.CENTER_VERTICAL;
nameTextView.setLayoutParams(layoutParams1);
if (!isBroadcast) {

View file

@ -648,9 +648,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.showLastFragment();
rightActionBarLayout.showLastFragment();
}
drawerLayoutContainer.setAllowOpenDrawer(false);
}
if (open_settings != 0) {
actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
drawerLayoutContainer.setAllowOpenDrawer(false);
if (AndroidUtilities.isTablet()) {
layersActionBarLayout.showLastFragment();
rightActionBarLayout.showLastFragment();
}
pushOpened = true;
}
if (!pushOpened && !isNew) {
@ -1280,5 +1286,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.showLastFragment();
}
}
drawerLayoutAdapter.notifyDataSetChanged();
}
}

View file

@ -447,6 +447,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (searching && searchWas) {
if (visibleItemCount > 0 && absListView.getLastVisiblePosition() == totalItemCount - 1 && !dialogsSearchAdapter.isMessagesSearchEndReached()) {
dialogsSearchAdapter.loadMoreSearchMessages();
}
return;
}
if (visibleItemCount > 0) {
@ -507,6 +510,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
@Override
public void onGlobalLayout() {
ViewProxy.setTranslationY(floatingButton, floatingHidden ? AndroidUtilities.dp(100) : 0);
floatingButton.setClickable(!floatingHidden);
if (floatingButton != null) {
if (Build.VERSION.SDK_INT < 16) {
floatingButton.getViewTreeObserver().removeGlobalOnLayoutListener(this);
@ -578,6 +582,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
floatingHidden = hide;
ObjectAnimatorProxy animator = ObjectAnimatorProxy.ofFloatProxy(floatingButton, "translationY", floatingHidden ? AndroidUtilities.dp(100) : 0).setDuration(300);
animator.setInterpolator(floatingInterpolator);
floatingButton.setClickable(!hide);
animator.start();
}

View file

@ -146,7 +146,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private long animationDuration;
private long animationStartTime;
private GestureDetector gestureDetector;
private DecelerateInterpolator interpolator = new DecelerateInterpolator();
private DecelerateInterpolator interpolator = new DecelerateInterpolator(1.5f);
private float pinchStartDistance = 0;
private float pinchStartScale = 1;
private float pinchCenterX;
@ -247,14 +247,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
public float getRadOffset() {
return radOffset;
}
public void setRadOffset(float value) {
radOffset = value;
}
public void setProgress(float value, boolean animated) {
if (!animated) {
animatedProgressValue = value;
@ -1396,26 +1388,39 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
setIndexToImage(centerImage, currentIndex);
setIndexToImage(rightImage, currentIndex + 1);
setIndexToImage(leftImage, currentIndex - 1);
for (int a = 0; a < 3; a++) {
checkProgress(a, false);
}
} else {
checkProgress(0, false);
if (prevIndex > currentIndex) {
ImageReceiver temp = rightImage;
rightImage = centerImage;
centerImage = leftImage;
leftImage = temp;
RadialProgressView tempProgress = radialProgressViews[0];
radialProgressViews[0] = radialProgressViews[2];
radialProgressViews[2] = tempProgress;
setIndexToImage(leftImage, currentIndex - 1);
radialProgressViews[0].setRadOffset(radialProgressViews[2].getRadOffset());
checkProgress(1, false);
checkProgress(2, false);
} else if (prevIndex < currentIndex) {
ImageReceiver temp = leftImage;
leftImage = centerImage;
centerImage = rightImage;
rightImage = temp;
radialProgressViews[0].setRadOffset(radialProgressViews[1].getRadOffset());
setIndexToImage(rightImage, currentIndex + 1);
}
}
for (int a = 0; a < 3; a++) {
checkProgress(a, false);
RadialProgressView tempProgress = radialProgressViews[0];
radialProgressViews[0] = radialProgressViews[1];
radialProgressViews[1] = tempProgress;
setIndexToImage(rightImage, currentIndex + 1);
checkProgress(1, false);
checkProgress(2, false);
}
}
}
@ -1970,23 +1975,25 @@ 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 && !changingPage) {
if (canZoom && ev.getPointerCount() == 2) {
if (!draggingDown) {
if (canZoom && ev.getPointerCount() == 2 && !changingPage) {
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;
@ -2033,7 +2040,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) {
@ -2217,7 +2224,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
float ai = -1;
if (System.currentTimeMillis() - animationStartTime < animationDuration) {
ai = interpolator.getInterpolation((float)(System.currentTimeMillis() - animationStartTime) / animationDuration);
if (ai >= 0.95f) {
if (ai >= 0.99f) {
ai = -1;
}
}
@ -2478,7 +2485,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (!canZoom || scale == 1.0f && (translationY != 0 || translationX != 0)) {
return false;
}
if (animationStartTime != 0) {
if (animationStartTime != 0 || animationInProgress != 0) {
return false;
}
if (scale == 1.0f) {

View file

@ -178,6 +178,16 @@ public class PopupNotificationActivity extends Activity implements NotificationC
MessagesController.getInstance().sendTyping(currentMessageObject.getDialogId(), classGuid);
}
}
@Override
public void onAttachButtonHidden() {
}
@Override
public void onAttachButtonShow() {
}
});
setContentView(R.layout.popup_notification_layout);

View file

@ -618,20 +618,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (totalItemCount == 0) {
return;
}
int height = 0;
View child = view.getChildAt(0);
if (child != null) {
if (firstVisibleItem == 0) {
height = AndroidUtilities.dp(88) + child.getTop();
}
if (actionBar.getExtraHeight() != height) {
actionBar.setExtraHeight(height, true);
needLayout();
}
}
checkListViewScroll();
}
});
@ -671,6 +658,23 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
}
private void checkListViewScroll() {
if (listView.getChildCount() == 0) {
return;
}
int height = 0;
View child = listView.getChildAt(0);
if (child != null) {
if (listView.getFirstVisiblePosition() == 0) {
height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0);
}
if (actionBar.getExtraHeight() != height) {
actionBar.setExtraHeight(height, true);
needLayout();
}
}
}
private void needLayout() {
FrameLayout.LayoutParams layoutParams;
if (listView != null) {
@ -697,8 +701,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff);
writeButton.setEnabled(diff > 0.02);
writeButton.setVisibility(diff <= 0.02 ? View.GONE : View.VISIBLE);
if (writeButton.getVisibility() == View.GONE) {
writeButton.clearAnimation();
}
}
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(avatarSize / 2));
@ -815,6 +821,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
updateRowsIds();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
checkListViewScroll();
}
}
} else if (id == NotificationCenter.blockedUsersDidLoaded) {
@ -831,6 +838,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
updateRowsIds();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
checkListViewScroll();
}
}
} else if (id == NotificationCenter.closeChats) {

View file

@ -373,7 +373,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
listView = new ListView(getParentActivity());
listView.setDivider(null);
listView.setDrawingCacheEnabled(false);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5));
@ -659,7 +658,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
View child = view.getChildAt(0);
if (child != null) {
if (firstVisibleItem == 0) {
height = AndroidUtilities.dp(88) + child.getTop();
height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0);
}
if (actionBar.getExtraHeight() != height) {
actionBar.setExtraHeight(height, true);
@ -885,8 +884,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff);
writeButton.setEnabled(diff > 0.02);
writeButton.setVisibility(diff <= 0.02 ? View.GONE : View.VISIBLE);
if (writeButton.getVisibility() == View.GONE) {
writeButton.clearAnimation();
}
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(avatarSize / 2));
layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
@ -936,7 +937,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
photo = user.photo.photo_small;
photoBig = user.photo.photo_big;
}
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user, true));
AvatarDrawable avatarDrawable = new AvatarDrawable(user, true);
avatarDrawable.setColor(0xff5c98cd);
avatarImage.setImage(photo, "50_50", avatarDrawable);
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));

View file

@ -54,6 +54,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
public static interface ChatActivityEnterViewDelegate {
public abstract void onMessageSend();
public abstract void needSendTyping();
public abstract void onAttachButtonHidden();
public abstract void onAttachButtonShow();
}
private EditText messsageEditText;
@ -136,6 +138,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
attachButton = (FrameLayout) containerView.findViewById(R.id.chat_attach_button);
if (attachButton != null) {
ViewProxy.setPivotX(attachButton, AndroidUtilities.dp(48));
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(50);
messsageEditText.setLayoutParams(layoutParams);
}
sendButton = (ImageButton) containerView.findViewById(R.id.chat_send_button);
@ -380,14 +385,17 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
public void onAnimationEnd(Object animation) {
if (runningAnimation2.equals(animation)) {
attachButton.setVisibility(View.GONE);
attachButton.clearAnimation();
}
}
});
runningAnimation2.start();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(2);
layoutParams.rightMargin = AndroidUtilities.dp(0);
messsageEditText.setLayoutParams(layoutParams);
delegate.onAttachButtonHidden();
}
sendButton.setVisibility(View.VISIBLE);
@ -409,7 +417,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
public void onAnimationEnd(Object animation) {
if (runningAnimation.equals(animation)) {
sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.GONE);
audioSendButton.clearAnimation();
runningAnimation = null;
runningAnimationType = 0;
}
@ -424,9 +433,15 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
ViewProxy.setScaleY(sendButton, 1.0f);
ViewProxy.setAlpha(sendButton, 1.0f);
sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.GONE);
audioSendButton.clearAnimation();
if (attachButton != null) {
attachButton.setVisibility(View.GONE);
attachButton.clearAnimation();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(0);
messsageEditText.setLayoutParams(layoutParams);
}
}
}
@ -456,8 +471,10 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
runningAnimation2.start();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(2);
layoutParams.rightMargin = AndroidUtilities.dp(50);
messsageEditText.setLayoutParams(layoutParams);
delegate.onAttachButtonShow();
}
audioSendButton.setVisibility(View.VISIBLE);
@ -478,7 +495,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
@Override
public void onAnimationEnd(Object animation) {
if (runningAnimation.equals(animation)) {
sendButton.setVisibility(View.INVISIBLE);
sendButton.setVisibility(View.GONE);
sendButton.clearAnimation();
audioSendButton.setVisibility(View.VISIBLE);
runningAnimation = null;
runningAnimationType = 0;
@ -493,10 +511,14 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
ViewProxy.setScaleX(audioSendButton, 1.0f);
ViewProxy.setScaleY(audioSendButton, 1.0f);
ViewProxy.setAlpha(audioSendButton, 1.0f);
sendButton.setVisibility(View.INVISIBLE);
sendButton.setVisibility(View.GONE);
sendButton.clearAnimation();
audioSendButton.setVisibility(View.VISIBLE);
if (attachButton != null) {
attachButton.setVisibility(View.VISIBLE);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(50);
messsageEditText.setLayoutParams(layoutParams);
}
}
}

View file

@ -17,6 +17,7 @@ import android.widget.AbsListView;
import android.widget.ListAdapter;
import android.widget.ListView;
import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.ui.Adapters.BaseSectionsAdapter;
@ -181,7 +182,7 @@ public class SectionsListView extends ListView implements AbsListView.OnScrollLi
for (View header : headers) {
int saveCount = canvas.save();
int top = (Integer)header.getTag();
canvas.translate(0, top);
canvas.translate(LocaleController.isRTL ? getWidth() - header.getWidth() : 0, top);
canvas.clipRect(0, 0, getWidth(), header.getMeasuredHeight());
if (top < 0) {
canvas.saveLayerAlpha(0, top, header.getWidth(), top + canvas.getHeight(), (int)(255 * (1.0f + (float)top / (float)header.getMeasuredHeight())), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);

View file

@ -297,7 +297,11 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
loadingFileObject = null;
loadingFile = null;
loadingSize = null;
try {
backgroundImage.setImageURI(Uri.fromFile(f));
} catch (Throwable e) {
FileLog.e("tmessages", e);
}
backgroundImage.setBackgroundColor(0);
selectedColor = 0;
doneButton.setEnabled(true);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
TMessagesProj/src/main/res/drawable-hdpi/ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
TMessagesProj/src/main/res/drawable-mdpi/ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
TMessagesProj/src/main/res/drawable-xhdpi/ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -87,7 +87,7 @@
android:background="@drawable/compose_panel"
android:orientation="horizontal">
<FrameLayout
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
@ -197,7 +197,7 @@
</org.telegram.ui.Views.FrameLayoutFixed>
</FrameLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
<FrameLayout
android:layout_width="48dp"

View file

@ -1,11 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="6dp"
android:id="@+id/progress">
</ProgressBar>
</RelativeLayout>

View file

@ -29,7 +29,7 @@
android:background="@drawable/compose_panel"
android:orientation="horizontal">
<FrameLayout
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
@ -131,7 +131,7 @@
</org.telegram.ui.Views.FrameLayoutFixed>
</FrameLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
<FrameLayout
android:layout_width="48dp"

View file

@ -143,6 +143,7 @@
<string name="ReplyToUser">Responder a %1$s</string>
<string name="NotificationMessagesPeopleDisplayOrder">%1$s %2$s</string>
<!--contacts view-->
<string name="NewMessageTitle">Nuevo mensaje</string>
<string name="SelectContact">Elegir contacto</string>
<string name="NoContacts">Aún sin contactos</string>
<string name="InviteText">Oye, cambiémonos a Telegram: http://telegram.org/dl2</string>
@ -308,7 +309,7 @@
<string name="LastSeenHelp">Elige quién puede ver tu última conexión.</string>
<string name="LastSeenTitle">¿Quién puede ver tu última conexión?</string>
<string name="AddExceptions">Añadir excepciones</string>
<string name="CustomHelp">Importante: no podrás ver la última conexión de las personas con las que no compartes la tuya. En su lugar, se mostrarán conexiones indeterminadas (recientemente, hace unos días, hace unas semanas).</string>
<string name="CustomHelp">Importante: No podrás ver la última conexión de las personas con las que no compartes la tuya. En su lugar, se mostrarán conexiones indeterminadas (recientemente, hace unos días, hace unas semanas).</string>
<string name="AlwaysShareWith">Compartir siempre con</string>
<string name="NeverShareWith">Nunca compartir con</string>
<string name="CustomShareSettingsHelp">Estos ajustes anularán los valores de arriba.</string>
@ -399,6 +400,7 @@
<string name="AreYouSureSecretChat">¿Quieres iniciar un chat secreto?</string>
<string name="AreYouSureRegistration">¿Quieres cancelar el registro?</string>
<string name="AreYouSureClearHistory">¿Quieres eliminar el historial?</string>
<string name="AreYouSureDeleteMessages">¿Quieres eliminar %1$s?</string>
<string name="SendMessagesToGroup">¿Enviar mensajes a %1$s?</string>
<string name="ForwardMessagesToGroup">¿Reenviar mensajes a %1$s?</string>
<string name="FeatureUnavailable">Lo siento, esta característica no está disponible en tu país actualmente.</string>