Commit e6c639e2 authored by Grigory Fedorov's avatar Grigory Fedorov

New ContactViewerFragment: simple linear layout instead of Preferences style. Not completed.

parent fe855947
...@@ -236,18 +236,6 @@ ...@@ -236,18 +236,6 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.ContactViewerNew"
android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.xabber.android.ui.ChatViewer" />
</activity>
<activity <activity
android:name="com.xabber.android.ui.FingerprintViewer" android:name="com.xabber.android.ui.FingerprintViewer"
android:label="@string/otr_verify_fingerprint" android:label="@string/otr_verify_fingerprint"
......
...@@ -58,6 +58,7 @@ import com.xabber.android.ui.dialog.ChatExportDialogFragment; ...@@ -58,6 +58,7 @@ import com.xabber.android.ui.dialog.ChatExportDialogFragment;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater; import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.helper.ManagedActivity; import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.ChatEditor; import com.xabber.android.ui.preferences.ChatEditor;
import com.xabber.android.ui.preferences.ContactViewer;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.Collection; import java.util.Collection;
...@@ -801,7 +802,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -801,7 +802,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.avatar) { if (v.getId() == R.id.avatar) {
startActivity(ContactViewerNew.createIntent(this, actionWithAccount, actionWithUser)); startActivity(ContactViewer.createIntent(this, actionWithAccount, actionWithUser));
} }
} }
} }
package com.xabber.android.ui;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleExpandableToolbarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
public class ContactViewerNew extends ManagedActivity {
private ContactTitleExpandableToolbarInflater contactTitleExpandableToolbarInflater;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
contactTitleExpandableToolbarInflater = new ContactTitleExpandableToolbarInflater(this);
AbstractContact bestContact = RosterManager.getInstance().getBestContact(getAccount(getIntent()), getUser(getIntent()));
contactTitleExpandableToolbarInflater.onCreate(bestContact);
}
@Override
protected void onResume() {
super.onResume();
contactTitleExpandableToolbarInflater.onResume();
}
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactViewerNew.class).setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
}
...@@ -67,16 +67,6 @@ public class ContactTitleExpandableToolbarInflater implements ObservableScrollVi ...@@ -67,16 +67,6 @@ public class ContactTitleExpandableToolbarInflater implements ObservableScrollVi
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(accountStatusBarColors[colorLevel]); window.setStatusBarColor(accountStatusBarColors[colorLevel]);
} }
final ObservableScrollView scrollView = (ObservableScrollView) activity.findViewById(R.id.scroll);
scrollView.setScrollViewCallbacks(this);
ScrollUtils.addOnGlobalLayoutListener(activity.findViewById(R.id.toolbar_overlay), new Runnable() {
@Override
public void run() {
updateFlexibleSpaceText(scrollView.getCurrentScrollY());
}
});
} }
public void onResume() { public void onResume() {
...@@ -92,6 +82,16 @@ public class ContactTitleExpandableToolbarInflater implements ObservableScrollVi ...@@ -92,6 +82,16 @@ public class ContactTitleExpandableToolbarInflater implements ObservableScrollVi
actionBarSize = getActionBarSize(); actionBarSize = getActionBarSize();
toolbarHeightDelta = toolbarHeight - actionBarSize; toolbarHeightDelta = toolbarHeight - actionBarSize;
final ObservableScrollView scrollView = (ObservableScrollView) activity.findViewById(R.id.scroll);
scrollView.setScrollViewCallbacks(this);
ScrollUtils.addOnGlobalLayoutListener(activity.findViewById(R.id.expandable_contact_title), new Runnable() {
@Override
public void run() {
updateFlexibleSpaceText(scrollView.getCurrentScrollY());
}
});
} }
protected int getActionBarSize() { protected int getActionBarSize() {
......
...@@ -18,7 +18,6 @@ import android.content.Context; ...@@ -18,7 +18,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager; import com.xabber.android.data.LogManager;
...@@ -28,10 +27,11 @@ import com.xabber.android.data.extension.vcard.OnVCardListener; ...@@ -28,10 +27,11 @@ import com.xabber.android.data.extension.vcard.OnVCardListener;
import com.xabber.android.data.extension.vcard.VCardManager; import com.xabber.android.data.extension.vcard.VCardManager;
import com.xabber.android.data.intent.AccountIntentBuilder; import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.data.intent.EntityIntentBuilder; import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.OnContactChangedListener; import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterContact; import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater; import com.xabber.android.ui.helper.ContactTitleExpandableToolbarInflater;
import com.xabber.android.ui.helper.ManagedActivity; import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
...@@ -68,6 +68,8 @@ public class ContactViewer extends ManagedActivity implements ...@@ -68,6 +68,8 @@ public class ContactViewer extends ManagedActivity implements
private static final Map<TelephoneType, Integer> TELEPHONE_TYPE_MAP = new HashMap<>(); private static final Map<TelephoneType, Integer> TELEPHONE_TYPE_MAP = new HashMap<>();
private static final Map<EmailType, Integer> EMAIL_TYPE_MAP = new HashMap<>(); private static final Map<EmailType, Integer> EMAIL_TYPE_MAP = new HashMap<>();
private ContactTitleExpandableToolbarInflater contactTitleExpandableToolbarInflater;
static { static {
ADDRESS_TYPE_MAP.put(AddressType.DOM, R.string.vcard_type_dom); ADDRESS_TYPE_MAP.put(AddressType.DOM, R.string.vcard_type_dom);
ADDRESS_TYPE_MAP.put(AddressType.HOME, R.string.vcard_type_home); ADDRESS_TYPE_MAP.put(AddressType.HOME, R.string.vcard_type_home);
...@@ -184,22 +186,17 @@ public class ContactViewer extends ManagedActivity implements ...@@ -184,22 +186,17 @@ public class ContactViewer extends ManagedActivity implements
LogManager.exception(this, e); LogManager.exception(this, e);
} }
} }
setTitle(getString(R.string.contact_viewer));
setContentView(R.layout.contact_viewer);
setSupportActionBar((Toolbar) findViewById(R.id.contact_viewer_toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ContactTitleActionBarInflater contactTitleActionBarInflater = new ContactTitleActionBarInflater(this);
contactTitleActionBarInflater.setUpActionBarView();
contactTitleActionBarInflater.update(RosterManager.getInstance().getBestContact(account, bareAddress));
if (savedInstanceState == null) { if (savedInstanceState == null) {
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ContactViewerFragment()).commit(); .add(R.id.scrollable_container, new ContactViewerFragment()).commit();
} }
contactTitleExpandableToolbarInflater = new ContactTitleExpandableToolbarInflater(this);
AbstractContact bestContact = RosterManager.getInstance().getBestContact(account, bareAddress);
contactTitleExpandableToolbarInflater.onCreate(bestContact);
} }
@Override @Override
...@@ -213,6 +210,8 @@ public class ContactViewer extends ManagedActivity implements ...@@ -213,6 +210,8 @@ public class ContactViewer extends ManagedActivity implements
if (vCard == null && !vCardError) if (vCard == null && !vCardError)
VCardManager.getInstance().request(account, bareAddress, null); VCardManager.getInstance().request(account, bareAddress, null);
contactTitleExpandableToolbarInflater.onResume();
ContactViewerFragment contactViewerFragment = getFragment(); ContactViewerFragment contactViewerFragment = getFragment();
contactViewerFragment.updateContact(account, bareAddress); contactViewerFragment.updateContact(account, bareAddress);
...@@ -221,7 +220,7 @@ public class ContactViewer extends ManagedActivity implements ...@@ -221,7 +220,7 @@ public class ContactViewer extends ManagedActivity implements
private ContactViewerFragment getFragment() { private ContactViewerFragment getFragment() {
return (ContactViewerFragment) getFragmentManager() return (ContactViewerFragment) getFragmentManager()
.findFragmentById(R.id.preferences_activity_container); .findFragmentById(R.id.scrollable_container);
} }
@Override @Override
......
package com.xabber.android.ui.preferences; package com.xabber.android.ui.preferences;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceCategory; import android.support.annotation.Nullable;
import android.preference.PreferenceGroup; import android.view.LayoutInflater;
import android.preference.PreferenceScreen; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.extension.capability.CapabilitiesManager; import com.xabber.android.data.extension.capability.CapabilitiesManager;
import com.xabber.android.data.extension.capability.ClientInfo; import com.xabber.android.data.extension.capability.ClientInfo;
import com.xabber.android.data.roster.PresenceManager; import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem; import com.xabber.android.data.roster.ResourceItem;
import com.xabber.android.data.roster.RosterContact; import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.android.ui.widget.StatusPreference;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.Address; import com.xabber.xmpp.vcard.Address;
import com.xabber.xmpp.vcard.AddressProperty; import com.xabber.xmpp.vcard.AddressProperty;
...@@ -26,37 +31,26 @@ import com.xabber.xmpp.vcard.TelephoneType; ...@@ -26,37 +31,26 @@ import com.xabber.xmpp.vcard.TelephoneType;
import com.xabber.xmpp.vcard.VCard; import com.xabber.xmpp.vcard.VCard;
import com.xabber.xmpp.vcard.VCardProperty; import com.xabber.xmpp.vcard.VCardProperty;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ContactViewerFragment extends android.preference.PreferenceFragment { public class ContactViewerFragment extends Fragment {
private List<PreferenceCategory> addresses; private LinearLayout contactInfoItems;
private List<PreferenceCategory> telephones;
private List<PreferenceCategory> emails;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
}
addresses = new ArrayList<>(); @Nullable
telephones = new ArrayList<>(); @Override
emails = new ArrayList<>(); public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
addPreferencesFromResource(R.xml.contact_viewer); View view = inflater.inflate(R.layout.contact_viewer_fragment, container, false);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen()); contactInfoItems = (LinearLayout) view.findViewById(R.id.contact_info_items);
}
/** return view;
* Sets value for the preference by its id.
*
* @param resourceId
* @param value
*/
private void setValue(int resourceId, String value) {
if (value == null)
value = "";
findPreference(getString(resourceId)).setSummary(value);
} }
/** /**
...@@ -74,23 +68,18 @@ public class ContactViewerFragment extends android.preference.PreferenceFragment ...@@ -74,23 +68,18 @@ public class ContactViewerFragment extends android.preference.PreferenceFragment
} }
public void updateContact(String account, String bareAddress) { public void updateContact(String account, String bareAddress) {
setValue(R.string.contact_viewer_jid, bareAddress); addContactInfoItem(R.string.contact_viewer_jid, bareAddress);
RosterContact rosterContact = RosterManager.getInstance() RosterContact rosterContact = RosterManager.getInstance().getRosterContact(account, bareAddress);
.getRosterContact(account, bareAddress); addContactInfoItem(R.string.contact_viewer_name, rosterContact == null ? null : rosterContact.getRealName());
setValue(R.string.contact_viewer_name, rosterContact == null ? null
: rosterContact.getRealName());
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(getString(R.string.contact_viewer_resources));
preferenceCategory.removeAll();
if (rosterContact != null && rosterContact.isConnected()) if (rosterContact != null && rosterContact.isConnected())
for (ResourceItem resourceItem : PresenceManager.getInstance() for (ResourceItem resourceItem
.getResourceItems(account, bareAddress)) { : PresenceManager.getInstance().getResourceItems(account, bareAddress)) {
StatusPreference preference = new StatusPreference(getActivity());
preference.setLayoutResource(R.layout.info_preference);
preference.setStatusMode(resourceItem.getStatusMode());
String user = resourceItem.getUser(bareAddress); String user = resourceItem.getUser(bareAddress);
ClientInfo clientInfo = CapabilitiesManager.getInstance() ClientInfo clientInfo = CapabilitiesManager.getInstance().getClientInfo(account, user);
.getClientInfo(account, user);
String client; String client = "";
if (clientInfo == null) { if (clientInfo == null) {
CapabilitiesManager.getInstance().request(account, user); CapabilitiesManager.getInstance().request(account, user);
client = getString(R.string.please_wait); client = getString(R.string.please_wait);
...@@ -98,116 +87,133 @@ public class ContactViewerFragment extends android.preference.PreferenceFragment ...@@ -98,116 +87,133 @@ public class ContactViewerFragment extends android.preference.PreferenceFragment
client = getString(R.string.unknown); client = getString(R.string.unknown);
} else { } else {
String name = clientInfo.getName(); String name = clientInfo.getName();
if (name == null) if (name != null) {
name = getString(R.string.unknown); client = name;
}
String type = clientInfo.getType(); String type = clientInfo.getType();
if (type == null) if (type != null) {
type = getString(R.string.unknown); if (client.isEmpty()) {
client = getString(R.string.contact_viewer_client_info, client = type;
name, type); } else {
client = client + "/" + type;
} }
preference.setTitle(getString(
R.string.contact_viewer_resource_summary, }
resourceItem.getVerbose(), resourceItem.getPriority(), }
client));
preference.setSummary(resourceItem.getStatusText()); resourceItem.getStatusMode().getStatusLevel();
preferenceCategory.addPreference(preference);
String label = String.valueOf(resourceItem.getPriority());
if (!client.isEmpty()) {
label = label + ", " + client;
}
addContactInfoItem(label, resourceItem.getVerbose(), null);
} }
} }
public void updateVCard(VCard vCard) { public void updateVCard(VCard vCard) {
LogManager.i(this, "updateVCard.");
if (vCard == null) if (vCard == null) {
return; return;
setValue(R.string.vcard_nick_name, }
vCard.getField(VCardProperty.NICKNAME)); addContactInfoItem(R.string.vcard_nick_name, vCard.getField(VCardProperty.NICKNAME));
setValue(R.string.vcard_formatted_name, vCard.getFormattedName()); addContactInfoItem(R.string.vcard_formatted_name, vCard.getFormattedName());
setValue(R.string.vcard_prefix_name, addContactInfoItem(R.string.vcard_prefix_name, vCard.getField(NameProperty.PREFIX));
vCard.getField(NameProperty.PREFIX)); addContactInfoItem(R.string.vcard_given_name, vCard.getField(NameProperty.GIVEN));
setValue(R.string.vcard_given_name, vCard.getField(NameProperty.GIVEN)); addContactInfoItem(R.string.vcard_middle_name, vCard.getField(NameProperty.MIDDLE));
setValue(R.string.vcard_middle_name, addContactInfoItem(R.string.vcard_family_name, vCard.getField(NameProperty.FAMILY));
vCard.getField(NameProperty.MIDDLE)); addContactInfoItem(R.string.vcard_suffix_name, vCard.getField(NameProperty.SUFFIX));
setValue(R.string.vcard_family_name, addContactInfoItem(R.string.vcard_birth_date, vCard.getField(VCardProperty.BDAY));
vCard.getField(NameProperty.FAMILY)); addContactInfoItem(R.string.vcard_title, vCard.getField(VCardProperty.TITLE));
setValue(R.string.vcard_suffix_name, addContactInfoItem(R.string.vcard_role, vCard.getField(VCardProperty.ROLE));
vCard.getField(NameProperty.SUFFIX));
setValue(R.string.vcard_birth_date, vCard.getField(VCardProperty.BDAY));
setValue(R.string.vcard_title, vCard.getField(VCardProperty.TITLE));
setValue(R.string.vcard_role, vCard.getField(VCardProperty.ROLE));
List<Organization> organizations = vCard.getOrganizations(); List<Organization> organizations = vCard.getOrganizations();
String organization; String organization;
if (organizations.isEmpty()) if (organizations.isEmpty()) {
organization = null; organization = null;
else { } else {
organization = organizations.get(0).getName(); organization = organizations.get(0).getName();
for (String unit : organizations.get(0).getUnits()) for (String unit : organizations.get(0).getUnits()) {
organization = addString(organization, unit, "\n"); organization = addString(organization, unit, "\n");
} }
setValue(R.string.vcard_organization, organization); }
setValue(R.string.vcard_url, vCard.getField(VCardProperty.URL)); addContactInfoItem(getString(R.string.vcard_organization), organization, R.drawable.ic_organization_24dp);
addContactInfoItem(R.string.vcard_url, vCard.getField(VCardProperty.URL));
String categories = null; String categories = null;
for (String category : vCard.getCategories()) for (String category : vCard.getCategories()) {
categories = addString(categories, category, "\n"); categories = addString(categories, category, "\n");
setValue(R.string.vcard_categories, categories); }
setValue(R.string.vcard_note, vCard.getField(VCardProperty.NOTE));
setValue(R.string.vcard_decsription, vCard.getField(VCardProperty.DESC)); addContactInfoItem(R.string.vcard_categories, categories);
PreferenceScreen screen = getPreferenceScreen(); addContactInfoItem(R.string.vcard_note, vCard.getField(VCardProperty.NOTE));
for (PreferenceCategory category : addresses) addContactInfoItem(R.string.vcard_decsription, vCard.getField(VCardProperty.DESC));
screen.removePreference(category);
for (PreferenceCategory category : telephones)
screen.removePreference(category);
for (PreferenceCategory category : emails)
screen.removePreference(category);
for (Address address : vCard.getAddresses()) { for (Address address : vCard.getAddresses()) {
String types = null; String types = null;
for (AddressType type : address.getTypes()) for (AddressType type : address.getTypes()) {
types = addString(types, getString(ContactViewer.getAddressTypeMap().get(type)), types = addString(types, getString(ContactViewer.getAddressTypeMap().get(type)), ", ");
", "); }
String value = null; String value = null;
for (AddressProperty property : AddressProperty.values()) for (AddressProperty property : AddressProperty.values()) {
value = addString(value, address.getProperties().get(property), value = addString(value, address.getProperties().get(property), "\n");
"\n");
PreferenceScreen addressScreen = createTypedCategory(
R.string.vcard_address, types, value);
for (AddressProperty property : AddressProperty.values())
addPreferenceScreen(addressScreen,
ContactViewer.getAddressPropertyMap().get(property), address
.getProperties().get(property));
} }
addContactInfoItem(types, value, null);
for (AddressProperty property : AddressProperty.values()) {
ContactViewer.getAddressPropertyMap().get(property);
address.getProperties().get(property);
}
}
for (Telephone telephone : vCard.getTelephones()) { for (Telephone telephone : vCard.getTelephones()) {
String types = null; String types = null;
for (TelephoneType type : telephone.getTypes()) for (TelephoneType type : telephone.getTypes()) {
types = addString(types, types = addString(types, getString(ContactViewer.getTelephoneTypeMap().get(type)), ", ");
getString(ContactViewer.getTelephoneTypeMap().get(type)), ", "); }
createTypedCategory(R.string.vcard_telephone, types,
telephone.getValue()); addContactInfoItem(types, telephone.getValue(), R.drawable.ic_telephone_24dp);
} }
for (Email email : vCard.getEmails()) { for (Email email : vCard.getEmails()) {
String types = null; String types = null;
for (EmailType type : email.getTypes()) for (EmailType type : email.getTypes()) {
types = addString(types, getString(ContactViewer.getEmailTypeMap().get(type)), types = addString(types, getString(ContactViewer.getEmailTypeMap().get(type)), ", ");
", "); }
createTypedCategory(R.string.vcard_email, types, email.getValue());
addContactInfoItem(types, email.getValue(), R.drawable.ic_email_24dp);
}
}
private void addContactInfoItem(int labelId, String value) {
addContactInfoItem(getString(labelId), value, null);
} }
private void addContactInfoItem(String label, String value, Integer iconResource) {
LogManager.i(this, label + ": " + value);
if (value == null || value.isEmpty() ) {
return;
} }
private PreferenceScreen createTypedCategory(int title, String types, final LayoutInflater inflater
String value) { = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
PreferenceCategory preferenceCategory = new PreferenceCategory(getActivity()); View contactInfoItem = inflater.inflate(R.layout.contact_info_item, contactInfoItems, false);
preferenceCategory.setTitle(title);
getPreferenceScreen().addPreference(preferenceCategory); ((TextView)contactInfoItem.findViewById(R.id.contact_info_item_name)).setText(label);
((TextView)contactInfoItem.findViewById(R.id.contact_info_item_value)).setText(value);
addPreferenceScreen(preferenceCategory, R.string.vcard_type, types); if (iconResource != null) {
return addPreferenceScreen(preferenceCategory, title, value); ((ImageView) contactInfoItem.findViewById(R.id.contact_info_group_icon)).setImageResource(iconResource);
} }
private PreferenceScreen addPreferenceScreen(PreferenceGroup container, contactInfoItems.addView(contactInfoItem);
int title, String summary) {
PreferenceScreen preference = getPreferenceManager().createPreferenceScreen(getActivity());
preference.setLayoutResource(R.layout.info_preference);
preference.setTitle(title);
preference.setSummary(summary == null ? "" : summary);
container.addPreference(preference);
return preference;
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
>
<ImageView
android:id="@+id/contact_info_group_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="24dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="72dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_marginStart="72dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:text="(650) 555-1234"
android:id="@+id/contact_info_item_value"
android:textSize="@dimen/abc_text_size_medium_material" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:text="Mobile"
android:id="@+id/contact_info_item_name" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_info_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
\ No newline at end of file
...@@ -17,15 +17,6 @@ ...@@ -17,15 +17,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/toolbar_height"> android:paddingTop="@dimen/toolbar_height">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:text="Lorem ipsum dolor sit amet, ut duis lorem provident sed felis blandit, condimentum donec lectus ipsum et mauris, morbi porttitor interdum feugiat nulla donec sodales, vestibulum nisl primis a molestie vestibulum quam, sapien mauris metus risus suspendisse magnis. Augue viverra nulla faucibus egestas eu, a etiam id congue rutrum ante, arcu tincidunt donec quam felis at ornare, iaculis ligula sodales venenatis commodo volutpat neque, suspendisse elit praesent tellus felis mi amet. Inceptos amet tempor lectus lorem est non, ac donec ac libero neque mauris, tellus ante metus eget leo consequat. Scelerisque dolor curabitur pretium blandit ut feugiat, amet lacus pulvinar justo convallis ut, sed natoque ipsum urna posuere nibh eu. Sed at sed vulputate sit orci, facilisis a aliquam tellus quam aliquam, eu aliquam donec at molestie ante, pellentesque mauris lorem ultrices libero faucibus porta, imperdiet adipiscing sit hac diam ut nulla. Lacus enim elit pulvinar donec vehicula dapibus, accumsan purus officia cursus dolor sapien, eu amet dis mauris mi nulla ut. Non accusamus etiam pede non urna tempus, vestibulum aliquam tortor eget pharetra sodales, in vestibulum ut justo orci nulla, lobortis purus sem semper consectetuer elit praesent tellus felis mi amet. Inceptos amet tempor lectus lorem est non, ac donec ac libero neque mauris, tellus ante metus eget leo consequat. Scelerisque dolor curabitur pretium blandit ut feugiat, amet lacus pulvinar justo convallis ut, sed natoque ipsum urna posuere nibh eu. Sed at sed vulputate sit orci, facilisis a aliquam tellus quam aliquam, eu aliquam donec at molestie ante, pellentesque mauris lorem ultrices libero faucibus porta, imperdiet adipiscing sit hac diam ut nulla. Lacus enim elit pulvinar donec vehicula dapibus, accumsan purus officia cursus dolor sapien, eu amet dis mauris mi nulla ut. Non accusamus etiam pede non urna tempus, vestibulum aliquam tortor eget pharetra sodales, in vestibulum ut justo orci nulla, lobortis purus sem semper consectetuer elit praesent tellus felis mi amet. Inceptos amet tempor lectus lorem est non, ac donec ac libero neque mauris, tellus ante metus eget leo consequat. Scelerisque dolor curabitur pretium blandit ut feugiat, amet lacus pulvinar justo convallis ut, sed natoque ipsum urna posuere nibh eu. Sed at sed vulputate sit orci, facilisis a aliquam tellus quam aliquam, eu aliquam donec at molestie ante, pellentesque mauris lorem ultrices libero faucibus porta, imperdiet adipiscing sit hac diam ut nulla. Lacus enim elit pulvinar donec vehicula dapibus, accumsan purus officia cursus dolor sapien, eu amet dis mauris mi nulla ut. Non accusamus etiam pede non urna tempus, vestibulum aliquam tortor eget pharetra sodales, in vestibulum ut justo orci nulla, lobortis purus sem semper consectetuer"/>
</FrameLayout> </FrameLayout>
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView> </com.github.ksoichiro.android.observablescrollview.ObservableScrollView>
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Layout for a Preference in a PreferenceActivity. The
Preference is able to place a specific widget for its particular
type in the "widget_frame" layout. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">
<TextView android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignLeft="@android:id/title"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</RelativeLayout>
<!-- Preference should place its actual preference widget here. -->
<LinearLayout android:id="@+android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
</LinearLayout>
...@@ -21,12 +21,10 @@ ...@@ -21,12 +21,10 @@
<PreferenceScreen <PreferenceScreen
android:title="@string/contact_viewer_jid" android:title="@string/contact_viewer_jid"
android:key="@string/contact_viewer_jid" android:key="@string/contact_viewer_jid"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/contact_viewer_name" android:title="@string/contact_viewer_name"
android:key="@string/contact_viewer_name" android:key="@string/contact_viewer_name"
android:layout="@layout/info_preference"
/> />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
...@@ -39,43 +37,35 @@ ...@@ -39,43 +37,35 @@
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_nick_name" android:title="@string/vcard_nick_name"
android:key="@string/vcard_nick_name" android:key="@string/vcard_nick_name"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_formatted_name" android:title="@string/vcard_formatted_name"
android:key="@string/vcard_formatted_name" android:key="@string/vcard_formatted_name"
android:layout="@layout/info_preference"
> >
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_prefix_name" android:title="@string/vcard_prefix_name"
android:key="@string/vcard_prefix_name" android:key="@string/vcard_prefix_name"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_given_name" android:title="@string/vcard_given_name"
android:key="@string/vcard_given_name" android:key="@string/vcard_given_name"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_middle_name" android:title="@string/vcard_middle_name"
android:key="@string/vcard_middle_name" android:key="@string/vcard_middle_name"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_family_name" android:title="@string/vcard_family_name"
android:key="@string/vcard_family_name" android:key="@string/vcard_family_name"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_suffix_name" android:title="@string/vcard_suffix_name"
android:key="@string/vcard_suffix_name" android:key="@string/vcard_suffix_name"
android:layout="@layout/info_preference"
/> />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_birth_date" android:title="@string/vcard_birth_date"
android:key="@string/vcard_birth_date" android:key="@string/vcard_birth_date"
android:layout="@layout/info_preference"
/> />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
...@@ -84,17 +74,14 @@ ...@@ -84,17 +74,14 @@
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_title" android:title="@string/vcard_title"
android:key="@string/vcard_title" android:key="@string/vcard_title"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_role" android:title="@string/vcard_role"
android:key="@string/vcard_role" android:key="@string/vcard_role"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_organization" android:title="@string/vcard_organization"
android:key="@string/vcard_organization" android:key="@string/vcard_organization"
android:layout="@layout/info_preference"
/> />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
...@@ -103,22 +90,18 @@ ...@@ -103,22 +90,18 @@
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_url" android:title="@string/vcard_url"
android:key="@string/vcard_url" android:key="@string/vcard_url"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_categories" android:title="@string/vcard_categories"
android:key="@string/vcard_categories" android:key="@string/vcard_categories"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_decsription" android:title="@string/vcard_decsription"
android:key="@string/vcard_decsription" android:key="@string/vcard_decsription"
android:layout="@layout/info_preference"
/> />
<PreferenceScreen <PreferenceScreen
android:title="@string/vcard_note" android:title="@string/vcard_note"
android:key="@string/vcard_note" android:key="@string/vcard_note"
android:layout="@layout/info_preference"
/> />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
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