Commit 443c213e authored by Grigory Fedorov's avatar Grigory Fedorov

ContactViewerFragment made independent from ContactViewer and renamed to...

ContactViewerFragment made independent from ContactViewer and renamed to ContactVcardViewerFragment.
parent 6d6e724b
......@@ -17,7 +17,6 @@ import com.xabber.android.data.extension.capability.CapabilitiesManager;
import com.xabber.android.data.extension.capability.ClientInfo;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.Address;
import com.xabber.xmpp.vcard.AddressProperty;
......@@ -34,13 +33,12 @@ import com.xabber.xmpp.vcard.VCardProperty;
import java.util.ArrayList;
import java.util.List;
public class ContactViewerFragment extends Fragment {
public class ContactVcardViewerFragment extends Fragment {
private LinearLayout xmppItems;
private LinearLayout contactInfoItems;
String account;
String bareAddress;
private TextView contactNameView;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -52,17 +50,11 @@ public class ContactViewerFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.contact_viewer_fragment, container, false);
View view = inflater.inflate(R.layout.contact_vcard_viewer_fragment, container, false);
xmppItems = (LinearLayout) view.findViewById(R.id.xmpp_items);
contactInfoItems = (LinearLayout) view.findViewById(R.id.contact_info_items);
View contactTitleView = ((ContactViewer) getActivity()).getContactTitleView();
contactTitleView.findViewById(R.id.status_icon).setVisibility(View.GONE);
contactTitleView.findViewById(R.id.status_text).setVisibility(View.GONE);
contactNameView = (TextView) contactTitleView.findViewById(R.id.name);
return view;
}
......@@ -86,12 +78,10 @@ public class ContactViewerFragment extends Fragment {
this.account = account;
this.bareAddress = bareAddress;
contactNameView.setText(RosterManager.getInstance().getBestContact(account, bareAddress).getName());
xmppItems.removeAllViews();
View jabberIdView = createItemView(xmppItems,
getString(R.string.contact_viewer_jid), bareAddress, R.drawable.ic_vcard_xmpp_24dp);
View jabberIdView = createItemView(xmppItems, getString(R.string.contact_viewer_jid),
bareAddress, R.drawable.ic_vcard_xmpp_24dp);
if (jabberIdView != null) {
xmppItems.addView(jabberIdView);
......@@ -124,7 +114,6 @@ public class ContactViewerFragment extends Fragment {
} else {
client = client + "/" + type;
}
}
}
......@@ -179,7 +168,6 @@ public class ContactViewerFragment extends Fragment {
addItem(birthDayList, contactInfoItems, getString(R.string.vcard_birth_date), vCard.getField(VCardProperty.BDAY));
addItemGroup(birthDayList, contactInfoItems, R.drawable.ic_vcard_birthday_24dp);
addOrganizationInfo(vCard);
List<View> webList = new ArrayList<>();
......@@ -259,7 +247,6 @@ public class ContactViewerFragment extends Fragment {
addItem(organizationList, contactInfoItems, getString(R.string.vcard_title), vCard.getField(VCardProperty.TITLE));
addItem(organizationList, contactInfoItems, getString(R.string.vcard_role), vCard.getField(VCardProperty.ROLE));
List<Organization> organizations = vCard.getOrganizations();
String organization;
if (organizations.isEmpty()) {
......
......@@ -26,6 +26,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
......@@ -69,7 +70,9 @@ public class ContactViewer extends ManagedActivity implements
private VCard vCard;
private boolean vCardError;
private ContactTitleExpandableToolbarInflater contactTitleExpandableToolbarInflater;
private ContactTitleExpandableToolbarInflater contactTitleExpandableToolbarInflater;
private TextView contactNameView;
private boolean isAccount = false;
......@@ -143,13 +146,18 @@ public class ContactViewer extends ManagedActivity implements
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.scrollable_container, new ContactViewerFragment()).commit();
.add(R.id.scrollable_container, new ContactVcardViewerFragment()).commit();
}
contactTitleExpandableToolbarInflater = new ContactTitleExpandableToolbarInflater(this);
AbstractContact bestContact = RosterManager.getInstance().getBestContact(account, bareAddress);
contactTitleExpandableToolbarInflater.onCreate(bestContact);
View contactTitleView = findViewById(R.id.expandable_contact_title);
contactTitleView.findViewById(R.id.status_icon).setVisibility(View.GONE);
contactTitleView.findViewById(R.id.status_text).setVisibility(View.GONE);
contactNameView = (TextView) contactTitleView.findViewById(R.id.name);
}
@Override
......@@ -164,7 +172,7 @@ public class ContactViewer extends ManagedActivity implements
contactTitleExpandableToolbarInflater.onResume();
ContactViewerFragment contactViewerFragment = getFragment();
ContactVcardViewerFragment contactViewerFragment = getFragment();
contactViewerFragment.updateContact(account, bareAddress);
contactViewerFragment.updateVCard(vCard);
......@@ -239,8 +247,8 @@ public class ContactViewer extends ManagedActivity implements
builder.show();
}
private ContactViewerFragment getFragment() {
return (ContactViewerFragment) getFragmentManager().findFragmentById(R.id.scrollable_container);
private ContactVcardViewerFragment getFragment() {
return (ContactVcardViewerFragment) getFragmentManager().findFragmentById(R.id.scrollable_container);
}
@Override
......@@ -284,6 +292,7 @@ public class ContactViewer extends ManagedActivity implements
public void onContactsChanged(Collection<BaseEntity> entities) {
for (BaseEntity entity : entities) {
if (entity.equals(account, bareAddress)) {
contactNameView.setText(RosterManager.getInstance().getBestContact(account, bareAddress).getName());
getFragment().updateContact(account, bareAddress);
break;
}
......@@ -293,6 +302,7 @@ public class ContactViewer extends ManagedActivity implements
@Override
public void onAccountsChanged(Collection<String> accounts) {
if (accounts.contains(account)) {
contactNameView.setText(RosterManager.getInstance().getBestContact(account, bareAddress).getName());
getFragment().updateContact(account, bareAddress);
}
}
......@@ -310,9 +320,4 @@ public class ContactViewer extends ManagedActivity implements
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
public View getContactTitleView() {
return findViewById(R.id.expandable_contact_title);
}
}
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