Commit 68946a30 authored by Grigory Fedorov's avatar Grigory Fedorov

ChatViewer and ChatViewerFragment rewritten. ChatViewerAdapter removed. No scroll chat for now.

Dialogs do not use support libraries.
parent bcbb1c98
...@@ -171,8 +171,8 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -171,8 +171,8 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
text); text);
return; return;
} }
AccountChooseDialogFragment.newInstance(bareAddress, text).show( AccountChooseDialogFragment.newInstance(bareAddress, text)
getSupportFragmentManager(), "OPEN_WITH_ACCOUNT"); .show(getFragmentManager(), "OPEN_WITH_ACCOUNT");
} }
/** /**
...@@ -240,15 +240,14 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O ...@@ -240,15 +240,14 @@ public class ContactList extends ManagedActivity implements OnChoosedListener, O
if (SettingsManager.bootCount() > 2 if (SettingsManager.bootCount() > 2
&& !SettingsManager.connectionStartAtBoot() && !SettingsManager.connectionStartAtBoot()
&& !SettingsManager.startAtBootSuggested()) && !SettingsManager.startAtBootSuggested())
StartAtBootDialogFragment.newInstance().show( StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
getSupportFragmentManager(), "START_AT_BOOT");
if (!SettingsManager.contactIntegrationSuggested() if (!SettingsManager.contactIntegrationSuggested()
&& Application.getInstance().isContactsSupported()) { && Application.getInstance().isContactsSupported()) {
if (AccountManager.getInstance().getAllAccounts().isEmpty()) if (AccountManager.getInstance().getAllAccounts().isEmpty())
SettingsManager.setContactIntegrationSuggested(); SettingsManager.setContactIntegrationSuggested();
else else
ContactIntegrationDialogFragment.newInstance().show( ContactIntegrationDialogFragment.newInstance().show(
getSupportFragmentManager(), "CONTACT_INTEGRATION"); getFragmentManager(), "CONTACT_INTEGRATION");
} }
} }
} }
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
*/ */
package com.xabber.android.ui; package com.xabber.android.ui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
...@@ -34,6 +30,10 @@ import com.xabber.android.ui.dialog.GroupAddDialogFragment.OnGroupAddConfirmed; ...@@ -34,6 +30,10 @@ import com.xabber.android.ui.dialog.GroupAddDialogFragment.OnGroupAddConfirmed;
import com.xabber.android.ui.helper.ManagedListActivity; import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/** /**
* Manage list of selected groups. * Manage list of selected groups.
* *
...@@ -146,8 +146,7 @@ public abstract class GroupListActivity extends ManagedListActivity implements ...@@ -146,8 +146,7 @@ public abstract class GroupListActivity extends ManagedListActivity implements
} }
private void showGroupAddDialog() { private void showGroupAddDialog() {
GroupAddDialogFragment.newInstance(getGroups()).show( GroupAddDialogFragment.newInstance(getGroups()).show(getFragmentManager(), "GROUP-ADD");
getSupportFragmentManager(), "GROUP-ADD");
} }
@Override @Override
......
...@@ -14,11 +14,6 @@ ...@@ -14,11 +14,6 @@
*/ */
package com.xabber.android.ui.adapter; package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import android.app.Activity; import android.app.Activity;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
...@@ -49,6 +44,11 @@ import com.xabber.android.utils.Emoticons; ...@@ -49,6 +44,11 @@ import com.xabber.android.utils.Emoticons;
import com.xabber.android.utils.StringUtils; import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/** /**
* Adapter for the list of messages in the chat. * Adapter for the list of messages in the chat.
* *
...@@ -309,7 +309,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter ...@@ -309,7 +309,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
@Override @Override
public void onChange() { public void onChange() {
messages = new ArrayList<MessageItem>(MessageManager.getInstance() messages = new ArrayList<>(MessageManager.getInstance()
.getMessages(account, user)); .getMessages(account, user));
hint = getHint(); hint = getHint();
notifyDataSetChanged(); notifyDataSetChanged();
......
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collection;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.ui.ChatViewerFragment;
import com.xabber.xmpp.address.Jid;
/**
* Adapter for the list of chat pages.
*
* @author alexander.ivanov
*/
public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
UpdatableAdapter {
private final FragmentActivity activity;
/**
* Intent sent while opening chat activity.
*/
private final AbstractChat intent;
/**
* Position to insert intent.
*/
private final int intentPosition;
private ArrayList<AbstractChat> activeChats;
public ChatViewerAdapter(FragmentActivity activity, String account,
String user) {
this.activity = activity;
activeChats = new ArrayList<AbstractChat>();
intent = MessageManager.getInstance().getOrCreateChat(account,
Jid.getBareAddress(user));
Collection<? extends BaseEntity> activeChats = MessageManager
.getInstance().getActiveChats();
if (activeChats.contains(intent))
intentPosition = -1;
else
intentPosition = activeChats.size();
onChange();
}
@Override
public int getCount() {
return activeChats.size();
}
@Override
public Object getItem(int position) {
return activeChats.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
final AbstractChat chat = (AbstractChat) getItem(position);
ChatViewerFragment fragment;
if (convertView == null) {
fragment = new ChatViewerFragment(activity);
view = fragment.getView();
view.setTag(fragment);
} else {
view = convertView;
fragment = (ChatViewerFragment) view.getTag();
}
fragment.setChat(chat);
return view;
}
@Override
public void saveState(View view) {
((ChatViewerFragment) view.getTag()).saveState();
}
@Override
public void hidePages(View view) {
((ChatViewerFragment) view.getTag()).hidePages();
}
@Override
public void showPages(View view) {
((ChatViewerFragment) view.getTag()).showPages();
}
/**
* Must be called on changes in chat (message sent, received, etc.).
*/
public void onChatChange(View view, boolean incomingMessage) {
((ChatViewerFragment) view.getTag()).onChatChange(incomingMessage);
}
/**
* Must be called on changes in chat (message sent, received, etc.).
*/
public void onPrepareOptionsMenu(View view, Menu menu) {
((ChatViewerFragment) view.getTag()).onPrepareOptionsMenu(menu);
}
public void insertText(View view, String text) {
((ChatViewerFragment) view.getTag()).insertText(text);
}
@Override
public void onChange() {
activeChats = new ArrayList<AbstractChat>(MessageManager.getInstance()
.getActiveChats());
if (intentPosition != -1) {
int index = activeChats.indexOf(intent);
AbstractChat chat;
if (index == -1)
chat = intent;
else
chat = activeChats.remove(index);
activeChats.add(Math.min(intentPosition, activeChats.size()), chat);
}
notifyDataSetChanged();
}
public int getPosition(String account, String user) {
for (int position = 0; position < activeChats.size(); position++)
if (activeChats.get(position).equals(account, user))
return position;
return -1;
}
}
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
*/ */
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import java.util.ArrayList;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import java.util.ArrayList;
/** /**
* Base dialog fragment. * Base dialog fragment.
......
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import java.util.ArrayList;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.support.v4.app.DialogFragment;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -14,6 +12,8 @@ import com.xabber.android.data.roster.RosterContact; ...@@ -14,6 +12,8 @@ import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter; import com.xabber.android.ui.adapter.AccountChooseAdapter;
import java.util.ArrayList;
public class AccountChooseDialogFragment extends AbstractDialogFragment { public class AccountChooseDialogFragment extends AbstractDialogFragment {
private static final String USER = "USER"; private static final String USER = "USER";
......
...@@ -14,14 +14,12 @@ ...@@ -14,14 +14,12 @@
*/ */
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import java.io.File;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.v4.app.DialogFragment;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
...@@ -34,6 +32,8 @@ import com.xabber.android.data.message.MessageManager; ...@@ -34,6 +32,8 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.io.File;
public class ChatExportDialogFragment extends ConfirmDialogFragment { public class ChatExportDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT"; private static final String ACCOUNT = "ACCOUNT";
...@@ -45,8 +45,7 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment { ...@@ -45,8 +45,7 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
* @return * @return
*/ */
public static DialogFragment newInstance(String account, String user) { public static DialogFragment newInstance(String account, String user) {
return new ChatExportDialogFragment().putAgrument(ACCOUNT, account) return new ChatExportDialogFragment().putAgrument(ACCOUNT, account).putAgrument(USER, user);
.putAgrument(USER, user);
} }
private String account; private String account;
......
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
......
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
......
...@@ -14,17 +14,17 @@ ...@@ -14,17 +14,17 @@
*/ */
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import java.util.ArrayList;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
public class GroupAddDialogFragment extends ConfirmDialogFragment { public class GroupAddDialogFragment extends ConfirmDialogFragment {
private static final String GROUPS = "GROUPS"; private static final String GROUPS = "GROUPS";
......
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
......
...@@ -16,7 +16,7 @@ package com.xabber.android.ui.dialog; ...@@ -16,7 +16,7 @@ package com.xabber.android.ui.dialog;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
......
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.muc.MUCManager; import com.xabber.android.data.extension.muc.MUCManager;
......
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.support.v4.app.DialogFragment; import android.app.DialogFragment;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
*/ */
package com.xabber.android.ui.helper; package com.xabber.android.ui.helper;
import org.jivesoftware.smackx.ChatState;
import android.app.Activity; import android.app.Activity;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -24,7 +22,6 @@ import android.graphics.Shader.TileMode; ...@@ -24,7 +22,6 @@ import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.View; import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
...@@ -34,6 +31,8 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -34,6 +31,8 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.utils.Emoticons; import com.xabber.android.utils.Emoticons;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import org.jivesoftware.smackx.ChatState;
/** /**
* Helper class to update <code>contact_title.xml</code>. * Helper class to update <code>contact_title.xml</code>.
* *
...@@ -61,8 +60,7 @@ public class ContactTitleInflater { ...@@ -61,8 +60,7 @@ public class ContactTitleInflater {
.findViewById(R.id.avatar); .findViewById(R.id.avatar);
final ImageView statusModeView = (ImageView) titleView final ImageView statusModeView = (ImageView) titleView
.findViewById(R.id.status_mode); .findViewById(R.id.status_mode);
final TextView statusTextView = (TextView) titleView final TextView statusTextView = (TextView) titleView.findViewById(R.id.status_text);
.findViewById(R.id.status_text);
final View shadowView = titleView.findViewById(R.id.shadow); final View shadowView = titleView.findViewById(R.id.shadow);
titleView.setBackgroundDrawable(titleAccountBackground); titleView.setBackgroundDrawable(titleAccountBackground);
nameView.setText(abstractContact.getName()); nameView.setText(abstractContact.getName());
......
...@@ -33,11 +33,9 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -33,11 +33,9 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.GroupManager; import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.PresenceManager; import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ShowOfflineMode; import com.xabber.android.data.roster.ShowOfflineMode;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.ChatViewer; import com.xabber.android.ui.ChatViewer;
import com.xabber.android.ui.ContactAdd; import com.xabber.android.ui.ContactAdd;
import com.xabber.android.ui.ContactEditor; import com.xabber.android.ui.ContactEditor;
import com.xabber.android.ui.preferences.ContactViewer;
import com.xabber.android.ui.MUCEditor; import com.xabber.android.ui.MUCEditor;
import com.xabber.android.ui.StatusEditor; import com.xabber.android.ui.StatusEditor;
import com.xabber.android.ui.adapter.UpdatableAdapter; import com.xabber.android.ui.adapter.UpdatableAdapter;
...@@ -45,6 +43,8 @@ import com.xabber.android.ui.dialog.ContactDeleteDialogFragment; ...@@ -45,6 +43,8 @@ import com.xabber.android.ui.dialog.ContactDeleteDialogFragment;
import com.xabber.android.ui.dialog.GroupDeleteDialogFragment; import com.xabber.android.ui.dialog.GroupDeleteDialogFragment;
import com.xabber.android.ui.dialog.GroupRenameDialogFragment; import com.xabber.android.ui.dialog.GroupRenameDialogFragment;
import com.xabber.android.ui.dialog.MUCDeleteDialogFragment; import com.xabber.android.ui.dialog.MUCDeleteDialogFragment;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.preferences.ContactViewer;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
/** /**
...@@ -84,7 +84,7 @@ public class ContextMenuHelper { ...@@ -84,7 +84,7 @@ public class ContextMenuHelper {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
MUCDeleteDialogFragment.newInstance(account, user) MUCDeleteDialogFragment.newInstance(account, user)
.show(activity.getSupportFragmentManager(), .show(activity.getFragmentManager(),
"MUC_DELETE"); "MUC_DELETE");
return true; return true;
} }
...@@ -131,8 +131,7 @@ public class ContextMenuHelper { ...@@ -131,8 +131,7 @@ public class ContextMenuHelper {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance(account, ContactDeleteDialogFragment.newInstance(account,
user).show( user).show(activity.getFragmentManager(),
activity.getSupportFragmentManager(),
"CONTACT_DELETE"); "CONTACT_DELETE");
return true; return true;
} }
...@@ -225,8 +224,7 @@ public class ContextMenuHelper { ...@@ -225,8 +224,7 @@ public class ContextMenuHelper {
account == GroupManager.NO_ACCOUNT ? null account == GroupManager.NO_ACCOUNT ? null
: account, : account,
group == GroupManager.NO_GROUP ? null group == GroupManager.NO_GROUP ? null
: group).show( : group).show(activity.getFragmentManager(),
activity.getSupportFragmentManager(),
"GROUP_RENAME"); "GROUP_RENAME");
return true; return true;
} }
...@@ -241,9 +239,7 @@ public class ContextMenuHelper { ...@@ -241,9 +239,7 @@ public class ContextMenuHelper {
.newInstance( .newInstance(
account == GroupManager.NO_ACCOUNT ? null account == GroupManager.NO_ACCOUNT ? null
: account, group) : account, group)
.show(activity .show(activity.getFragmentManager(), "GROUP_DELETE");
.getSupportFragmentManager(),
"GROUP_DELETE");
return true; return true;
} }
}); });
......
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