Commit b56e3352 authored by Grigory Fedorov's avatar Grigory Fedorov

Click on Avatar in contact list leads to contact info screen.

parent 3c495c64
...@@ -8,7 +8,6 @@ import android.view.ContextMenu.ContextMenuInfo; ...@@ -8,7 +8,6 @@ import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
...@@ -49,7 +48,7 @@ import java.util.Collection; ...@@ -49,7 +48,7 @@ import java.util.Collection;
public class ContactListFragment extends Fragment implements OnAccountChangedListener, public class ContactListFragment extends Fragment implements OnAccountChangedListener,
OnContactChangedListener, OnChatChangedListener, OnItemClickListener, OnContactChangedListener, OnChatChangedListener, OnItemClickListener,
OnContactListChangedListener, OnClickListener, GroupedContactAdapter.OnAccountClickListener { OnContactListChangedListener, View.OnClickListener, GroupedContactAdapter.OnClickListener {
private ContactListAdapter adapter; private ContactListAdapter adapter;
...@@ -187,7 +186,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -187,7 +186,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
final int text; final int text;
final int button; final int button;
final ContactListState state; final ContactListState state;
final OnClickListener listener; final View.OnClickListener listener;
if (isFilterEnabled) { if (isFilterEnabled) {
if (commonState == CommonState.online) { if (commonState == CommonState.online) {
state = ContactListState.online; state = ContactListState.online;
...@@ -203,7 +202,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -203,7 +202,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
state = ContactListState.online; state = ContactListState.online;
text = R.string.application_state_no_online; text = R.string.application_state_no_online;
button = R.string.application_action_no_online; button = R.string.application_action_no_online;
listener = new OnClickListener() { listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
SettingsManager.setContactsShowOffline(true); SettingsManager.setContactsShowOffline(true);
...@@ -214,7 +213,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -214,7 +213,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
state = ContactListState.online; state = ContactListState.online;
text = R.string.application_state_no_contacts; text = R.string.application_state_no_contacts;
button = R.string.application_action_no_contacts; button = R.string.application_action_no_contacts;
listener = new OnClickListener() { listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startActivity(ContactAdd.createIntent(getActivity())); startActivity(ContactAdd.createIntent(getActivity()));
...@@ -234,7 +233,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -234,7 +233,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
state = ContactListState.offline; state = ContactListState.offline;
text = R.string.application_state_waiting; text = R.string.application_state_waiting;
button = R.string.application_action_waiting; button = R.string.application_action_waiting;
listener = new OnClickListener() { listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
ConnectionManager.getInstance().updateConnections(true); ConnectionManager.getInstance().updateConnections(true);
...@@ -244,7 +243,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -244,7 +243,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
state = ContactListState.offline; state = ContactListState.offline;
text = R.string.application_state_offline; text = R.string.application_state_offline;
button = R.string.application_action_offline; button = R.string.application_action_offline;
listener = new OnClickListener() { listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
AccountManager.getInstance().setStatus( AccountManager.getInstance().setStatus(
...@@ -255,7 +254,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -255,7 +254,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
state = ContactListState.offline; state = ContactListState.offline;
text = R.string.application_state_disabled; text = R.string.application_state_disabled;
button = R.string.application_action_disabled; button = R.string.application_action_disabled;
listener = new OnClickListener() { listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startActivity(AccountList.createIntent(getActivity())); startActivity(AccountList.createIntent(getActivity()));
...@@ -265,7 +264,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -265,7 +264,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
state = ContactListState.offline; state = ContactListState.offline;
text = R.string.application_state_empty; text = R.string.application_state_empty;
button = R.string.application_action_empty; button = R.string.application_action_empty;
listener = new OnClickListener() { listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startActivity(AccountAdd.createIntent(getActivity())); startActivity(AccountAdd.createIntent(getActivity()));
...@@ -403,7 +402,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -403,7 +402,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
} }
@Override @Override
public void onAccountClick(View view, final String account) { public void onAccountMenuClick(View view, final String account) {
PopupMenu popup = new PopupMenu(getActivity(), view); PopupMenu popup = new PopupMenu(getActivity(), view);
popup.inflate(R.menu.account); popup.inflate(R.menu.account);
ContextMenuHelper.setUpAccountMenu(getActivity(), adapter, account, popup.getMenu()); ContextMenuHelper.setUpAccountMenu(getActivity(), adapter, account, popup.getMenu());
......
...@@ -18,7 +18,6 @@ import android.app.Activity; ...@@ -18,7 +18,6 @@ import android.app.Activity;
import android.os.Handler; import android.os.Handler;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ListView;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
...@@ -94,8 +93,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl ...@@ -94,8 +93,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
private final OnContactListChangedListener listener; private final OnContactListChangedListener listener;
public ContactListAdapter(Activity activity, OnContactListChangedListener listener, public ContactListAdapter(Activity activity, OnContactListChangedListener listener,
GroupedContactAdapter.OnAccountClickListener onAccountClickListener) { OnClickListener onClickListener) {
super(activity, onAccountClickListener); super(activity, onClickListener);
this.listener = listener; this.listener = listener;
handler = new Handler(); handler = new Handler();
refreshLock = new Object(); refreshLock = new Object();
......
...@@ -22,11 +22,10 @@ import android.view.LayoutInflater; ...@@ -22,11 +22,10 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountItem; import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
...@@ -39,6 +38,7 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -39,6 +38,7 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.Group; import com.xabber.android.data.roster.Group;
import com.xabber.android.data.roster.GroupManager; import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.ShowOfflineMode; import com.xabber.android.data.roster.ShowOfflineMode;
import com.xabber.android.ui.ContactViewer;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -96,12 +96,12 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -96,12 +96,12 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
private int[] accountGroupColors; private int[] accountGroupColors;
private final int[] accountSubgroupColors; private final int[] accountSubgroupColors;
private final int activeChatsColor; private final int activeChatsColor;
private final OnAccountClickListener onAccountClickListener; private final OnClickListener onClickListener;
final ArrayList<BaseEntity> baseEntities = new ArrayList<>(); final ArrayList<BaseEntity> baseEntities = new ArrayList<>();
protected Locale locale = Locale.getDefault(); protected Locale locale = Locale.getDefault();
public GroupedContactAdapter(Activity activity, OnAccountClickListener onAccountClickListener) { public GroupedContactAdapter(Activity activity, OnClickListener onClickListener) {
this.activity = activity; this.activity = activity;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
...@@ -113,7 +113,7 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -113,7 +113,7 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
accountSubgroupColors = resources.getIntArray(R.array.account_50); accountSubgroupColors = resources.getIntArray(R.array.account_50);
activeChatsColor = resources.getColor(R.color.color_primary_light); activeChatsColor = resources.getColor(R.color.color_primary_light);
this.onAccountClickListener = onAccountClickListener; this.onClickListener = onClickListener;
} }
@Override @Override
...@@ -240,7 +240,7 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -240,7 +240,7 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() { viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
onAccountClickListener.onAccountClick(v, account); onClickListener.onAccountMenuClick(v, account);
} }
}); });
...@@ -260,6 +260,19 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -260,6 +260,19 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
viewHolder.status.setText(statusText); viewHolder.status.setText(statusText);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user = AccountManager.getInstance().getAccount(account).getRealJid();
if (user == null) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
} else {
activity.startActivity(ContactViewer.createIntent(activity, account, user));
}
}
});
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel()); viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode(); ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
...@@ -346,7 +359,7 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -346,7 +359,7 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
viewHolder = (ContactViewHolder) view.getTag(); viewHolder = (ContactViewHolder) view.getTag();
} }
AbstractContact abstractContact = (AbstractContact) getItem(position); final AbstractContact abstractContact = (AbstractContact) getItem(position);
if (abstractContact.isConnected()) { if (abstractContact.isConnected()) {
viewHolder.offlineShadow.setVisibility(View.GONE); viewHolder.offlineShadow.setVisibility(View.GONE);
...@@ -364,6 +377,14 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -364,6 +377,14 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
viewHolder.avatar.setVisibility(View.GONE); viewHolder.avatar.setVisibility(View.GONE);
} }
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(ContactViewer.createIntent(activity,
abstractContact.getAccount(), abstractContact.getUser()));
}
});
viewHolder.name.setText(abstractContact.getName()); viewHolder.name.setText(abstractContact.getName());
String statusText; String statusText;
...@@ -652,8 +673,8 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat ...@@ -652,8 +673,8 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
} }
} }
public interface OnAccountClickListener { public interface OnClickListener {
void onAccountClick(View view, String account); void onAccountMenuClick(View view, String account);
} }
} }
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