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
......
<?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