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 { ...@@ -13,8 +13,8 @@ android {
applicationId "com.xabber.androiddev" applicationId "com.xabber.androiddev"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 21 targetSdkVersion 21
versionCode 116 versionCode 117
versionName '0.10.19' versionName '0.10.20'
} }
sourceSets { sourceSets {
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
android:theme="@style/Theme" android:theme="@style/Theme"
android:allowBackup="true"> android:allowBackup="true">
<activity <activity
android:label="@string/application_name" android:label="@string/production_title"
android:name="com.xabber.android.ui.ContactList" android:name="com.xabber.android.ui.ContactList"
android:launchMode="singleTop" android:launchMode="singleTop"
> >
...@@ -220,7 +220,6 @@ ...@@ -220,7 +220,6 @@
<activity <activity
android:label="@string/contact_viewer" android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.preferences.ContactViewer" android:name="com.xabber.android.ui.preferences.ContactViewer"
android:icon="@drawable/ic_information"
android:parentActivityName="com.xabber.android.ui.ContactList" android:parentActivityName="com.xabber.android.ui.ContactList"
> >
<!-- Parent activity meta-data to support 4.0 and lower --> <!-- Parent activity meta-data to support 4.0 and lower -->
...@@ -388,10 +387,6 @@ ...@@ -388,10 +387,6 @@
android:name="android.content.SyncAdapter" android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" android:resource="@xml/syncadapter"
/> />
<meta-data
android:name="android.provider.CONTACTS_STRUCTURE"
android:resource="@xml/contacts_structure"
/>
</service> </service>
<service <service
android:name="com.xabber.android.service.AccountAuthenticatorService" android:name="com.xabber.android.service.AccountAuthenticatorService"
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
package com.xabber.android.ui; package com.xabber.android.ui;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
...@@ -372,11 +371,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -372,11 +371,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
insertExtraText(); insertExtraText();
updateRegisteredChats(); updateRegisteredChats();
Fragment currentFragment = chatViewerAdapter.getCurrentFragment();
if (currentFragment instanceof ChatViewerFragment) {
((ChatViewerFragment)currentFragment).setInputFocus();
}
} }
private void insertExtraText() { private void insertExtraText() {
......
...@@ -613,14 +613,6 @@ public class ChatViewerFragment extends Fragment { ...@@ -613,14 +613,6 @@ public class ChatViewerFragment extends Fragment {
return this.account.equals(account) && this.user.equals(user); 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) { public void setInputText(String text) {
insertText(text); insertText(text);
} }
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
*/ */
package com.xabber.android.ui.adapter; package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collections;
import android.app.Activity; import android.app.Activity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -24,12 +21,14 @@ import android.view.View.OnClickListener; ...@@ -24,12 +21,14 @@ import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode; import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.androiddev.R; 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. * Adapter for the list of accounts in the title of contact list.
* *
...@@ -60,7 +59,7 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -60,7 +59,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
this.activity = activity; this.activity = activity;
this.onClickListener = onClickListener; this.onClickListener = onClickListener;
this.linearLayout = linearLayout; this.linearLayout = linearLayout;
accounts = new ArrayList<String>(); accounts = new ArrayList<>();
} }
/** /**
...@@ -76,48 +75,36 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -76,48 +75,36 @@ public class AccountToggleAdapter implements UpdatableAdapter {
final LayoutInflater inflater = (LayoutInflater) activity final LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
while (linearLayout.getChildCount() < size) { while (linearLayout.getChildCount() < size) {
final View view = inflater.inflate(R.layout.account_toggler_item, final View view = inflater.inflate(R.layout.account_toggler_item, linearLayout, false);
linearLayout, false);
linearLayout.addView(view); linearLayout.addView(view);
final AccountViewHolder accountViewHolder = new AccountViewHolder( final AccountViewHolder accountViewHolder = new AccountViewHolder(view);
view);
view.setTag(accountViewHolder); view.setTag(accountViewHolder);
activity.registerForContextMenu(accountViewHolder.statusMode); activity.registerForContextMenu(accountViewHolder.statusMode);
accountViewHolder.statusMode.setOnClickListener(onClickListener); accountViewHolder.statusMode.setOnClickListener(onClickListener);
} }
while (linearLayout.getChildCount() > size) while (linearLayout.getChildCount() > size) {
linearLayout.removeViewAt(size); linearLayout.removeViewAt(size);
}
onChange(); onChange();
} }
@Override @Override
public void onChange() { public void onChange() {
boolean contactsShowAccounts = SettingsManager.contactsShowAccounts();
String selected = AccountManager.getInstance().getSelectedAccount(); String selected = AccountManager.getInstance().getSelectedAccount();
for (int index = 0; index < accounts.size(); index++) { for (int index = 0; index < accounts.size(); index++) {
final View view = linearLayout.getChildAt(index); final View view = linearLayout.getChildAt(index);
final AccountViewHolder accountViewHolder = (AccountViewHolder) view final AccountViewHolder accountViewHolder = (AccountViewHolder) view.getTag();
.getTag();
final String account = accounts.get(index); final String account = accounts.get(index);
StatusMode statusMode = AccountManager.getInstance() StatusMode statusMode = AccountManager.getInstance().getAccount(account).getDisplayStatusMode();
.getAccount(account).getDisplayStatusMode(); int colorLevel = AccountManager.getInstance().getColorLevel(account);
int colorLevel = AccountManager.getInstance()
.getColorLevel(account);
view.getBackground().setLevel(colorLevel); view.getBackground().setLevel(colorLevel);
if (contactsShowAccounts) if (selected == null || account.equals(selected)) {
accountViewHolder.statusMode
.setBackgroundResource(R.drawable.account_border);
else
accountViewHolder.statusMode
.setBackgroundResource(R.drawable.account_border_persistent);
if (selected == null || account.equals(selected))
accountViewHolder.disabled.setVisibility(View.GONE); accountViewHolder.disabled.setVisibility(View.GONE);
else } else {
accountViewHolder.disabled.setVisibility(View.VISIBLE); accountViewHolder.disabled.setVisibility(View.VISIBLE);
accountViewHolder.statusMode.getBackground().setLevel(colorLevel); }
accountViewHolder.statusMode.setImageLevel(statusMode.ordinal()); accountViewHolder.statusMode.setImageLevel(statusMode.ordinal());
accountViewHolder.avatar.setImageDrawable(AvatarManager accountViewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
.getInstance().getAccountAvatar(account));
} }
} }
...@@ -137,11 +124,14 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -137,11 +124,14 @@ public class AccountToggleAdapter implements UpdatableAdapter {
* @return The data for the specified view. * @return The data for the specified view.
*/ */
public String getItemForView(View view) { public String getItemForView(View view) {
if (view.getId() == R.id.status_mode) if (view.getId() == R.id.status_mode) {
view = (View) view.getParent(); 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 accounts.get(index);
}
}
return null; return null;
} }
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
*/ */
package com.xabber.android.ui.adapter; package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Locale;
import android.app.Activity; import android.app.Activity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -27,6 +24,9 @@ import android.widget.Filterable; ...@@ -27,6 +24,9 @@ import android.widget.Filterable;
import com.xabber.android.data.entity.BaseEntity; import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import java.util.ArrayList;
import java.util.Locale;
/** /**
* Base adapter for the list of contacts. * Base adapter for the list of contacts.
* *
...@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater> ...@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
public BaseContactAdapter(Activity activity, Inflater inflater) { public BaseContactAdapter(Activity activity, Inflater inflater) {
this.activity = activity; this.activity = activity;
this.locale = Locale.getDefault(); this.locale = Locale.getDefault();
this.baseEntities = new ArrayList<BaseEntity>(); this.baseEntities = new ArrayList<>();
this.inflater = inflater; this.inflater = inflater;
inflater.setAdapter(this); inflater.setAdapter(this);
contactFilter = null; contactFilter = null;
filterString = null; filterString = null;
} }
/**
* @return View inflater.
*/
public Inflater getInflater() {
return inflater;
}
@Override @Override
public void onChange() { public void onChange() {
notifyDataSetChanged(); notifyDataSetChanged();
...@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater> ...@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override @Override
public Filter getFilter() { public Filter getFilter() {
if (contactFilter == null) if (contactFilter == null) {
contactFilter = new ContactFilter(); contactFilter = new ContactFilter();
}
return contactFilter; return contactFilter;
} }
...@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater> ...@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override @Override
protected void publishResults(CharSequence constraint, protected void publishResults(CharSequence constraint,
FilterResults results) { FilterResults results) {
if (constraint == null || constraint.length() == 0) if (constraint == null || constraint.length() == 0) {
filterString = null; filterString = null;
else } else {
filterString = constraint.toString().toLowerCase(locale); filterString = constraint.toString().toLowerCase(locale);
}
onChange(); onChange();
} }
......
...@@ -59,14 +59,11 @@ public abstract class BaseContactInflater { ...@@ -59,14 +59,11 @@ public abstract class BaseContactInflater {
public BaseContactInflater(Activity activity) { public BaseContactInflater(Activity activity) {
this.activity = activity; this.activity = activity;
layoutInflater = (LayoutInflater) activity layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); avatarInflaterHelper = AbstractAvatarInflaterHelper.createAbstractContactInflaterHelper();
avatarInflaterHelper = AbstractAvatarInflaterHelper
.createAbstractContactInflaterHelper(); Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(),
R.drawable.shadow);
shadowDrawable = new BitmapDrawable(bitmap);
shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
} }
...@@ -115,19 +112,18 @@ public abstract class BaseContactInflater { ...@@ -115,19 +112,18 @@ public abstract class BaseContactInflater {
*/ */
public void getView(View view, AbstractContact abstractContact) { public void getView(View view, AbstractContact abstractContact) {
final ViewHolder viewHolder = (ViewHolder) view.getTag(); final ViewHolder viewHolder = (ViewHolder) view.getTag();
if (abstractContact.isConnected()) if (abstractContact.isConnected()) {
viewHolder.shadow.setVisibility(View.GONE); viewHolder.shadow.setVisibility(View.GONE);
else } else {
viewHolder.shadow.setVisibility(View.VISIBLE); viewHolder.shadow.setVisibility(View.VISIBLE);
}
viewHolder.color.setImageLevel(abstractContact.getColorLevel()); viewHolder.color.setImageLevel(abstractContact.getColorLevel());
if (SettingsManager.contactsShowAvatars()) { if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE); viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(abstractContact viewHolder.avatar.setImageDrawable(abstractContact.getAvatarForContactList());
.getAvatarForContactList()); avatarInflaterHelper.updateAvatar(viewHolder.avatar, abstractContact);
avatarInflaterHelper.updateAvatar(viewHolder.avatar,
abstractContact);
((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams()) ((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams())
.addRule(RelativeLayout.RIGHT_OF, R.id.avatar); .addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
} else { } else {
...@@ -140,14 +136,12 @@ public abstract class BaseContactInflater { ...@@ -140,14 +136,12 @@ public abstract class BaseContactInflater {
final String statusText = getStatusText(abstractContact); final String statusText = getStatusText(abstractContact);
if ("".equals(statusText)) { if ("".equals(statusText)) {
viewHolder.name.getLayoutParams().height = activity.getResources() viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize( .getDimensionPixelSize(R.dimen.contact_name_height_hide_status);
R.dimen.contact_name_height_hide_status);
viewHolder.name.setGravity(Gravity.CENTER_VERTICAL); viewHolder.name.setGravity(Gravity.CENTER_VERTICAL);
viewHolder.status.setVisibility(View.GONE); viewHolder.status.setVisibility(View.GONE);
} else { } else {
viewHolder.name.getLayoutParams().height = activity.getResources() viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize( .getDimensionPixelSize(R.dimen.contact_name_height_show_status);
R.dimen.contact_name_height_show_status);
viewHolder.name.setGravity(Gravity.BOTTOM); viewHolder.name.setGravity(Gravity.BOTTOM);
viewHolder.status.setText(statusText); viewHolder.status.setText(statusText);
viewHolder.status.setVisibility(View.VISIBLE); viewHolder.status.setVisibility(View.VISIBLE);
......
...@@ -185,19 +185,6 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter { ...@@ -185,19 +185,6 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
public void onChatViewAdapterFinishUpdate(); 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() { public ArrayList<AbstractChat> getActiveChats() {
return activeChats; return activeChats;
} }
......
...@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater> ...@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater>
*/ */
ListView listView; ListView listView;
public SmoothContactAdapter(Activity activity, ListView listView, public SmoothContactAdapter(Activity activity, ListView listView, Inflater inflater) {
Inflater inflater) {
super(activity, inflater); super(activity, inflater);
this.listView = listView; this.listView = listView;
} }
......
...@@ -43,7 +43,7 @@ public class AccountChooseDialogFragment extends AbstractDialogFragment { ...@@ -43,7 +43,7 @@ public class AccountChooseDialogFragment extends AbstractDialogFragment {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String account = (String) adapter.getItem(which); String account = (String) adapter.getItem(which);
OnChoosedListener listener = (OnChoosedListener) getActivity(); OnChoosedListener listener = (OnChoosedListener) getActivity();
listener.onChoosed(account, user, text); listener.onChoose(account, user, text);
} }
}); });
return builder; return builder;
...@@ -73,7 +73,7 @@ public class AccountChooseDialogFragment extends AbstractDialogFragment { ...@@ -73,7 +73,7 @@ public class AccountChooseDialogFragment extends AbstractDialogFragment {
public interface OnChoosedListener { public interface OnChoosedListener {
void onChoosed(String account, String user, String text); void onChoose(String account, String user, String text);
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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