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