Commit 9d903829 authored by Grigory Fedorov's avatar Grigory Fedorov

Chat incoming animation returned. Some small simplifications.

parent 70556309
......@@ -32,7 +32,6 @@ import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.archive.MessageArchiveManager;
import com.xabber.android.data.extension.attention.AttentionManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageManager;
......@@ -56,10 +55,8 @@ import java.util.HashSet;
*/
public class ChatViewer extends ManagedActivity implements OnChatChangedListener,
OnContactChangedListener, OnAccountChangedListener, ViewPager.OnPageChangeListener,
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener, View.OnClickListener,
ChatViewerFragment.ChatViewerFragmentListener
{
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener,
ChatViewerFragment.ChatViewerFragmentListener {
/**
* Attention request.
......@@ -154,7 +151,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
if (actionWithAccount != null && actionWithUser != null) {
updateActionBar(actionWithAccount, actionWithUser);
updateActionBar(actionWithAccount);
}
}
......@@ -191,7 +188,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
selectPage(account, user, false);
}
private void selectPage(String account, String user, boolean smoothScroll) {
......@@ -265,7 +261,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override
public void onChatChanged(final String account, final String user, final boolean incoming) {
String currentAccount = null;
String currentUser = null;
AbstractChat chatByPageNumber = chatViewerAdapter.getChatByPageNumber(viewPager.getCurrentItem());
......@@ -285,17 +280,14 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
for (ChatViewerFragment chat : registeredChats) {
if (chat.isEqual(account, user)) {
chat.updateChat();
chat.playIncomingAnimation();
}
}
}
if (actionWithAccount != null && actionWithAccount.equals(account)
&& actionWithUser != null && actionWithUser.equals(user)) {
updateActionBar(account, user);
if (incoming) {
// contactTitleActionBarInflater.playIncomingAnimation();
}
updateActionBar(account);
}
}
......@@ -305,7 +297,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
updateRegisteredRecentChatsFragments();
if (actionWithAccount != null && actionWithUser != null) {
updateActionBar(actionWithAccount, actionWithUser);
updateActionBar(actionWithAccount);
}
}
......@@ -315,7 +307,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
updateRegisteredRecentChatsFragments();
if (actionWithAccount != null && actionWithUser != null) {
updateActionBar(actionWithAccount, actionWithUser);
updateActionBar(actionWithAccount);
}
}
......@@ -363,7 +355,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return;
}
updateActionBar(actionWithAccount, actionWithUser);
updateActionBar(actionWithAccount);
MessageManager.getInstance().setVisibleChat(actionWithAccount, actionWithUser);
......@@ -374,7 +366,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
NotificationManager.getInstance().removeMessageNotification(actionWithAccount, actionWithUser);
}
private void updateActionBar(String account, String user) {
private void updateActionBar(String account) {
statusBarPainter.updateWithAccountName(account);
}
......@@ -499,21 +491,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.avatar) {
showContactInfo();
}
}
private void showContactInfo() {
if (MUCManager.getInstance().hasRoom(actionWithAccount, actionWithUser)) {
startActivity(ContactViewer.createIntent(this, actionWithAccount, actionWithUser));
} else {
startActivity(ContactEditor.createIntent(this, actionWithAccount, actionWithUser));
}
}
@Override
public void onCloseChat() {
close();
......
......@@ -19,6 +19,8 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
......@@ -75,6 +77,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
private Toolbar toolbar;
private ChatViewerFragmentListener listener;
private Animation shakeAnimation = null;
public static ChatViewerFragment newInstance(String account, String user) {
ChatViewerFragment fragment = new ChatViewerFragment();
......@@ -449,13 +452,6 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
skipOnTextChanges = false;
}
public void scrollChat() {
int size = listView.getCount();
if (size > 0) {
listView.setSelection(size - 1);
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
registerForContextMenu(listView);
......@@ -620,4 +616,11 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
public interface ChatViewerFragmentListener {
void onCloseChat();
}
public void playIncomingAnimation() {
if (shakeAnimation == null) {
shakeAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
}
toolbar.findViewById(R.id.name_holder).startAnimation(shakeAnimation);
}
}
......@@ -4,8 +4,6 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import com.xabber.android.data.roster.AbstractContact;
......@@ -16,7 +14,7 @@ public class ContactTitleActionBarInflater {
private final ActionBarActivity activity;
private View actionBarView;
private Animation shakeAnimation = null;
private ActionBarPainter actionBarPainter;
......@@ -48,34 +46,6 @@ public class ContactTitleActionBarInflater {
ContactTitleInflater.updateTitle(actionBarView, activity, abstractContact);
}
public void restoreDefaultTitleView(String title) {
actionBarPainter.restore();
activity.getSupportActionBar().setDisplayShowCustomEnabled(false);
activity.getSupportActionBar().setDisplayShowTitleEnabled(true);
actionBarView.setVisibility(View.GONE);
activity.setTitle(title);
}
public void playIncomingAnimation() {
if (shakeAnimation == null) {
shakeAnimation = AnimationUtils.loadAnimation(activity, R.anim.shake);
}
actionBarView.findViewById(R.id.name_holder).startAnimation(shakeAnimation);
}
public void setOnClickListener(View.OnClickListener onClickListener) {
actionBarView.setOnClickListener(onClickListener);
}
public void setOnAvatarClickListener(View.OnClickListener onClickListener) {
actionBarView.findViewById(R.id.avatar).setOnClickListener(onClickListener);
}
public void setName(String name) {
((TextView) actionBarView.findViewById(R.id.name)).setText(name);
}
public void setStatusText(String user) {
((TextView) actionBarView.findViewById(R.id.status_text)).setText(user);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment