Commit 23d2b953 authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'feature/contact_list_action_bar' into develop

parents ebcde01b 599d9bf9
......@@ -13,8 +13,8 @@ android {
applicationId "com.xabber.androiddev"
minSdkVersion 14
targetSdkVersion 21
versionCode 116
versionName '0.10.19'
versionCode 117
versionName '0.10.20'
}
sourceSets {
......
......@@ -40,7 +40,7 @@
android:theme="@style/Theme"
android:allowBackup="true">
<activity
android:label="@string/application_name"
android:label="@string/production_title"
android:name="com.xabber.android.ui.ContactList"
android:launchMode="singleTop"
>
......@@ -220,7 +220,6 @@
<activity
android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.preferences.ContactViewer"
android:icon="@drawable/ic_information"
android:parentActivityName="com.xabber.android.ui.ContactList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -388,10 +387,6 @@
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter"
/>
<meta-data
android:name="android.provider.CONTACTS_STRUCTURE"
android:resource="@xml/contacts_structure"
/>
</service>
<service
android:name="com.xabber.android.service.AccountAuthenticatorService"
......
......@@ -14,7 +14,6 @@
*/
package com.xabber.android.ui;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
......@@ -372,11 +371,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
insertExtraText();
updateRegisteredChats();
Fragment currentFragment = chatViewerAdapter.getCurrentFragment();
if (currentFragment instanceof ChatViewerFragment) {
((ChatViewerFragment)currentFragment).setInputFocus();
}
}
private void insertExtraText() {
......
......@@ -613,14 +613,6 @@ public class ChatViewerFragment extends Fragment {
return this.account.equals(account) && this.user.equals(user);
}
public void setInputFocus() {
inputView.requestFocus();
if (getActivity() != null) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(inputView.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
public void setInputText(String text) {
insertText(text);
}
......
......@@ -26,12 +26,15 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.SearchView;
import android.widget.Toast;
......@@ -41,6 +44,7 @@ import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.extension.muc.MUCManager;
......@@ -52,6 +56,7 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ContactListFragment.OnContactClickListener;
import com.xabber.android.ui.adapter.AccountToggleAdapter;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener;
import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
......@@ -70,7 +75,8 @@ import java.util.Collection;
*
* @author alexander.ivanov
*/
public class ContactList extends ManagedActivity implements OnChoosedListener, OnContactClickListener {
public class ContactList extends ManagedActivity implements OnAccountChangedListener,
View.OnClickListener, OnChoosedListener, OnContactClickListener {
/**
* Select contact to be invited to the room was requested.
......@@ -86,6 +92,11 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
private static final String CONTACT_LIST_TAG = "CONTACT_LIST";
/**
* Adapter for account list.
*/
private AccountToggleAdapter accountToggleAdapter;
/**
* Current action.
*/
......@@ -95,22 +106,40 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
* Dialog related values.
*/
private String sendText;
private SearchView searchView;
private View actionBarView;
@Override
public void onCreate(Bundle savedInstanceState) {
if (Intent.ACTION_VIEW.equals(getIntent().getAction())
|| Intent.ACTION_SEND.equals(getIntent().getAction())
|| Intent.ACTION_SENDTO.equals(getIntent().getAction())
|| Intent.ACTION_CREATE_SHORTCUT
.equals(getIntent().getAction()))
|| Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
ActivityManager.getInstance().startNewTask(this);
}
super.onCreate(savedInstanceState);
if (isFinishing())
if (isFinishing()) {
return;
}
setContentView(R.layout.contact_list);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBarView = LayoutInflater.from(this).inflate(R.layout.contact_list_action_bar, null);
actionBarView.setOnClickListener(this);
actionBar.setCustomView(actionBarView, new ActionBar.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
accountToggleAdapter = new AccountToggleAdapter(this, this,
(LinearLayout) actionBarView.findViewById(R.id.account_list));
if (savedInstanceState != null) {
sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
......@@ -150,29 +179,33 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
*/
private void openChat(String user, String text) {
String bareAddress = Jid.getBareAddress(user);
ArrayList<BaseEntity> entities = new ArrayList<BaseEntity>();
for (AbstractChat check : MessageManager.getInstance().getChats())
if (check.isActive() && check.getUser().equals(bareAddress))
ArrayList<BaseEntity> entities = new ArrayList<>();
for (AbstractChat check : MessageManager.getInstance().getChats()) {
if (check.isActive() && check.getUser().equals(bareAddress)) {
entities.add(check);
}
}
if (entities.size() == 1) {
openChat(entities.get(0), text);
return;
}
entities.clear();
for (RosterContact check : RosterManager.getInstance().getContacts())
if (check.isEnabled() && check.getUser().equals(bareAddress))
for (RosterContact check : RosterManager.getInstance().getContacts()) {
if (check.isEnabled() && check.getUser().equals(bareAddress)) {
entities.add(check);
}
}
if (entities.size() == 1) {
openChat(entities.get(0), text);
return;
}
Collection<String> accounts = AccountManager.getInstance()
.getAccounts();
if (accounts.isEmpty())
if (accounts.isEmpty()) {
return;
}
if (accounts.size() == 1) {
openChat(new BaseEntity(accounts.iterator().next(), bareAddress),
text);
openChat(new BaseEntity(accounts.iterator().next(), bareAddress), text);
return;
}
AccountChooseDialogFragment.newInstance(bareAddress, text)
......@@ -186,27 +219,31 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
* @param text can be <code>null</code>.
*/
private void openChat(BaseEntity baseEntity, String text) {
if (text == null)
if (text == null) {
startActivity(ChatViewer.createSendIntent(this,
baseEntity.getAccount(), baseEntity.getUser(), null));
else
} else {
startActivity(ChatViewer.createSendIntent(this,
baseEntity.getAccount(), baseEntity.getUser(), text));
}
finish();
}
@Override
protected void onResume() {
super.onResume();
rebuildAccountToggle();
Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
if (action != null) {
switch (action) {
case ContactList.ACTION_ROOM_INVITE:
case Intent.ACTION_SEND:
case Intent.ACTION_CREATE_SHORTCUT:
if (Intent.ACTION_SEND.equals(action))
if (Intent.ACTION_SEND.equals(action)) {
sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
Toast.makeText(this, getString(R.string.select_contact),
Toast.LENGTH_LONG).show();
}
Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show();
break;
case Intent.ACTION_VIEW: {
action = null;
......@@ -221,8 +258,9 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
if (xmppUri != null && "message".equals(xmppUri.getQueryType())) {
ArrayList<String> texts = xmppUri.getValues("body");
String text = null;
if (texts != null && !texts.isEmpty())
if (texts != null && !texts.isEmpty()) {
text = texts.get(0);
}
openChat(xmppUri.getPath(), text);
}
}
......@@ -233,25 +271,28 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
Uri data = getIntent().getData();
if (data != null) {
String path = data.getPath();
if (path != null && path.startsWith("/"))
if (path != null && path.startsWith("/")) {
openChat(path.substring(1), null);
}
}
break;
}
}
}
if (Application.getInstance().doNotify()) {
if (SettingsManager.bootCount() > 2
&& !SettingsManager.connectionStartAtBoot()
&& !SettingsManager.startAtBootSuggested())
if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot()
&& !SettingsManager.startAtBootSuggested()) {
StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
}
if (!SettingsManager.contactIntegrationSuggested()
&& Application.getInstance().isContactsSupported()) {
if (AccountManager.getInstance().getAllAccounts().isEmpty())
if (AccountManager.getInstance().getAllAccounts().isEmpty()) {
SettingsManager.setContactIntegrationSuggested();
else
ContactIntegrationDialogFragment.newInstance().show(
getFragmentManager(), "CONTACT_INTEGRATION");
} else {
ContactIntegrationDialogFragment.newInstance()
.show(getFragmentManager(), "CONTACT_INTEGRATION");
}
}
}
}
......@@ -260,6 +301,7 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
protected void onPause() {
super.onPause();
hideKeyboard();
Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
}
private void hideKeyboard() {
......@@ -277,13 +319,14 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
return true;
}
private void setUpSearchView(Menu menu) {
private void setUpSearchView(final Menu menu) {
searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQueryHint("Search contact");
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
menu.findItem(R.id.action_search).collapseActionView();
return true;
}
});
......@@ -326,11 +369,8 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_search:
searchView.setIconified(false);
return true;
case R.id.action_change_status:
startActivity(StatusEditor.createIntent(this));
return true;
......@@ -371,12 +411,10 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
}
private void closeAllChats() {
for (AbstractChat chat : MessageManager.getInstance()
.getActiveChats()) {
MessageManager.getInstance().closeChat(chat.getAccount(),
chat.getUser());
NotificationManager.getInstance().removeMessageNotification(
chat.getAccount(), chat.getUser());
for (AbstractChat chat : MessageManager.getInstance().getActiveChats()) {
MessageManager.getInstance().closeChat(chat.getAccount(), chat.getUser());
NotificationManager.getInstance().
removeMessageNotification(chat.getAccount(), chat.getUser());
}
getContactListFragment().getAdapter().onChange();
}
......@@ -386,8 +424,7 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenuInfo menuInfo) {
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
}
......@@ -397,8 +434,7 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
switch (id) {
case DIALOG_CLOSE_APPLICATION_ID:
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog
.setMessage(getString(R.string.application_state_closing));
progressDialog.setMessage(getString(R.string.application_state_closing));
progressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
......@@ -412,65 +448,110 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
}
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case android.R.id.title:
getContactListFragment().scrollUp();
break;
default:
String account = accountToggleAdapter.getItemForView(view);
if (account == null) { // Check for tap on account in the title
break;
}
if (!SettingsManager.contactsShowAccounts()) {
if (AccountManager.getInstance().getAccounts().size() < 2) {
getContactListFragment().scrollUp();
} else {
getContactListFragment().setSelectedAccount(account);
rebuildAccountToggle();
}
} else {
getContactListFragment().scrollTo(account);
}
break;
}
}
@Override
public void onContactClick(AbstractContact abstractContact) {
if (ACTION_ROOM_INVITE.equals(action)) {
action = null;
Intent intent = getIntent();
String account = getRoomInviteAccount(intent);
String user = getRoomInviteUser(intent);
if (account != null && user != null)
try {
MUCManager.getInstance().invite(account, user,
abstractContact.getUser());
} catch (NetworkException e) {
Application.getInstance().onError(e);
switch (action) {
case ACTION_ROOM_INVITE: {
action = null;
Intent intent = getIntent();
String account = getRoomInviteAccount(intent);
String user = getRoomInviteUser(intent);
if (account != null && user != null) {
try {
MUCManager.getInstance().invite(account, user, abstractContact.getUser());
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
finish();
} else if (Intent.ACTION_SEND.equals(action)) {
action = null;
startActivity(ChatViewer.createSendIntent(this,
abstractContact.getAccount(), abstractContact.getUser(),
sendText));
finish();
} else if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
Intent intent = new Intent();
intent.putExtra(
Intent.EXTRA_SHORTCUT_INTENT,
ChatViewer.createClearTopIntent(this,
abstractContact.getAccount(),
abstractContact.getUser()));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
abstractContact.getName());
Bitmap bitmap;
if (MUCManager.getInstance().hasRoom(abstractContact.getAccount(),
abstractContact.getUser()))
bitmap = AvatarManager.getInstance().getRoomBitmap(
abstractContact.getUser());
else
bitmap = AvatarManager.getInstance().getUserBitmap(
abstractContact.getUser());
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, AvatarManager
.getInstance().createShortcutBitmap(bitmap));
setResult(RESULT_OK, intent);
finish();
finish();
break;
}
case Intent.ACTION_SEND:
action = null;
startActivity(ChatViewer.createSendIntent(this,
abstractContact.getAccount(), abstractContact.getUser(), sendText));
finish();
break;
case Intent.ACTION_CREATE_SHORTCUT: {
createShortcut(abstractContact);
finish();
break;
}
default:
startActivity(ChatViewer.createIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
break;
}
}
private void createShortcut(AbstractContact abstractContact) {
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, ChatViewer.createClearTopIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, abstractContact.getName());
Bitmap bitmap;
if (MUCManager.getInstance().hasRoom(abstractContact.getAccount(),
abstractContact.getUser())) {
bitmap = AvatarManager.getInstance().getRoomBitmap(abstractContact.getUser());
} else {
startActivity(ChatViewer.createIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
bitmap = AvatarManager.getInstance().getUserBitmap(abstractContact.getUser());
}
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON,
AvatarManager.getInstance().createShortcutBitmap(bitmap));
setResult(RESULT_OK, intent);
}
@Override
public void onChoosed(String account, String user, String text) {
public void onAccountsChanged(Collection<String> accounts) {
accountToggleAdapter.onChange();
}
@Override
public void onChoose(String account, String user, String text) {
openChat(new BaseEntity(account, user), text);
}
private void rebuildAccountToggle() {
accountToggleAdapter.rebuild();
if (SettingsManager.contactsShowPanel() && accountToggleAdapter.getCount() > 0) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
actionBarView.setVisibility(View.VISIBLE);
} else {
actionBarView.setVisibility(View.GONE);
getSupportActionBar().setDisplayShowTitleEnabled(true);
}
}
public static Intent createPersistentIntent(Context context) {
Intent intent = new Intent(context, ContactList.class);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
......@@ -478,8 +559,7 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
return new Intent(context, ContactList.class);
}
public static Intent createRoomInviteIntent(Context context,
String account, String room) {
public static Intent createRoomInviteIntent(Context context, String account, String room) {
Intent intent = new EntityIntentBuilder(context, ContactList.class)
.setAccount(account).setUser(room).build();
intent.setAction(ACTION_ROOM_INVITE);
......
......@@ -43,9 +43,8 @@ import com.xabber.androiddev.R;
import java.util.Collection;
public class ContactListFragment extends Fragment implements
OnAccountChangedListener, OnContactChangedListener,
OnChatChangedListener, OnItemClickListener,
public class ContactListFragment extends Fragment implements OnAccountChangedListener,
OnContactChangedListener, OnChatChangedListener, OnItemClickListener,
OnContactListChangedListener {
private ContactListAdapter adapter;
......@@ -85,8 +84,7 @@ public class ContactListFragment extends Fragment implements
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.contact_list_fragment, container,
false);
View view = inflater.inflate(R.layout.contact_list_fragment, container, false);
listView = (ListView) view.findViewById(android.R.id.list);
listView.setOnItemClickListener(this);
listView.setItemsCanFocus(true);
......@@ -98,20 +96,16 @@ public class ContactListFragment extends Fragment implements
disconnectedView = infoView.findViewById(R.id.disconnected);
textView = (TextView) infoView.findViewById(R.id.text);
buttonView = (Button) infoView.findViewById(R.id.button);
animation = AnimationUtils.loadAnimation(getActivity(),
R.anim.connection);
animation = AnimationUtils.loadAnimation(getActivity(), R.anim.connection);
return view;
}
@Override
public void onResume() {
super.onResume();
Application.getInstance().addUIListener(OnAccountChangedListener.class,
this);
Application.getInstance().addUIListener(OnContactChangedListener.class,
this);
Application.getInstance().addUIListener(OnChatChangedListener.class,
this);
Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
Application.getInstance().addUIListener(OnContactChangedListener.class, this);
Application.getInstance().addUIListener(OnChatChangedListener.class, this);
adapter.onChange();
}
......@@ -122,38 +116,35 @@ public class ContactListFragment extends Fragment implements
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenuInfo menuInfo) {
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
BaseEntity baseEntity = (BaseEntity) listView
.getItemAtPosition(info.position);
BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(info.position);
if (baseEntity instanceof AbstractContact) {
ContextMenuHelper.createContactContextMenu(getActivity(), adapter,
(AbstractContact) baseEntity, menu);
ContextMenuHelper.createContactContextMenu(
getActivity(), adapter, (AbstractContact) baseEntity, menu);
} else if (baseEntity instanceof AccountConfiguration) {
ContextMenuHelper.createAccountContextMenu(getActivity(), adapter,
baseEntity.getAccount(), menu);
ContextMenuHelper.createAccountContextMenu(
getActivity(), adapter, baseEntity.getAccount(), menu);
} else if (baseEntity instanceof GroupConfiguration) {
ContextMenuHelper.createGroupContextMenu(getActivity(), adapter,
baseEntity.getAccount(), baseEntity.getUser(), menu);
} else
} else {
throw new IllegalStateException();
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Object object = parent.getAdapter().getItem(position);
if (object instanceof AbstractContact) {
((OnContactClickListener) getActivity())
.onContactClick((AbstractContact) object);
((OnContactClickListener) getActivity()).onContactClick((AbstractContact) object);
} else if (object instanceof GroupConfiguration) {
GroupConfiguration groupConfiguration = (GroupConfiguration) object;
adapter.setExpanded(groupConfiguration.getAccount(),
groupConfiguration.getUser(),
adapter.setExpanded(groupConfiguration.getAccount(), groupConfiguration.getUser(),
!groupConfiguration.isExpanded());
} else
} else {
throw new IllegalStateException();
}
}
@Override
......@@ -168,14 +159,14 @@ public class ContactListFragment extends Fragment implements
@Override
public void onChatChanged(String account, String user, boolean incoming) {
if (incoming)
if (incoming) {
adapter.refreshRequest();
}
}
@Override
public void onContactListChanged(CommonState commonState,
boolean hasContacts, boolean hasVisibleContacts,
boolean isFilterEnabled) {
public void onContactListChanged(CommonState commonState, boolean hasContacts,
boolean hasVisibleContacts, boolean isFilterEnabled) {
if (hasVisibleContacts) {
infoView.setVisibility(View.GONE);
disconnectedView.clearAnimation();
......@@ -187,13 +178,13 @@ public class ContactListFragment extends Fragment implements
final ContactListState state;
final OnClickListener listener;
if (isFilterEnabled) {
if (commonState == CommonState.online)
if (commonState == CommonState.online) {
state = ContactListState.online;
else if (commonState == CommonState.roster
|| commonState == CommonState.connecting)
} else if (commonState == CommonState.roster || commonState == CommonState.connecting) {
state = ContactListState.connecting;
else
} else {
state = ContactListState.offline;
}
text = R.string.application_state_no_online;
button = 0;
listener = null;
......@@ -202,25 +193,21 @@ public class ContactListFragment extends Fragment implements
text = R.string.application_state_no_online;
button = R.string.application_action_no_online;
listener = new OnClickListener() {
@Override
public void onClick(View view) {
SettingsManager.setContactsShowOffline(true);
adapter.onChange();
}
};
} else if (commonState == CommonState.online) {
state = ContactListState.online;
text = R.string.application_state_no_contacts;
button = R.string.application_action_no_contacts;
listener = new OnClickListener() {
@Override
public void onClick(View view) {
startActivity(ContactAdd.createIntent(getActivity()));
}
};
} else if (commonState == CommonState.roster) {
state = ContactListState.connecting;
......@@ -237,49 +224,41 @@ public class ContactListFragment extends Fragment implements
text = R.string.application_state_waiting;
button = R.string.application_action_waiting;
listener = new OnClickListener() {
@Override
public void onClick(View view) {
ConnectionManager.getInstance().updateConnections(true);
}
};
} else if (commonState == CommonState.offline) {
state = ContactListState.offline;
text = R.string.application_state_offline;
button = R.string.application_action_offline;
listener = new OnClickListener() {
@Override
public void onClick(View view) {
AccountManager.getInstance().setStatus(
StatusMode.available, null);
}
};
} else if (commonState == CommonState.disabled) {
state = ContactListState.offline;
text = R.string.application_state_disabled;
button = R.string.application_action_disabled;
listener = new OnClickListener() {
@Override
public void onClick(View view) {
startActivity(AccountList.createIntent(getActivity()));
}
};
} else if (commonState == CommonState.empty) {
state = ContactListState.offline;
text = R.string.application_state_empty;
button = R.string.application_action_empty;
listener = new OnClickListener() {
@Override
public void onClick(View view) {
startActivity(AccountAdd.createIntent(getActivity()));
}
};
} else {
throw new IllegalStateException();
......@@ -291,9 +270,10 @@ public class ContactListFragment extends Fragment implements
} else if (state == ContactListState.connecting) {
connectedView.setVisibility(View.VISIBLE);
disconnectedView.setVisibility(View.VISIBLE);
if (disconnectedView.getAnimation() == null)
if (disconnectedView.getAnimation() == null) {
disconnectedView.startAnimation(animation);
} else if (state == ContactListState.online) {
}
} else {
connectedView.setVisibility(View.VISIBLE);
disconnectedView.setVisibility(View.INVISIBLE);
disconnectedView.clearAnimation();
......@@ -312,12 +292,9 @@ public class ContactListFragment extends Fragment implements
* Force stop contact list updates before pause or application close.
*/
void unregisterListeners() {
Application.getInstance().removeUIListener(
OnAccountChangedListener.class, this);
Application.getInstance().removeUIListener(
OnContactChangedListener.class, this);
Application.getInstance().removeUIListener(OnChatChangedListener.class,
this);
Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
Application.getInstance().removeUIListener(OnContactChangedListener.class, this);
Application.getInstance().removeUIListener(OnChatChangedListener.class, this);
adapter.removeRefreshRequests();
}
......@@ -337,10 +314,8 @@ public class ContactListFragment extends Fragment implements
void scrollTo(String account) {
long count = listView.getCount();
for (int position = 0; position < (int) count; position++) {
BaseEntity baseEntity = (BaseEntity) listView
.getItemAtPosition(position);
if (baseEntity != null
&& baseEntity instanceof AccountConfiguration
BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(position);
if (baseEntity != null && baseEntity instanceof AccountConfiguration
&& baseEntity.getAccount().equals(account)) {
stopMovement();
listView.setSelection(position);
......@@ -355,10 +330,11 @@ public class ContactListFragment extends Fragment implements
* @param account
*/
void setSelectedAccount(String account) {
if (account.equals(AccountManager.getInstance().getSelectedAccount()))
if (account.equals(AccountManager.getInstance().getSelectedAccount())) {
SettingsManager.setContactsSelectedAccount("");
else
} else {
SettingsManager.setContactsSelectedAccount(account);
}
stopMovement();
adapter.onChange();
}
......@@ -367,8 +343,9 @@ public class ContactListFragment extends Fragment implements
* Scroll to the top of contact list.
*/
void scrollUp() {
if (listView.getCount() > 0)
if (listView.getCount() > 0) {
listView.setSelection(0);
}
stopMovement();
}
......@@ -383,9 +360,7 @@ public class ContactListFragment extends Fragment implements
}
public interface OnContactClickListener {
void onContactClick(AbstractContact contact);
}
}
......@@ -14,9 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collections;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
......@@ -24,12 +21,14 @@ import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
/**
* Adapter for the list of accounts in the title of contact list.
*
......@@ -60,7 +59,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
this.activity = activity;
this.onClickListener = onClickListener;
this.linearLayout = linearLayout;
accounts = new ArrayList<String>();
accounts = new ArrayList<>();
}
/**
......@@ -76,48 +75,36 @@ public class AccountToggleAdapter implements UpdatableAdapter {
final LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
while (linearLayout.getChildCount() < size) {
final View view = inflater.inflate(R.layout.account_toggler_item,
linearLayout, false);
final View view = inflater.inflate(R.layout.account_toggler_item, linearLayout, false);
linearLayout.addView(view);
final AccountViewHolder accountViewHolder = new AccountViewHolder(
view);
final AccountViewHolder accountViewHolder = new AccountViewHolder(view);
view.setTag(accountViewHolder);
activity.registerForContextMenu(accountViewHolder.statusMode);
accountViewHolder.statusMode.setOnClickListener(onClickListener);
}
while (linearLayout.getChildCount() > size)
while (linearLayout.getChildCount() > size) {
linearLayout.removeViewAt(size);
}
onChange();
}
@Override
public void onChange() {
boolean contactsShowAccounts = SettingsManager.contactsShowAccounts();
String selected = AccountManager.getInstance().getSelectedAccount();
for (int index = 0; index < accounts.size(); index++) {
final View view = linearLayout.getChildAt(index);
final AccountViewHolder accountViewHolder = (AccountViewHolder) view
.getTag();
final AccountViewHolder accountViewHolder = (AccountViewHolder) view.getTag();
final String account = accounts.get(index);
StatusMode statusMode = AccountManager.getInstance()
.getAccount(account).getDisplayStatusMode();
int colorLevel = AccountManager.getInstance()
.getColorLevel(account);
StatusMode statusMode = AccountManager.getInstance().getAccount(account).getDisplayStatusMode();
int colorLevel = AccountManager.getInstance().getColorLevel(account);
view.getBackground().setLevel(colorLevel);
if (contactsShowAccounts)
accountViewHolder.statusMode
.setBackgroundResource(R.drawable.account_border);
else
accountViewHolder.statusMode
.setBackgroundResource(R.drawable.account_border_persistent);
if (selected == null || account.equals(selected))
if (selected == null || account.equals(selected)) {
accountViewHolder.disabled.setVisibility(View.GONE);
else
} else {
accountViewHolder.disabled.setVisibility(View.VISIBLE);
accountViewHolder.statusMode.getBackground().setLevel(colorLevel);
}
accountViewHolder.statusMode.setImageLevel(statusMode.ordinal());
accountViewHolder.avatar.setImageDrawable(AvatarManager
.getInstance().getAccountAvatar(account));
accountViewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
}
}
......@@ -137,11 +124,14 @@ public class AccountToggleAdapter implements UpdatableAdapter {
* @return The data for the specified view.
*/
public String getItemForView(View view) {
if (view.getId() == R.id.status_mode)
if (view.getId() == R.id.status_mode) {
view = (View) view.getParent();
for (int index = 0; index < linearLayout.getChildCount(); index++)
if (view == linearLayout.getChildAt(index))
}
for (int index = 0; index < linearLayout.getChildCount(); index++) {
if (view == linearLayout.getChildAt(index)) {
return accounts.get(index);
}
}
return null;
}
......
......@@ -14,9 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Locale;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
......@@ -27,6 +24,9 @@ import android.widget.Filterable;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.roster.AbstractContact;
import java.util.ArrayList;
import java.util.Locale;
/**
* Base adapter for the list of contacts.
*
......@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
public BaseContactAdapter(Activity activity, Inflater inflater) {
this.activity = activity;
this.locale = Locale.getDefault();
this.baseEntities = new ArrayList<BaseEntity>();
this.baseEntities = new ArrayList<>();
this.inflater = inflater;
inflater.setAdapter(this);
contactFilter = null;
filterString = null;
}
/**
* @return View inflater.
*/
public Inflater getInflater() {
return inflater;
}
@Override
public void onChange() {
notifyDataSetChanged();
......@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override
public Filter getFilter() {
if (contactFilter == null)
if (contactFilter == null) {
contactFilter = new ContactFilter();
}
return contactFilter;
}
......@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
if (constraint == null || constraint.length() == 0)
if (constraint == null || constraint.length() == 0) {
filterString = null;
else
} else {
filterString = constraint.toString().toLowerCase(locale);
}
onChange();
}
......
......@@ -59,14 +59,11 @@ public abstract class BaseContactInflater {
public BaseContactInflater(Activity activity) {
this.activity = activity;
layoutInflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
avatarInflaterHelper = AbstractAvatarInflaterHelper
.createAbstractContactInflaterHelper();
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(),
R.drawable.shadow);
shadowDrawable = new BitmapDrawable(bitmap);
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
avatarInflaterHelper = AbstractAvatarInflaterHelper.createAbstractContactInflaterHelper();
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
}
......@@ -115,19 +112,18 @@ public abstract class BaseContactInflater {
*/
public void getView(View view, AbstractContact abstractContact) {
final ViewHolder viewHolder = (ViewHolder) view.getTag();
if (abstractContact.isConnected())
if (abstractContact.isConnected()) {
viewHolder.shadow.setVisibility(View.GONE);
else
} else {
viewHolder.shadow.setVisibility(View.VISIBLE);
}
viewHolder.color.setImageLevel(abstractContact.getColorLevel());
if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(abstractContact
.getAvatarForContactList());
avatarInflaterHelper.updateAvatar(viewHolder.avatar,
abstractContact);
viewHolder.avatar.setImageDrawable(abstractContact.getAvatarForContactList());
avatarInflaterHelper.updateAvatar(viewHolder.avatar, abstractContact);
((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams())
.addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
} else {
......@@ -140,14 +136,12 @@ public abstract class BaseContactInflater {
final String statusText = getStatusText(abstractContact);
if ("".equals(statusText)) {
viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize(
R.dimen.contact_name_height_hide_status);
.getDimensionPixelSize(R.dimen.contact_name_height_hide_status);
viewHolder.name.setGravity(Gravity.CENTER_VERTICAL);
viewHolder.status.setVisibility(View.GONE);
} else {
viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize(
R.dimen.contact_name_height_show_status);
.getDimensionPixelSize(R.dimen.contact_name_height_show_status);
viewHolder.name.setGravity(Gravity.BOTTOM);
viewHolder.status.setText(statusText);
viewHolder.status.setVisibility(View.VISIBLE);
......
......@@ -185,19 +185,6 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
public void onChatViewAdapterFinishUpdate();
}
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
if (getCurrentFragment() != object) {
currentFragment = ((Fragment) object);
}
super.setPrimaryItem(container, position, object);
}
public Fragment getCurrentFragment() {
return currentFragment;
}
public ArrayList<AbstractChat> getActiveChats() {
return activeChats;
}
......
......@@ -14,14 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Map.Entry;
import java.util.TreeMap;
import android.app.Activity;
import android.os.Handler;
import android.widget.ListView;
......@@ -39,14 +31,21 @@ import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Map.Entry;
import java.util.TreeMap;
/**
* Adapter for contact list in the main activity.
*
* @author alexander.ivanov
*/
public class ContactListAdapter extends
GroupedContactAdapter<ChatContactInflater, GroupManager> implements
Runnable {
public class ContactListAdapter extends GroupedContactAdapter<ChatContactInflater, GroupManager>
implements Runnable {
/**
* Number of milliseconds between lazy refreshes.
......@@ -71,7 +70,7 @@ public class ContactListAdapter extends
/**
* Whether refresh is in progress.
*/
private boolean refreshInProgess;
private boolean refreshInProgress;
/**
* Minimal time when next refresh can be executed.
......@@ -80,15 +79,14 @@ public class ContactListAdapter extends
private final OnContactListChangedListener listener;
public ContactListAdapter(Activity activity, ListView listView,
OnContactListChangedListener listener) {
super(activity, listView, new ChatContactInflater(activity),
GroupManager.getInstance());
public ContactListAdapter(
Activity activity, ListView listView, OnContactListChangedListener listener) {
super(activity, listView, new ChatContactInflater(activity), GroupManager.getInstance());
this.listener = listener;
handler = new Handler();
refreshLock = new Object();
refreshRequested = false;
refreshInProgess = false;
refreshInProgress = false;
nextRefresh = new Date();
}
......@@ -97,11 +95,12 @@ public class ContactListAdapter extends
*/
public void refreshRequest() {
synchronized (refreshLock) {
if (refreshRequested)
if (refreshRequested) {
return;
if (refreshInProgess)
}
if (refreshInProgress) {
refreshRequested = true;
else {
} else {
long delay = nextRefresh.getTime() - new Date().getTime();
handler.postDelayed(this, delay > 0 ? delay : 0);
}
......@@ -114,7 +113,7 @@ public class ContactListAdapter extends
public void removeRefreshRequests() {
synchronized (refreshLock) {
refreshRequested = false;
refreshInProgess = false;
refreshInProgress = false;
handler.removeCallbacks(this);
}
}
......@@ -123,32 +122,25 @@ public class ContactListAdapter extends
public void onChange() {
synchronized (refreshLock) {
refreshRequested = false;
refreshInProgess = true;
refreshInProgress = true;
handler.removeCallbacks(this);
}
final Collection<RosterContact> rosterContacts = RosterManager
.getInstance().getContacts();
final Collection<RosterContact> rosterContacts = RosterManager.getInstance().getContacts();
final boolean showOffline = SettingsManager.contactsShowOffline();
final boolean showGroups = SettingsManager.contactsShowGroups();
final boolean showEmptyGroups = SettingsManager
.contactsShowEmptyGroups();
final boolean showActiveChats = SettingsManager
.contactsShowActiveChats();
final boolean stayActiveChats = SettingsManager
.contactsStayActiveChats();
final boolean showEmptyGroups = SettingsManager.contactsShowEmptyGroups();
final boolean showActiveChats = SettingsManager.contactsShowActiveChats();
final boolean stayActiveChats = SettingsManager.contactsStayActiveChats();
final boolean showAccounts = SettingsManager.contactsShowAccounts();
final Comparator<AbstractContact> comparator = SettingsManager
.contactsOrder();
final CommonState commonState = AccountManager.getInstance()
.getCommonState();
final String selectedAccount = AccountManager.getInstance()
.getSelectedAccount();
final Comparator<AbstractContact> comparator = SettingsManager.contactsOrder();
final CommonState commonState = AccountManager.getInstance().getCommonState();
final String selectedAccount = AccountManager.getInstance().getSelectedAccount();
/**
* Accounts.
*/
final TreeMap<String, AccountConfiguration> accounts = new TreeMap<String, AccountConfiguration>();
final TreeMap<String, AccountConfiguration> accounts = new TreeMap<>();
/**
* Groups.
......@@ -168,7 +160,7 @@ public class ContactListAdapter extends
/**
* List of rooms and active chats grouped by users inside accounts.
*/
final TreeMap<String, TreeMap<String, AbstractChat>> abstractChats = new TreeMap<String, TreeMap<String, AbstractChat>>();
final TreeMap<String, TreeMap<String, AbstractChat>> abstractChats = new TreeMap<>();
/**
* Whether there is at least one contact.
......@@ -180,18 +172,17 @@ public class ContactListAdapter extends
*/
boolean hasVisibleContacts = false;
for (String account : AccountManager.getInstance().getAccounts())
for (String account : AccountManager.getInstance().getAccounts()) {
accounts.put(account, null);
}
for (AbstractChat abstractChat : MessageManager.getInstance()
.getChats()) {
for (AbstractChat abstractChat : MessageManager.getInstance().getChats()) {
if ((abstractChat instanceof RoomChat || abstractChat.isActive())
&& accounts.containsKey(abstractChat.getAccount())) {
final String account = abstractChat.getAccount();
TreeMap<String, AbstractChat> users = abstractChats
.get(account);
TreeMap<String, AbstractChat> users = abstractChats.get(account);
if (users == null) {
users = new TreeMap<String, AbstractChat>();
users = new TreeMap<>();
abstractChats.put(account, users);
}
users.put(abstractChat.getUser(), abstractChat);
......@@ -203,77 +194,82 @@ public class ContactListAdapter extends
if (showAccounts) {
groups = null;
contacts = null;
for (Entry<String, AccountConfiguration> entry : accounts
.entrySet()) {
for (Entry<String, AccountConfiguration> entry : accounts.entrySet()) {
entry.setValue(new AccountConfiguration(entry.getKey(),
GroupManager.IS_ACCOUNT, groupStateProvider));
}
} else {
if (showGroups) {
groups = new TreeMap<String, GroupConfiguration>();
groups = new TreeMap<>();
contacts = null;
} else {
groups = null;
contacts = new ArrayList<AbstractContact>();
contacts = new ArrayList<>();
}
}
if (showActiveChats)
if (showActiveChats) {
activeChats = new GroupConfiguration(GroupManager.NO_ACCOUNT,
GroupManager.ACTIVE_CHATS, groupStateProvider);
else
} else {
activeChats = null;
}
// Build structure.
for (RosterContact rosterContact : rosterContacts) {
if (!rosterContact.isEnabled())
if (!rosterContact.isEnabled()) {
continue;
}
hasContacts = true;
final boolean online = rosterContact.getStatusMode().isOnline();
final String account = rosterContact.getAccount();
final TreeMap<String, AbstractChat> users = abstractChats
.get(account);
final TreeMap<String, AbstractChat> users = abstractChats.get(account);
final AbstractChat abstractChat;
if (users == null)
if (users == null) {
abstractChat = null;
else
} else {
abstractChat = users.remove(rosterContact.getUser());
if (showActiveChats && abstractChat != null
&& abstractChat.isActive()) {
}
if (showActiveChats && abstractChat != null && abstractChat.isActive()) {
activeChats.setNotEmpty();
hasVisibleContacts = true;
if (activeChats.isExpanded())
if (activeChats.isExpanded()) {
activeChats.addAbstractContact(rosterContact);
}
activeChats.increment(online);
if (!stayActiveChats || (!showAccounts && !showGroups))
if (!stayActiveChats || (!showAccounts && !showGroups)) {
continue;
}
}
if (selectedAccount != null && !selectedAccount.equals(account))
if (selectedAccount != null && !selectedAccount.equals(account)) {
continue;
}
if (addContact(rosterContact, online, accounts, groups,
contacts, showAccounts, showGroups, showOffline))
contacts, showAccounts, showGroups, showOffline)) {
hasVisibleContacts = true;
}
}
for (TreeMap<String, AbstractChat> users : abstractChats.values())
for (TreeMap<String, AbstractChat> users : abstractChats.values()) {
for (AbstractChat abstractChat : users.values()) {
final AbstractContact abstractContact;
if (abstractChat instanceof RoomChat)
abstractContact = new RoomContact(
(RoomChat) abstractChat);
else
if (abstractChat instanceof RoomChat) {
abstractContact = new RoomContact((RoomChat) abstractChat);
} else {
abstractContact = new ChatContact(abstractChat);
}
if (showActiveChats && abstractChat.isActive()) {
activeChats.setNotEmpty();
hasVisibleContacts = true;
if (activeChats.isExpanded())
if (activeChats.isExpanded()) {
activeChats.addAbstractContact(abstractContact);
}
activeChats.increment(false);
if (!stayActiveChats || (!showAccounts && !showGroups))
if (!stayActiveChats || (!showAccounts && !showGroups)) {
continue;
}
}
if (selectedAccount != null
&& !selectedAccount.equals(abstractChat
.getAccount()))
if (selectedAccount != null && !selectedAccount.equals(abstractChat.getAccount())) {
continue;
}
final String group;
final boolean online;
if (abstractChat instanceof RoomChat) {
......@@ -284,19 +280,20 @@ public class ContactListAdapter extends
online = false;
}
hasVisibleContacts = true;
addContact(abstractContact, group, online, accounts,
groups, contacts, showAccounts, showGroups);
addContact(abstractContact, group, online, accounts, groups, contacts,
showAccounts, showGroups);
}
}
// Remove empty groups, sort and apply structure.
baseEntities.clear();
if (hasVisibleContacts) {
if (showActiveChats) {
if (!activeChats.isEmpty()) {
if (showAccounts || showGroups)
if (showAccounts || showGroups) {
baseEntities.add(activeChats);
activeChats
.sortAbstractContacts(ComparatorByChat.COMPARATOR_BY_CHAT);
}
activeChats.sortAbstractContacts(ComparatorByChat.COMPARATOR_BY_CHAT);
baseEntities.addAll(activeChats.getAbstractContacts());
}
}
......@@ -304,35 +301,30 @@ public class ContactListAdapter extends
for (AccountConfiguration rosterAccount : accounts.values()) {
baseEntities.add(rosterAccount);
if (showGroups) {
if (rosterAccount.isExpanded())
if (rosterAccount.isExpanded()) {
for (GroupConfiguration rosterConfiguration : rosterAccount
.getSortedGroupConfigurations())
if (showEmptyGroups
|| !rosterConfiguration.isEmpty()) {
.getSortedGroupConfigurations()) {
if (showEmptyGroups || !rosterConfiguration.isEmpty()) {
baseEntities.add(rosterConfiguration);
rosterConfiguration
.sortAbstractContacts(comparator);
baseEntities.addAll(rosterConfiguration
.getAbstractContacts());
rosterConfiguration.sortAbstractContacts(comparator);
baseEntities.addAll(rosterConfiguration.getAbstractContacts());
}
}
}
} else {
rosterAccount.sortAbstractContacts(comparator);
baseEntities.addAll(rosterAccount
.getAbstractContacts());
baseEntities.addAll(rosterAccount.getAbstractContacts());
}
}
} else {
if (showGroups) {
for (GroupConfiguration rosterConfiguration : groups
.values())
if (showEmptyGroups
|| !rosterConfiguration.isEmpty()) {
for (GroupConfiguration rosterConfiguration : groups.values()) {
if (showEmptyGroups || !rosterConfiguration.isEmpty()) {
baseEntities.add(rosterConfiguration);
rosterConfiguration
.sortAbstractContacts(comparator);
baseEntities.addAll(rosterConfiguration
.getAbstractContacts());
rosterConfiguration.sortAbstractContacts(comparator);
baseEntities.addAll(rosterConfiguration.getAbstractContacts());
}
}
} else {
Collections.sort(contacts, comparator);
baseEntities.addAll(contacts);
......@@ -340,33 +332,35 @@ public class ContactListAdapter extends
}
}
} else { // Search
final ArrayList<AbstractContact> baseEntities = new ArrayList<AbstractContact>();
final ArrayList<AbstractContact> baseEntities = new ArrayList<>();
// Build structure.
for (RosterContact rosterContact : rosterContacts) {
if (!rosterContact.isEnabled())
if (!rosterContact.isEnabled()) {
continue;
}
final String account = rosterContact.getAccount();
final TreeMap<String, AbstractChat> users = abstractChats
.get(account);
if (users != null)
final TreeMap<String, AbstractChat> users = abstractChats.get(account);
if (users != null) {
users.remove(rosterContact.getUser());
if (rosterContact.getName().toLowerCase(locale)
.contains(filterString))
}
if (rosterContact.getName().toLowerCase(locale).contains(filterString)) {
baseEntities.add(rosterContact);
}
}
for (TreeMap<String, AbstractChat> users : abstractChats.values())
for (TreeMap<String, AbstractChat> users : abstractChats.values()) {
for (AbstractChat abstractChat : users.values()) {
final AbstractContact abstractContact;
if (abstractChat instanceof RoomChat)
abstractContact = new RoomContact(
(RoomChat) abstractChat);
else
if (abstractChat instanceof RoomChat) {
abstractContact = new RoomContact((RoomChat) abstractChat);
} else {
abstractContact = new ChatContact(abstractChat);
if (abstractContact.getName().toLowerCase(locale)
.contains(filterString))
}
if (abstractContact.getName().toLowerCase(locale).contains(filterString)) {
baseEntities.add(abstractContact);
}
}
}
Collections.sort(baseEntities, comparator);
this.baseEntities.clear();
this.baseEntities.addAll(baseEntities);
......@@ -379,10 +373,11 @@ public class ContactListAdapter extends
synchronized (refreshLock) {
nextRefresh = new Date(new Date().getTime() + REFRESH_INTERVAL);
refreshInProgess = false;
refreshInProgress = false;
handler.removeCallbacks(this); // Just to be sure.
if (refreshRequested)
if (refreshRequested) {
handler.postDelayed(this, REFRESH_INTERVAL);
}
}
}
......
......@@ -14,11 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.TreeMap;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
......@@ -38,6 +33,11 @@ import com.xabber.android.data.roster.GroupStateProvider;
import com.xabber.android.data.roster.ShowOfflineMode;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.TreeMap;
/**
* Provide grouping implementation for the list of contacts.
*
......@@ -62,7 +62,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
static final int TYPE_GROUP = 1;
static {
Collection<Group> groups = new ArrayList<Group>(1);
Collection<Group> groups = new ArrayList<>(1);
groups.add(new Group() {
@Override
public String getName() {
......@@ -95,28 +95,15 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
public GroupedContactAdapter(Activity activity, ListView listView,
Inflater inflater, StateProvider groupStateProvider) {
super(activity, listView, inflater);
layoutInflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.groupStateProvider = groupStateProvider;
TypedArray typedArray;
typedArray = activity.getTheme().obtainStyledAttributes(
R.styleable.ContactList);
expanderAccountTextColor = typedArray
.getColorStateList(R.styleable.ContactList_expanderAccountColor);
expanderGroupTextColor = typedArray
.getColorStateList(R.styleable.ContactList_expanderGroupColor);
typedArray = activity.getTheme().obtainStyledAttributes(R.styleable.ContactList);
expanderAccountTextColor = typedArray.getColorStateList(R.styleable.ContactList_expanderAccountColor);
expanderGroupTextColor = typedArray.getColorStateList(R.styleable.ContactList_expanderGroupColor);
typedArray.recycle();
}
/**
* Returns group state provider.
*
* @return
*/
public StateProvider getGroupStateProvider() {
return groupStateProvider;
}
@Override
public int getViewTypeCount() {
return 2;
......@@ -125,12 +112,13 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
@Override
public int getItemViewType(int position) {
Object object = getItem(position);
if (object instanceof AbstractContact)
if (object instanceof AbstractContact) {
return TYPE_CONTACT;
else if (object instanceof GroupConfiguration)
} else if (object instanceof GroupConfiguration) {
return TYPE_GROUP;
else
} else {
throw new IllegalStateException();
}
}
@Override
......@@ -141,15 +129,12 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final View view;
final GroupViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.base_group_item, parent,
false);
TypedArray typedArray = activity
.obtainStyledAttributes(R.styleable.ContactList);
view.setBackgroundDrawable(typedArray
.getDrawable(R.styleable.ContactList_expanderBackground));
((ImageView) view.findViewById(R.id.indicator))
.setImageDrawable(typedArray
.getDrawable(R.styleable.ContactList_expanderIndicator));
view = layoutInflater.inflate(R.layout.base_group_item, parent, false);
TypedArray typedArray = activity.obtainStyledAttributes(R.styleable.ContactList);
view.setBackgroundDrawable(
typedArray.getDrawable(R.styleable.ContactList_expanderBackground));
((ImageView) view.findViewById(R.id.indicator)).setImageDrawable(
typedArray.getDrawable(R.styleable.ContactList_expanderIndicator));
typedArray.recycle();
viewHolder = new GroupViewHolder(view);
......@@ -161,25 +146,23 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final GroupConfiguration configuration = (GroupConfiguration) getItem(position);
final int level;
if (configuration instanceof AccountConfiguration) {
level = AccountManager.getInstance().getColorLevel(
configuration.getAccount());
level = AccountManager.getInstance().getColorLevel(configuration.getAccount());
viewHolder.name.setTextColor(expanderAccountTextColor);
} else {
level = AccountManager.getInstance().getColorCount();
viewHolder.name.setTextColor(expanderGroupTextColor);
}
view.getBackground().setLevel(level);
viewHolder.name.getBackground().setLevel(
configuration.getShowOfflineMode().ordinal());
viewHolder.name.getBackground().setLevel(configuration.getShowOfflineMode().ordinal());
final String name = GroupManager.getInstance().getGroupName(
configuration.getAccount(), configuration.getUser());
viewHolder.name.setText(name + " (" + configuration.getOnline()
+ "/" + configuration.getTotal() + ")");
viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1
: 0);
viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1 : 0);
return view;
} else
} else {
throw new IllegalStateException();
}
}
/**
......@@ -191,10 +174,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/
protected GroupConfiguration getGroupConfiguration(
AccountConfiguration accountConfiguration, String name) {
GroupConfiguration groupConfiguration = accountConfiguration
.getGroupConfiguration(name);
if (groupConfiguration != null)
GroupConfiguration groupConfiguration = accountConfiguration.getGroupConfiguration(name);
if (groupConfiguration != null) {
return groupConfiguration;
}
groupConfiguration = new GroupConfiguration(
accountConfiguration.getAccount(), name, groupStateProvider);
accountConfiguration.addGroupConfiguration(groupConfiguration);
......@@ -211,10 +194,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
protected GroupConfiguration getGroupConfiguration(
TreeMap<String, GroupConfiguration> groups, String name) {
GroupConfiguration groupConfiguration = groups.get(name);
if (groupConfiguration != null)
if (groupConfiguration != null) {
return groupConfiguration;
groupConfiguration = new GroupConfiguration(GroupManager.NO_ACCOUNT,
name, groupStateProvider);
}
groupConfiguration = new GroupConfiguration(GroupManager.NO_ACCOUNT, name, groupStateProvider);
groups.put(name, groupConfiguration);
return groupConfiguration;
}
......@@ -231,38 +214,39 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
* @param showAccounts
* @param showGroups
*/
protected void addContact(AbstractContact abstractContact, String group,
boolean online, TreeMap<String, AccountConfiguration> accounts,
TreeMap<String, GroupConfiguration> groups,
ArrayList<AbstractContact> contacts, boolean showAccounts,
boolean showGroups) {
protected void addContact(AbstractContact abstractContact, String group, boolean online,
TreeMap<String, AccountConfiguration> accounts, TreeMap<String, GroupConfiguration> groups,
ArrayList<AbstractContact> contacts, boolean showAccounts, boolean showGroups) {
if (showAccounts) {
final String account = abstractContact.getAccount();
final AccountConfiguration accountConfiguration;
accountConfiguration = accounts.get(account);
if (accountConfiguration == null)
if (accountConfiguration == null) {
return;
}
if (showGroups) {
GroupConfiguration groupConfiguration = getGroupConfiguration(
accountConfiguration, group);
GroupConfiguration groupConfiguration
= getGroupConfiguration(accountConfiguration, group);
if (accountConfiguration.isExpanded()) {
groupConfiguration.setNotEmpty();
if (groupConfiguration.isExpanded())
if (groupConfiguration.isExpanded()) {
groupConfiguration.addAbstractContact(abstractContact);
}
}
groupConfiguration.increment(online);
} else {
if (accountConfiguration.isExpanded())
if (accountConfiguration.isExpanded()) {
accountConfiguration.addAbstractContact(abstractContact);
}
}
accountConfiguration.increment(online);
} else {
if (showGroups) {
GroupConfiguration groupConfiguration = getGroupConfiguration(
groups, group);
GroupConfiguration groupConfiguration = getGroupConfiguration(groups, group);
groupConfiguration.setNotEmpty();
if (groupConfiguration.isExpanded())
if (groupConfiguration.isExpanded()) {
groupConfiguration.addAbstractContact(abstractContact);
}
groupConfiguration.increment(online);
} else {
contacts.add(abstractContact);
......@@ -292,13 +276,14 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
if (showAccounts) {
final AccountConfiguration accountConfiguration;
accountConfiguration = accounts.get(abstractContact.getAccount());
if (accountConfiguration == null)
return hasVisible;
if (accountConfiguration == null) {
return false;
}
if (showGroups) {
Collection<? extends Group> abstractGroups = abstractContact
.getGroups();
if (abstractGroups.size() == 0)
Collection<? extends Group> abstractGroups = abstractContact.getGroups();
if (abstractGroups.size() == 0) {
abstractGroups = NO_GROUP_LIST;
}
for (Group abstractGroup : abstractGroups) {
GroupConfiguration groupConfiguration = getGroupConfiguration(
accountConfiguration, abstractGroup.getName());
......@@ -316,41 +301,39 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
hasVisible = true;
if (accountConfiguration.isExpanded()) {
groupConfiguration.setNotEmpty();
if (groupConfiguration.isExpanded())
groupConfiguration
.addAbstractContact(abstractContact);
if (groupConfiguration.isExpanded()) {
groupConfiguration.addAbstractContact(abstractContact);
}
}
}
groupConfiguration.increment(online);
}
} else {
if (online
|| (accountConfiguration.getShowOfflineMode() == ShowOfflineMode.always)
if (online || (accountConfiguration.getShowOfflineMode() == ShowOfflineMode.always)
|| (accountConfiguration.getShowOfflineMode() == ShowOfflineMode.normal && showOffline)) {
hasVisible = true;
if (accountConfiguration.isExpanded())
accountConfiguration
.addAbstractContact(abstractContact);
if (accountConfiguration.isExpanded()) {
accountConfiguration.addAbstractContact(abstractContact);
}
}
}
accountConfiguration.increment(online);
} else {
if (showGroups) {
Collection<? extends Group> abstractGroups = abstractContact
.getGroups();
if (abstractGroups.size() == 0)
Collection<? extends Group> abstractGroups = abstractContact.getGroups();
if (abstractGroups.size() == 0) {
abstractGroups = NO_GROUP_LIST;
}
for (Group abstractGroup : abstractGroups) {
GroupConfiguration groupConfiguration = getGroupConfiguration(
groups, abstractGroup.getName());
if (online
|| (groupConfiguration.getShowOfflineMode() == ShowOfflineMode.always)
GroupConfiguration groupConfiguration
= getGroupConfiguration(groups, abstractGroup.getName());
if (online || (groupConfiguration.getShowOfflineMode() == ShowOfflineMode.always)
|| (groupConfiguration.getShowOfflineMode() == ShowOfflineMode.normal && showOffline)) {
groupConfiguration.setNotEmpty();
hasVisible = true;
if (groupConfiguration.isExpanded())
groupConfiguration
.addAbstractContact(abstractContact);
if (groupConfiguration.isExpanded()) {
groupConfiguration.addAbstractContact(abstractContact);
}
}
groupConfiguration.increment(online);
}
......
......@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater>
*/
ListView listView;
public SmoothContactAdapter(Activity activity, ListView listView,
Inflater inflater) {
public SmoothContactAdapter(Activity activity, ListView listView, Inflater inflater) {
super(activity, inflater);
this.listView = listView;
}
......
......@@ -43,7 +43,7 @@ public class AccountChooseDialogFragment extends AbstractDialogFragment {
public void onClick(DialogInterface dialog, int which) {
String account = (String) adapter.getItem(which);
OnChoosedListener listener = (OnChoosedListener) getActivity();
listener.onChoosed(account, user, text);
listener.onChoose(account, user, text);
}
});
return builder;
......@@ -73,7 +73,7 @@ public class AccountChooseDialogFragment extends AbstractDialogFragment {
public interface OnChoosedListener {
void onChoosed(String account, String user, String text);
void onChoose(String account, String user, String text);
}
......
......@@ -14,19 +14,19 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/account_background_1"
android:drawable="@color/account_1"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/account_background_2"
android:drawable="@color/account_2"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/account_background_3"
android:drawable="@color/account_3"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/account_background_4"
android:drawable="@color/account_4"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
<?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/.
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/account_border_1"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/account_border_2"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/account_border_3"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/account_border_4"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/account_border_1_pressed" />
<item
android:state_focused="true"
android:drawable="@drawable/account_border_1_pressed" />
<item
android:state_pressed="true"
android:drawable="@drawable/account_border_1_pressed" />
<item
android:drawable="@drawable/account_border_1_normal" />
</selector>
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/account_border_2_pressed" />
<item
android:state_focused="true"
android:drawable="@drawable/account_border_2_pressed" />
<item
android:state_pressed="true"
android:drawable="@drawable/account_border_2_pressed" />
<item
android:drawable="@drawable/account_border_2_normal" />
</selector>
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/account_border_3_pressed" />
<item
android:state_focused="true"
android:drawable="@drawable/account_border_3_pressed" />
<item
android:state_pressed="true"
android:drawable="@drawable/account_border_3_pressed" />
<item
android:drawable="@drawable/account_border_3_normal" />
</selector>
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/account_border_4_pressed" />
<item
android:state_focused="true"
android:drawable="@drawable/account_border_4_pressed" />
<item
android:state_pressed="true"
android:drawable="@drawable/account_border_4_pressed" />
<item
android:drawable="@drawable/account_border_4_normal" />
</selector>
<?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/.
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/account_border_1_normal"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/account_border_2_normal"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/account_border_3_normal"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/account_border_4_normal"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
......@@ -14,19 +14,19 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/account_color_1"
android:drawable="@color/account_1"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/account_color_2"
android:drawable="@color/account_2"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/account_color_3"
android:drawable="@color/account_3"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/account_color_4"
android:drawable="@color/account_4"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/btn_status_mode_normal" />
</selector>
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/btn_title_back_normal" />
<item
android:drawable="@drawable/btn_title_back_pressed" />
</selector>
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/btn_title_back_pressed" />
<item
android:drawable="@drawable/btn_title_back_normal" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_1_dark_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_1_dark_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_1_dark_focused" />
<item
android:drawable="@drawable/expander_account_1_dark_normal" />
<item android:drawable="@color/account_1" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_1_light_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_1_light_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_1_light_focused" />
<item
android:drawable="@drawable/expander_account_1_light_normal" />
<item android:drawable="@color/account_1" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_2_dark_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_2_dark_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_2_dark_focused" />
<item
android:drawable="@drawable/expander_account_2_dark_normal" />
<item android:drawable="@color/account_2" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_2_light_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_2_light_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_2_light_focused" />
<item
android:drawable="@drawable/expander_account_2_light_normal" />
<item android:drawable="@color/account_2" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_3_dark_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_3_dark_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_3_dark_focused" />
<item
android:drawable="@drawable/expander_account_3_dark_normal" />
<item android:drawable="@color/account_3" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_3_light_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_3_light_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_3_light_focused" />
<item
android:drawable="@drawable/expander_account_3_light_normal" />
<item android:drawable="@color/account_3" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_4_dark_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_4_dark_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_4_dark_focused" />
<item
android:drawable="@drawable/expander_account_4_dark_normal" />
<item android:drawable="@color/account_4" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_account_4_light_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_account_4_light_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_account_4_light_focused" />
<item
android:drawable="@drawable/expander_account_4_light_normal" />
<item android:drawable="@color/account_4" />
</selector>
......@@ -14,15 +14,5 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_group_dark_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_group_dark_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_group_dark_focused" />
<item
android:drawable="@drawable/expander_group_dark_normal" />
<item android:drawable="@color/material_blue_grey_900" />
</selector>
......@@ -15,14 +15,5 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/expander_group_light_pressed" />
<item
android:state_selected="true"
android:drawable="@drawable/expander_group_light_focused" />
<item
android:state_focused="true"
android:drawable="@drawable/expander_group_light_focused" />
<item
android:drawable="@drawable/expander_group_light_normal" />
android:drawable="@color/material_blue_grey_900" />
</selector>
......@@ -14,6 +14,6 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/expander_indicator_dark_hidden" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/expander_indicator_dark_show" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_arrow_drop_right_white_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_arrow_drop_down_white_24dp" android:minLevel="1" android:maxLevel="1" />
</level-list>
\ No newline at end of file
......@@ -14,6 +14,6 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/expander_indicator_light_hidden" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/expander_indicator_light_show" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_arrow_drop_right_white_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_arrow_drop_down_white_24dp" android:minLevel="1" android:maxLevel="1" />
</level-list>
\ No newline at end of file
......@@ -14,19 +14,19 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/title_account_background_1_dark"
android:drawable="@color/account_1"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/title_account_background_2_dark"
android:drawable="@color/account_2"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/title_account_background_3_dark"
android:drawable="@color/account_3"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/title_account_background_4_dark"
android:drawable="@color/account_4"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
......@@ -14,19 +14,19 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/title_account_background_1_light"
android:drawable="@color/account_1"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/title_account_background_2_light"
android:drawable="@color/account_2"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/title_account_background_3_light"
android:drawable="@color/account_3"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/title_account_background_4_light"
android:drawable="@color/account_4"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
......@@ -21,8 +21,11 @@
>
<ImageView
android:id="@+id/color"
android:layout_width="wrap_content"
android:layout_width="4dp"
android:layout_height="@dimen/avatar_size"
android:layout_marginRight="3dp"
android:layout_marginEnd="3dp"
android:src="@drawable/account_color"
/>
<ImageView
......@@ -34,7 +37,7 @@
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:paddingLeft="4dip"
android:paddingRight="4dip"
......
......@@ -30,7 +30,6 @@
android:id="@+id/status_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/account_border"
android:src="@drawable/ic_status_account"
android:clickable="true"
/>
......@@ -38,6 +37,6 @@
android:id="@+id/disabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/account_border_disabled"
android:src="@color/account_disabled"
/>
</RelativeLayout>
\ No newline at end of file
......@@ -18,11 +18,16 @@
android:layout_height="@dimen/contact_list_item_height"
android:paddingTop="@dimen/contact_list_item_padding_top"
android:paddingBottom="@dimen/contact_list_item_padding_bottom"
>
<ImageView
android:id="@+id/color"
android:layout_width="wrap_content"
android:layout_width="4dp"
android:layout_height="@dimen/avatar_size"
android:layout_marginRight="3dp"
android:layout_marginEnd="3dp"
android:src="@drawable/account_color"
/>
<include layout="@layout/base_contact_avatar" />
......
......@@ -16,27 +16,29 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/expander_height"
android:gravity="center_vertical|left"
android:gravity="center_vertical|start"
android:background="@drawable/expander_background_dark"
>
<ImageView
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="@dimen/expander_height"
android:layout_marginLeft="@dimen/expander_arrow_margin_left"
android:layout_marginRight="@dimen/expander_arrow_margin_right"
android:layout_height="wrap_content"
android:src="@drawable/expander_indicator_dark"
/>
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="@dimen/expander_height"
android:gravity="center_vertical"
android:layout_marginRight="@dimen/expander_text_margin_right"
android:layout_marginEnd="@dimen/expander_text_margin_right"
android:singleLine="true"
android:ellipsize="marquee"
android:background="@drawable/ic_show_offline"
android:text="name (0/0)"
android:layout_toRightOf="@id/indicator"
android:layout_toEndOf="@id/indicator"
/>
</RelativeLayout>
\ No newline at end of file
......@@ -15,7 +15,7 @@
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/container"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_gravity="fill_horizontal"
android:gravity="center_vertical">
<HorizontalScrollView
android:id="@+id/account_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<LinearLayout
android:id="@+id/account_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
\ No newline at end of file
......@@ -22,7 +22,7 @@
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
android:drawSelectorOnTop="true" />
<RelativeLayout
android:id="@+id/info"
......
......@@ -59,7 +59,7 @@
android:singleLine="true"
android:ellipsize="marquee"
android:textStyle="bold"
android:textColor="?android:attr/textColorPrimary"
android:textColor="@color/secondary_text_default_material_light"
android:text="name"
/>
<TextView
......@@ -70,7 +70,7 @@
android:gravity="top"
android:singleLine="true"
android:ellipsize="marquee"
android:textColor="?android:attr/textColorPrimary"
android:textColor="@color/secondary_text_default_material_light"
android:text="status"
/>
</LinearLayout>
......
......@@ -15,4 +15,12 @@
<resources>
<color name="bright_foreground_dark">#ffffffff</color>
<color name="bright_foreground_light">#ff000000</color>
<color name="account_1" >#FFCCFF90</color>
<color name="account_2" >#FFFFE57F</color>
<color name="account_3" >#FFFF8A80</color>
<color name="account_4" >#FF80D8FF</color>
<color name="account_disabled" >#33000000</color>
</resources>
......@@ -19,7 +19,6 @@
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="accountBackground">@drawable/account_background</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="titleMainBackground">@drawable/title_main_background_dark</item>
<item name="titleAccountBackground">@drawable/title_account_background_dark</item>
<item name="textColorPrimaryNoSelected">@color/bright_foreground_dark</item>
</style>
......
<?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/.
-->
<ContactsSource
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ContactsDataKind
android:mimeType="vnd.android.cursor.item/vnd.com.xabber.view"
android:icon="@drawable/ic_information"
android:summaryColumn="data1"
android:detailColumn="data2"
android:detailSocialSummary="false"
/>
</ContactsSource>
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