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);
}
......
......@@ -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;
}
......
......@@ -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);
}
......
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