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; ...@@ -32,7 +32,6 @@ import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity; import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.archive.MessageArchiveManager; import com.xabber.android.data.extension.archive.MessageArchiveManager;
import com.xabber.android.data.extension.attention.AttentionManager; 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.intent.EntityIntentBuilder;
import com.xabber.android.data.message.AbstractChat; import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageManager; import com.xabber.android.data.message.MessageManager;
...@@ -56,10 +55,8 @@ import java.util.HashSet; ...@@ -56,10 +55,8 @@ import java.util.HashSet;
*/ */
public class ChatViewer extends ManagedActivity implements OnChatChangedListener, public class ChatViewer extends ManagedActivity implements OnChatChangedListener,
OnContactChangedListener, OnAccountChangedListener, ViewPager.OnPageChangeListener, OnContactChangedListener, OnAccountChangedListener, ViewPager.OnPageChangeListener,
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener, View.OnClickListener, ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener,
ChatViewerFragment.ChatViewerFragmentListener {
ChatViewerFragment.ChatViewerFragmentListener
{
/** /**
* Attention request. * Attention request.
...@@ -154,7 +151,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -154,7 +151,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
} }
if (actionWithAccount != null && actionWithUser != null) { if (actionWithAccount != null && actionWithUser != null) {
updateActionBar(actionWithAccount, actionWithUser); updateActionBar(actionWithAccount);
} }
} }
...@@ -191,7 +188,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -191,7 +188,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
} }
selectPage(account, user, false); selectPage(account, user, false);
} }
private void selectPage(String account, String user, boolean smoothScroll) { private void selectPage(String account, String user, boolean smoothScroll) {
...@@ -265,7 +261,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -265,7 +261,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override @Override
public void onChatChanged(final String account, final String user, final boolean incoming) { public void onChatChanged(final String account, final String user, final boolean incoming) {
String currentAccount = null; String currentAccount = null;
String currentUser = null; String currentUser = null;
AbstractChat chatByPageNumber = chatViewerAdapter.getChatByPageNumber(viewPager.getCurrentItem()); AbstractChat chatByPageNumber = chatViewerAdapter.getChatByPageNumber(viewPager.getCurrentItem());
...@@ -285,17 +280,14 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -285,17 +280,14 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
for (ChatViewerFragment chat : registeredChats) { for (ChatViewerFragment chat : registeredChats) {
if (chat.isEqual(account, user)) { if (chat.isEqual(account, user)) {
chat.updateChat(); chat.playIncomingAnimation();
} }
} }
} }
if (actionWithAccount != null && actionWithAccount.equals(account) if (actionWithAccount != null && actionWithAccount.equals(account)
&& actionWithUser != null && actionWithUser.equals(user)) { && actionWithUser != null && actionWithUser.equals(user)) {
updateActionBar(account, user); updateActionBar(account);
if (incoming) {
// contactTitleActionBarInflater.playIncomingAnimation();
}
} }
} }
...@@ -305,7 +297,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -305,7 +297,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
updateRegisteredRecentChatsFragments(); updateRegisteredRecentChatsFragments();
if (actionWithAccount != null && actionWithUser != null) { if (actionWithAccount != null && actionWithUser != null) {
updateActionBar(actionWithAccount, actionWithUser); updateActionBar(actionWithAccount);
} }
} }
...@@ -315,7 +307,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -315,7 +307,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
updateRegisteredRecentChatsFragments(); updateRegisteredRecentChatsFragments();
if (actionWithAccount != null && actionWithUser != null) { if (actionWithAccount != null && actionWithUser != null) {
updateActionBar(actionWithAccount, actionWithUser); updateActionBar(actionWithAccount);
} }
} }
...@@ -363,7 +355,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -363,7 +355,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return; return;
} }
updateActionBar(actionWithAccount, actionWithUser); updateActionBar(actionWithAccount);
MessageManager.getInstance().setVisibleChat(actionWithAccount, actionWithUser); MessageManager.getInstance().setVisibleChat(actionWithAccount, actionWithUser);
...@@ -374,7 +366,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -374,7 +366,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
NotificationManager.getInstance().removeMessageNotification(actionWithAccount, actionWithUser); NotificationManager.getInstance().removeMessageNotification(actionWithAccount, actionWithUser);
} }
private void updateActionBar(String account, String user) { private void updateActionBar(String account) {
statusBarPainter.updateWithAccountName(account); statusBarPainter.updateWithAccountName(account);
} }
...@@ -499,21 +491,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -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 @Override
public void onCloseChat() { public void onCloseChat() {
close(); close();
......
...@@ -19,6 +19,8 @@ import android.view.MenuInflater; ...@@ -19,6 +19,8 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
...@@ -75,6 +77,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -75,6 +77,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
private Toolbar toolbar; private Toolbar toolbar;
private ChatViewerFragmentListener listener; private ChatViewerFragmentListener listener;
private Animation shakeAnimation = null;
public static ChatViewerFragment newInstance(String account, String user) { public static ChatViewerFragment newInstance(String account, String user) {
ChatViewerFragment fragment = new ChatViewerFragment(); ChatViewerFragment fragment = new ChatViewerFragment();
...@@ -449,13 +452,6 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -449,13 +452,6 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
skipOnTextChanges = false; skipOnTextChanges = false;
} }
public void scrollChat() {
int size = listView.getCount();
if (size > 0) {
listView.setSelection(size - 1);
}
}
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
registerForContextMenu(listView); registerForContextMenu(listView);
...@@ -620,4 +616,11 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -620,4 +616,11 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
public interface ChatViewerFragmentListener { public interface ChatViewerFragmentListener {
void onCloseChat(); 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; ...@@ -4,8 +4,6 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView; import android.widget.TextView;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
...@@ -16,7 +14,7 @@ public class ContactTitleActionBarInflater { ...@@ -16,7 +14,7 @@ public class ContactTitleActionBarInflater {
private final ActionBarActivity activity; private final ActionBarActivity activity;
private View actionBarView; private View actionBarView;
private Animation shakeAnimation = null;
private ActionBarPainter actionBarPainter; private ActionBarPainter actionBarPainter;
...@@ -48,34 +46,6 @@ public class ContactTitleActionBarInflater { ...@@ -48,34 +46,6 @@ public class ContactTitleActionBarInflater {
ContactTitleInflater.updateTitle(actionBarView, activity, abstractContact); 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) { public void setStatusText(String user) {
((TextView) actionBarView.findViewById(R.id.status_text)).setText(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