Bug fixes

This commit is contained in:
DrKLO 2014-11-19 13:32:27 +03:00
parent ea8760f9a2
commit ba4cf583b4
8 changed files with 120 additions and 40 deletions

View file

@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 386
versionName "2.0.0"
versionCode 388
versionName "2.0.1"
}
}

View file

@ -850,6 +850,8 @@ public class ContactsController {
final HashMap<Integer, TLRPC.User> usersDict = new HashMap<Integer, TLRPC.User>();
final boolean isEmpty = contactsArr.isEmpty();
if (!contacts.isEmpty()) {
for (int a = 0; a < contactsArr.size(); a++) {
TLRPC.TL_contact contact = contactsArr.get(a);
@ -1003,6 +1005,12 @@ public class ContactsController {
updateUnregisteredContacts(contactsArr);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.contactsDidLoaded);
if (from != 1 && !isEmpty) {
saveContactsLoadTime();
} else {
reloadContactsStatusesMaybe();
}
}
});
@ -1037,6 +1045,27 @@ public class ContactsController {
});
}
private void reloadContactsStatusesMaybe() {
try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
long lastReloadStatusTime = preferences.getLong("lastReloadStatusTime", 0);
if (lastReloadStatusTime < System.currentTimeMillis() - 1000 * 60 * 60 * 24) {
reloadContactsStatuses();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
private void saveContactsLoadTime() {
try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
preferences.edit().putLong("lastReloadStatusTime", System.currentTimeMillis()).commit();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
private void updateUnregisteredContacts(final ArrayList<TLRPC.TL_contact> contactsArr) {
final HashMap<String, TLRPC.TL_contact> contactsPhonesShort = new HashMap<String, TLRPC.TL_contact>();
@ -1586,6 +1615,7 @@ public class ContactsController {
}
public void reloadContactsStatuses() {
saveContactsLoadTime();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
final SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("needGetStatuses", true).commit();

View file

@ -560,6 +560,10 @@ public class ActionBarLayout extends FrameLayout {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
}
ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
if (parent != null) {
parent.removeView(fragment.actionBar);
}
containerViewBack.addView(fragment.actionBar);
fragment.actionBar.setTitleOverlayText(titleOverlayText);
}
@ -698,6 +702,10 @@ public class ActionBarLayout extends FrameLayout {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(previousFragment.actionBar);
}
containerView.addView(previousFragment.actionBar);
previousFragment.actionBar.setTitleOverlayText(titleOverlayText);
}

View file

@ -165,6 +165,9 @@ public class DrawerLayoutContainer extends FrameLayout {
}
public void openDrawer(boolean fast) {
if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) {
AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus());
}
cancelCurrentAnimation();
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
animatorSet.playTogether(

View file

@ -506,6 +506,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat != null) {
MediaController.getInstance().stopMediaObserver();
}
if (currentUser != null) {
MessagesController.getInstance().cancelLoadFullUser(currentUser.id);
}
if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
@ -996,38 +999,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
if (currentEncryptedChat != null) {
emptyView.setVisibility(View.INVISIBLE);
View secretChatPlaceholder = contentView.findViewById(R.id.secret_placeholder);
secretChatPlaceholder.setVisibility(View.VISIBLE);
if (isCustomTheme) {
secretChatPlaceholder.setBackgroundResource(R.drawable.system_black);
} else {
secretChatPlaceholder.setBackgroundResource(R.drawable.system_blue);
}
secretViewStatusTextView = (TextView) contentView.findViewById(R.id.invite_text);
secretChatPlaceholder.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12));
View v = contentView.findViewById(R.id.secret_placeholder);
v.setVisibility(View.VISIBLE);
if (currentEncryptedChat.admin_id == UserConfig.getClientUserId()) {
if (currentUser.first_name.length() > 0) {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, currentUser.first_name));
} else {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, currentUser.last_name));
}
} else {
if (currentUser.first_name.length() > 0) {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleIncoming", R.string.EncryptedPlaceholderTitleIncoming, currentUser.first_name));
} else {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleIncoming", R.string.EncryptedPlaceholderTitleIncoming, currentUser.last_name));
}
}
updateSecretStatus();
}
if (isCustomTheme) {
progressViewInner.setBackgroundResource(R.drawable.system_loader2);
emptyView.setBackgroundResource(R.drawable.system_black);
@ -1261,6 +1232,38 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatActivityEnterView.setContainerView(getParentActivity(), fragmentView);
chatActivityEnterView.addToAttachLayout(menuItem);
if (currentEncryptedChat != null) {
emptyView.setVisibility(View.INVISIBLE);
View secretChatPlaceholder = contentView.findViewById(R.id.secret_placeholder);
secretChatPlaceholder.setVisibility(View.VISIBLE);
if (isCustomTheme) {
secretChatPlaceholder.setBackgroundResource(R.drawable.system_black);
} else {
secretChatPlaceholder.setBackgroundResource(R.drawable.system_blue);
}
secretViewStatusTextView = (TextView) contentView.findViewById(R.id.invite_text);
secretChatPlaceholder.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12));
View v = contentView.findViewById(R.id.secret_placeholder);
v.setVisibility(View.VISIBLE);
if (currentEncryptedChat.admin_id == UserConfig.getClientUserId()) {
if (currentUser.first_name.length() > 0) {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, currentUser.first_name));
} else {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, currentUser.last_name));
}
} else {
if (currentUser.first_name.length() > 0) {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleIncoming", R.string.EncryptedPlaceholderTitleIncoming, currentUser.first_name));
} else {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleIncoming", R.string.EncryptedPlaceholderTitleIncoming, currentUser.last_name));
}
}
updateSecretStatus();
}
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
@ -2544,6 +2547,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
cell.setAllowedToSetPhoto(true);
}
}
if (currentUser != null) {
MessagesController.getInstance().loadFullUser(MessagesController.getInstance().getUser(currentUser.id), classGuid);
}
}
private void updateBottomOverlay() {

View file

@ -223,6 +223,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
dialogsAdapter.setOpenedDialogId(openedDialogId);
}
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), !onlySelect);
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
@Override
@ -527,9 +530,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.dialogsNeedReload) {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (messagesListView != null) {
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
searchEmptyView.setVisibility(View.GONE);
@ -537,14 +537,33 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
messagesListView.setEmptyView(progressView);
} else {
if (searching && searchWas) {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
messagesListView.setEmptyView(searchEmptyView);
emptyView.setVisibility(View.GONE);
} else {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
messagesListView.setEmptyView(emptyView);
searchEmptyView.setVisibility(View.GONE);
}
progressView.setVisibility(View.GONE);
}
} else {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
}
}
} else if (id == NotificationCenter.emojiDidLoaded) {
if (messagesListView != null) {
@ -569,7 +588,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else {
openedDialogId = dialog_id;
}
if (dialogsAdapter != null) {
dialogsAdapter.setOpenedDialogId(openedDialogId);
}
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
}
}

View file

@ -695,6 +695,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
}
public void setFieldText(String text) {
if (messsageEditText == null) {
return;
}
ignoreTextChange = true;
messsageEditText.setText(text);
messsageEditText.setSelection(messsageEditText.getText().length());

View file

@ -17,6 +17,7 @@ import android.widget.AbsListView;
import android.widget.ListAdapter;
import android.widget.ListView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.ui.Adapters.BaseSectionsAdapter;
@ -112,7 +113,12 @@ public class SectionsListView extends ListView implements AbsListView.OnScrollLi
header.setTag(-header.getHeight());
} else if (pos == count - 2) {
View child = getChildAt(itemNum - firstVisibleItem);
int headerTop = child.getTop();
int headerTop = 0;
if (child != null) {
headerTop = child.getTop();
} else {
headerTop = -AndroidUtilities.dp(100);
}
if (headerTop < 0) {
header.setTag(headerTop);
} else {
@ -124,7 +130,9 @@ public class SectionsListView extends ListView implements AbsListView.OnScrollLi
itemNum += count - mAdapter.getPositionInSectionForPosition(firstVisibleItem);
} else {
View child = getChildAt(itemNum - firstVisibleItem);
if (child != null) {
header.setTag(child.getTop());
}
itemNum += count;
}
}