# HG changeset patch # User Da Risk # Date 1343146928 -7200 # Node ID 7067aa2679170e1edf3ce573d859ab47223134fe # Parent e1b1c8ad710afec562401b6be79c256d627b877a Replace our custom Tabs gallery with the standard PagerTabStrip from ACL diff -r e1b1c8ad710a -r 7067aa267917 libs/android-support-v13.jar Binary file libs/android-support-v13.jar has changed diff -r e1b1c8ad710a -r 7067aa267917 res/layout/contactlist.xml --- a/res/layout/contactlist.xml Fri May 18 00:25:02 2012 +0200 +++ b/res/layout/contactlist.xml Tue Jul 24 18:22:08 2012 +0200 @@ -2,12 +2,17 @@ - + > + + + diff -r e1b1c8ad710a -r 7067aa267917 res/layout/contactlist_group.xml --- a/res/layout/contactlist_group.xml Fri May 18 00:25:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ - - - diff -r e1b1c8ad710a -r 7067aa267917 res/layout/contactlist_groupstub.xml --- a/res/layout/contactlist_groupstub.xml Fri May 18 00:25:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ - - - - - - diff -r e1b1c8ad710a -r 7067aa267917 res/values/styles.xml --- a/res/values/styles.xml Fri May 18 00:25:02 2012 +0200 +++ b/res/values/styles.xml Tue Jul 24 18:22:08 2012 +0200 @@ -24,6 +24,11 @@ @color/black + + diff -r e1b1c8ad710a -r 7067aa267917 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Fri May 18 00:25:02 2012 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Tue Jul 24 18:22:08 2012 +0200 @@ -49,6 +49,8 @@ import java.util.ListIterator; import java.util.Map; +import org.jivesoftware.smack.util.StringUtils; + import android.app.Dialog; import android.content.ComponentName; import android.content.Intent; @@ -63,20 +65,13 @@ import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.PagerTabStrip; import android.support.v4.view.ViewPager; import android.util.Log; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; -import android.view.ViewStub; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.BaseAdapter; -import android.widget.Gallery; -import android.widget.LinearLayout; import com.beem.project.beem.BeemApplication; import com.beem.project.beem.R; @@ -90,11 +85,8 @@ import com.beem.project.beem.ui.dialogs.builders.ChatList; import com.beem.project.beem.ui.dialogs.builders.DeleteContact; import com.beem.project.beem.ui.dialogs.builders.ResendSubscription; -import com.beem.project.beem.ui.views.SectionTextView; import com.beem.project.beem.utils.BeemBroadcastReceiver; -import org.jivesoftware.smack.util.StringUtils; - /** * The contact list activity displays the roster of the user. */ @@ -106,7 +98,7 @@ } private static final String TAG = "ContactList"; - private final List mListGroup = new ArrayList(); + private final List mListGroup = new ArrayList(); /** Map containing a list of the different contacts of a given group. * Each list is a @{link SortedList} so there is no need to sort it again. @@ -114,7 +106,6 @@ private final Map> mContactOnGroup = new HashMap>(); private final ServiceConnection mServConn = new BeemServiceConnection(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); - private final BeemBanner mAdapterBanner = new BeemBanner(); private final Map contactListAdapters = new HashMap(); private final BeemRosterListener mBeemRosterListener = new BeemRosterListener(); @@ -122,11 +113,10 @@ private IXmppFacade mXmppFacade; private IChatManager mChatManager; private SharedPreferences mSettings; - private LayoutInflater mInflater; private boolean mBinded; private ViewPager viewPager; private ListPagerAdapter groupsPagesAdapter; - private Gallery groupGallery; + private PagerTabStrip pagerTabs; /** * Constructor. @@ -188,15 +178,15 @@ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); - mInflater = getLayoutInflater(); - viewPager = (ViewPager) findViewById(R.id.pager); - viewPager.setOnPageChangeListener(new OnPageChangeListener()); groupsPagesAdapter = new ListPagerAdapter(getSupportFragmentManager(), viewPager); - - mListGroup.add(new GroupHolder(getString(R.string.contact_list_all_contact))); - mListGroup.add(new GroupHolder(getString(R.string.contact_list_no_group))); - mAdapterBanner.notifyDataSetChanged(); + pagerTabs = (PagerTabStrip) findViewById(R.id.tabstrip); + pagerTabs.setTabIndicatorColorResource(R.color.vert_manu); + pagerTabs.setNonPrimaryAlpha(0.50f); + + mListGroup.add(getString(R.string.contact_list_all_contact)); + mListGroup.add(getString(R.string.contact_list_no_group)); + groupsPagesAdapter.notifyDataSetChanged(); } @Override @@ -251,24 +241,22 @@ if (contactListAdapter == null) { contactListAdapter = new ContactListAdapter(ContactList.this); contactListAdapters.put(group, contactListAdapter); - List realGroups = mListGroup.subList(1, mListGroup.size() - 1); - if (!GroupHolder.contains(mListGroup, group)) { - GroupHolder gh = new GroupHolder(group); + List realGroups = mListGroup.subList(1, mListGroup.size() - 1); + if (!mListGroup.contains(group)) { boolean added = false; // insert group in sorted list - for (ListIterator iterator = realGroups.listIterator(); iterator.hasNext();) { - GroupHolder currentGroup = (GroupHolder) iterator.next(); - if (currentGroup.group.compareTo(group) > 0) { + for (ListIterator iterator = realGroups.listIterator(); iterator.hasNext();) { + String currentGroup = (String) iterator.next(); + if (currentGroup.compareTo(group) > 0) { iterator.previous(); - iterator.add(gh); + iterator.add(group); added = true; break; } } if (!added) - realGroups.add(gh); + realGroups.add(group); groupsPagesAdapter.notifyDataSetChanged(); - mAdapterBanner.notifyDataSetChanged(); } } boolean hideDisconnected = mSettings.getBoolean(BeemApplication.SHOW_OFFLINE_CONTACTS_KEY, false); @@ -315,29 +303,14 @@ * Show the groups view. */ private void showGroups() { - - ViewStub stub = (ViewStub) findViewById(R.id.contactlist_stub); - if (stub != null) { - View v = stub.inflate(); - groupGallery = (Gallery) v.findViewById(R.id.contactlist_banner); - groupGallery.setOnItemClickListener(new OnItemClickGroupName()); - groupGallery.setAdapter(mAdapterBanner); - groupGallery.setSelection(0); - } else { - ((LinearLayout) findViewById(R.id.contactlist_groupstub)).setVisibility(View.VISIBLE); - groupGallery = (Gallery) findViewById(R.id.contactlist_banner); - groupGallery.setSelection(0); - } - GroupHolder.setUniquePrincipal(mListGroup, 0); + pagerTabs.setVisibility(View.VISIBLE); } /** * Hide the groups view. */ private void hideGroups() { - View v = findViewById(R.id.contactlist_groupstub); - if (v != null) - v.setVisibility(View.GONE); + pagerTabs.setVisibility(View.GONE); } /** @@ -349,12 +322,9 @@ return; List rosterGroups = mRoster.getGroupsNames(); Collections.sort(rosterGroups); - List realGroups = mListGroup.subList(1, mListGroup.size() - 1); + List realGroups = mListGroup.subList(1, mListGroup.size() - 1); realGroups.clear(); - realGroups.addAll(GroupHolder.createFrom(rosterGroups)); - // restore principal - GroupHolder.setUniquePrincipal(mListGroup, viewPager.getCurrentItem()); - mAdapterBanner.notifyDataSetChanged(); + realGroups.addAll(rosterGroups); groupsPagesAdapter.notifyDataSetChanged(); } @@ -498,45 +468,6 @@ } /** - * Adapter banner list. - */ - private class BeemBanner extends BaseAdapter { - - /** - * Constructor. - */ - public BeemBanner() { - } - - @Override - public int getCount() { - return mListGroup.size(); - } - - @Override - public Object getItem(int position) { - return mListGroup.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - SectionTextView v = (SectionTextView) convertView; - if (convertView == null) { - v = (SectionTextView) mInflater.inflate(R.layout.contactlist_group, null); - } - GroupHolder gh = (GroupHolder) getItem(position); - v.setText(gh.group); - v.setPrincipal(gh.isPrincipal); - return v; - } - } - - /** * The service connection used to connect to the Beem service. */ private class BeemServiceConnection implements ServiceConnection { @@ -609,44 +540,6 @@ } - - /** - * Listener on page change event. - */ - private class OnPageChangeListener extends ViewPager.SimpleOnPageChangeListener { - - /** - * Create a {@link OnPageChangeListener}. - */ - public OnPageChangeListener() { - } - @Override - public void onPageSelected(int position) { - GroupHolder.setUniquePrincipal(mListGroup, position); - if (groupGallery != null) { - groupGallery.setSelection(position); - } - mAdapterBanner.notifyDataSetChanged(); - } - } - - /** - * Event simple click on middle groupe name. - */ - private class OnItemClickGroupName implements OnItemClickListener { - - /** - * Constructor. - */ - public OnItemClickGroupName() { - } - - @Override - public void onItemClick(AdapterView arg0, View v, int i, long l) { - viewPager.setCurrentItem(i, true); - } - } - /** * PagerAdapter for the contact list. */ @@ -664,7 +557,7 @@ @Override public Fragment getItem(int position) { - String group = mListGroup.get(position).group; + String group = mListGroup.get(position); ContactListFragment f = ContactListFragment.newInstance(group); f.setListAdapter(getContactListAdapter(group)); return f; @@ -674,65 +567,12 @@ public int getCount() { return mListGroup.size(); } + + @Override + public String getPageTitle(int position) { + return mListGroup.get(position); + } } - /** - * A holder for a group name and is principal state. - * It is an helper class to manage the state of the tabs. - */ - private static class GroupHolder { - - String group; - boolean isPrincipal; - - /** - * Create a {@link GroupHolder}. - * @param group the group name - */ - public GroupHolder(final String group) { - this.group = group; - } - - /** - * Create a list of GroupHolder. - * @param groups list of group name - * @return a list of {@link GroupHolder} - */ - public static List createFrom(List groups) { - List result = new ArrayList(); - for (String s : groups) { - result.add(new GroupHolder(s)); - } - return result; - } - - /** - * Test if a group exist in a list of {@link GroupHolder}. - * @param list the list - * @param group the group - * @return true if the group is in the list false otherwise - */ - public static boolean contains(List list, String group) { - for (GroupHolder groupHolder : list) { - if (groupHolder.group.equals(group)) - return true; - } - return false; - } - - /** - * Set a unique principal in the {@link GroupHolder} list. - * @param groups the list - * @param position the position of the principal - */ - public static void setUniquePrincipal(List groups, int position) { - for (GroupHolder gh : groups) { - gh.isPrincipal = false; - } - groups.get(position).isPrincipal = true; - } - } - - } diff -r e1b1c8ad710a -r 7067aa267917 src/com/beem/project/beem/ui/views/SectionTextView.java --- a/src/com/beem/project/beem/ui/views/SectionTextView.java Fri May 18 00:25:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,220 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009-2011 by Frederic-Charles Barthelery, - Nikita Kozlov, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM 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 BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://www.beem-project.com/ - -*/ -package com.beem.project.beem.ui.views; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.util.AttributeSet; -import android.widget.TextView; - -import com.beem.project.beem.R; - -/** - * This class implements a custom TextView with an underscore section line. - * It can be used to make tabs. - * - */ -public class SectionTextView extends TextView { - private static final int DEFAULT_PRINCIPAL_COLOR = 0xffffffff; - private static final int DEFAULT_PRINCIPAL_LINE_SIZE = 8; - private static final int DEFAULT_NON_PRINCIPAL_COLOR = 0xff555555; - private static final int DEFAULT_NON_PRINCIPAL_LINE_SIZE = 3; - private static final int SECTION_SPACE_SIZE = 5; - private boolean principal; - private int principalColor; - private int nonPrincipalColor; - private float principalLineSize; - private float nonPrincipalLineSize; - private float density; - - private Paint sectionPaint; - - - /** - * Create a SectionTextView. - * - * @param context the android context - * @param attrs the android attributes - */ - public SectionTextView(final Context context, final AttributeSet attrs) { - super(context, attrs); - initSectionTextView(); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SectionTextView); - - principalColor = a.getColor(R.styleable.SectionTextView_principalColor, DEFAULT_PRINCIPAL_COLOR); - principalLineSize = a.getDimension(R.styleable.SectionTextView_principalLineSize, - DEFAULT_PRINCIPAL_LINE_SIZE * density); - nonPrincipalColor = a.getColor(R.styleable.SectionTextView_nonPrincipalColor, DEFAULT_NON_PRINCIPAL_COLOR); - nonPrincipalLineSize = a.getDimension(R.styleable.SectionTextView_nonPrincipalLineSize, - DEFAULT_NON_PRINCIPAL_LINE_SIZE * density); - - a.recycle(); - } - - /** - * Create a SectionTextView. - * - * @param context the android context - */ - public SectionTextView(final Context context) { - super(context); - initSectionTextView(); - } - - /** - * Set the textview in principal mode. - * It will show up with a distinctive color. - * - * @param principal the mode - */ - public void setPrincipal(boolean principal) { - this.principal = principal; - } - - /** - * Get the principal mode of the view. - * - * @return the mode - */ - public boolean isPrincipal() { - return principal; - } - - - /** - * Get the color used to show the view in principal mode. - * - * @return the color - */ - public int getPrincipalColor() { - return principalColor; - } - - /** - * Set the color used to show the view in principal mode. - * - * @param principalColor the color - */ - public void setPrincipalColor(int principalColor) { - this.principalColor = principalColor; - } - - /** - * Get the color used to show the view when not in principal mode. - * - * @return the color - */ - public int getNonPrincipalColor() { - return nonPrincipalColor; - } - - /** - * Set the color used to show the view when not in principal mode. - * - * @param nonPrincipalColor the color - */ - public void setNonPrincipalColor(int nonPrincipalColor) { - this.nonPrincipalColor = nonPrincipalColor; - } - - /** - * Get the size of the line section in principal mode. - * - * @return the size of the line - */ - public float getPrincipalLineSize() { - return principalLineSize; - } - - /** - * Set the size of the line section in principal mode. - * - * @param principalLineSize the size of the line - */ - public void setPrincipalLineSize(float principalLineSize) { - this.principalLineSize = principalLineSize; - } - - /** - * Get the size of the line section when not in principal mode. - * - * @return the size of the line - */ - public float getNonPrincipalLineSize() { - return nonPrincipalLineSize; - } - - /** - * Set the size of the line section when not in principal mode. - * - * @param nonPrincipalLineSize the size of the line - */ - public void setNonPrincipalLineSize(float nonPrincipalLineSize) { - this.nonPrincipalLineSize = nonPrincipalLineSize; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - int height = getMeasuredHeight(); - height += Math.max(principalLineSize, nonPrincipalLineSize) - + SECTION_SPACE_SIZE * density; // line width + space - setMeasuredDimension(getMeasuredWidth(), height); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - if (isPrincipal()) { - sectionPaint.setColor(principalColor); - sectionPaint.setStrokeWidth(principalLineSize); - canvas.drawLine(0, getHeight() - principalLineSize / 2, - getWidth(), getHeight() - principalLineSize / 2, sectionPaint); - } else { - sectionPaint.setColor(nonPrincipalColor); - sectionPaint.setStrokeWidth(nonPrincipalLineSize); - canvas.drawLine(0, getHeight() - nonPrincipalLineSize / 2, getWidth(), - getHeight() - nonPrincipalLineSize / 2, sectionPaint); - } - } - - /** - * Initialize the SectionTextView with the default value. - */ - private void initSectionTextView() { - density = getResources().getDisplayMetrics().density; - sectionPaint = new Paint(); - principalColor = DEFAULT_PRINCIPAL_COLOR; - principalLineSize = DEFAULT_PRINCIPAL_LINE_SIZE * density; - nonPrincipalColor = DEFAULT_NON_PRINCIPAL_COLOR; - nonPrincipalLineSize = DEFAULT_NON_PRINCIPAL_LINE_SIZE * density; - } - -}