Commit 7ca652a5 authored by Grigory Fedorov's avatar Grigory Fedorov

QuickContactBadge does not used for avatars displaying - they are not clickable anymore.

 Avatar inflater helpers removed.
parent eae1d6a8
...@@ -32,7 +32,6 @@ import android.widget.TextView; ...@@ -32,7 +32,6 @@ import android.widget.TextView;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.ui.helper.AbstractAvatarInflaterHelper;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
/** /**
...@@ -46,7 +45,6 @@ public abstract class BaseContactInflater { ...@@ -46,7 +45,6 @@ public abstract class BaseContactInflater {
final LayoutInflater layoutInflater; final LayoutInflater layoutInflater;
final AbstractAvatarInflaterHelper avatarInflaterHelper;
/** /**
* Repeated shadow for drawable. * Repeated shadow for drawable.
...@@ -62,7 +60,6 @@ public abstract class BaseContactInflater { ...@@ -62,7 +60,6 @@ public abstract class BaseContactInflater {
public BaseContactInflater(Activity activity) { public BaseContactInflater(Activity activity) {
this.activity = activity; this.activity = activity;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
avatarInflaterHelper = AbstractAvatarInflaterHelper.createAbstractContactInflaterHelper();
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow); Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap); shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
...@@ -128,7 +125,6 @@ public abstract class BaseContactInflater { ...@@ -128,7 +125,6 @@ public abstract class BaseContactInflater {
if (SettingsManager.contactsShowAvatars()) { if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE); viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(abstractContact.getAvatarForContactList()); viewHolder.avatar.setImageDrawable(abstractContact.getAvatarForContactList());
avatarInflaterHelper.updateAvatar(viewHolder.avatar, abstractContact);
((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams()) ((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams())
.addRule(RelativeLayout.RIGHT_OF, R.id.avatar); .addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
} else { } else {
......
...@@ -13,7 +13,6 @@ import com.xabber.android.data.message.MessageManager; ...@@ -13,7 +13,6 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.NotificationManager; import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.AbstractAvatarInflaterHelper;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -23,15 +22,12 @@ public class ChatListAdapter extends BaseAdapter { ...@@ -23,15 +22,12 @@ public class ChatListAdapter extends BaseAdapter {
private List<AbstractChat> chats; private List<AbstractChat> chats;
private final AbstractAvatarInflaterHelper avatarInflaterHelper;
private final Context context; private final Context context;
public ChatListAdapter(Context context) { public ChatListAdapter(Context context) {
this.context = context; this.context = context;
chats = new ArrayList<>(); chats = new ArrayList<>();
avatarInflaterHelper = AbstractAvatarInflaterHelper.createAbstractContactInflaterHelper();
} }
public void updateChats(List<AbstractChat> chats) { public void updateChats(List<AbstractChat> chats) {
...@@ -73,7 +69,6 @@ public class ChatListAdapter extends BaseAdapter { ...@@ -73,7 +69,6 @@ public class ChatListAdapter extends BaseAdapter {
final ImageView avatarView = (ImageView) view.findViewById(R.id.avatar); final ImageView avatarView = (ImageView) view.findViewById(R.id.avatar);
avatarView.setImageDrawable(abstractContact.getAvatar()); avatarView.setImageDrawable(abstractContact.getAvatar());
avatarInflaterHelper.updateAvatar(avatarView, abstractContact);
final TextView textView = (TextView) view.findViewById(R.id.text); final TextView textView = (TextView) view.findViewById(R.id.text);
......
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.helper;
import android.widget.ImageView;
import com.xabber.android.data.Application;
import com.xabber.android.data.roster.AbstractContact;
/**
* Helper class to update avatar's contact item.
*
* @author alexander.ivanov
*/
public abstract class AbstractAvatarInflaterHelper {
/**
* Update avatar image view.
*
* @param avatar
* @param abstractContact
*/
public abstract void updateAvatar(ImageView avatar,
AbstractContact abstractContact);
/**
* @return New instance depend on whether new system contact list is
* supported.
*/
public static AbstractAvatarInflaterHelper createAbstractContactInflaterHelper() {
if (Application.getInstance().isContactsSupported())
return new AvatarInflaterHelper();
else
return new DummyAvatarInflaterHelper();
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.helper;
import android.annotation.TargetApi;
import android.provider.ContactsContract;
import android.widget.ImageView;
import android.widget.QuickContactBadge;
import com.xabber.android.data.roster.AbstractContact;
/**
* Helper class to add quick contact badge to the inflated contact item.
*
* @author alexander.ivanov
*/
@TargetApi(5)
public class AvatarInflaterHelper extends AbstractAvatarInflaterHelper {
@Override
public void updateAvatar(ImageView avatar, AbstractContact abstractContact) {
QuickContactBadge badge = (QuickContactBadge) avatar;
badge.assignContactFromEmail(abstractContact.getUser(), true);
badge.setMode(ContactsContract.QuickContact.MODE_SMALL);
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.helper;
import android.widget.ImageView;
import com.xabber.android.data.roster.AbstractContact;
/**
* This dummy implementation do nothing.
*
* @author alexander.ivanov
*/
public class DummyAvatarInflaterHelper extends AbstractAvatarInflaterHelper {
@Override
public void updateAvatar(ImageView avatar, AbstractContact abstractContact) {
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<QuickContactBadge
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_toRightOf="@id/color"
android:src="@drawable/avatar_1_1"
/>
...@@ -29,7 +29,16 @@ ...@@ -29,7 +29,16 @@
android:layout_marginEnd="3dp" android:layout_marginEnd="3dp"
/> />
<include layout="@layout/base_contact_avatar" />
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_toRightOf="@id/color"
android:src="@drawable/avatar_1_1"
/>
<RelativeLayout <RelativeLayout
android:id="@+id/panel" android:id="@+id/panel"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -31,7 +31,14 @@ ...@@ -31,7 +31,14 @@
android:src="@android:color/transparent" android:src="@android:color/transparent"
/> />
<include layout="@layout/base_contact_avatar" /> <ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_toRightOf="@id/color"
android:src="@drawable/avatar_1_1"
/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -6,7 +6,18 @@ ...@@ -6,7 +6,18 @@
android:layout_height="?android:attr/actionBarSize" android:layout_height="?android:attr/actionBarSize"
android:orientation="horizontal" android:orientation="horizontal"
> >
<include layout="@layout/contact_title_avatar" />
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="48dip"
android:layout_height="48dip"
android:src="@drawable/avatar_1_1"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
/>
<LinearLayout <LinearLayout
android:id="@+id/name_holder" android:id="@+id/name_holder"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<QuickContactBadge
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="48dip"
android:layout_height="48dip"
android:src="@drawable/avatar_1_1"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
/>
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