made refresh work
This commit is contained in:
parent
354b182968
commit
02c78bb1fb
|
@ -3,11 +3,8 @@ package eu.siacs.conversations.ui;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender.SendIntentException;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -29,17 +26,13 @@ import android.widget.Toast;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import de.timroes.android.listview.EnhancedListView;
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Blockable;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
|
@ -50,7 +43,6 @@ import eu.siacs.conversations.ui.adapter.ConversationAdapter;
|
|||
import eu.siacs.conversations.ui.service.EmojiService;
|
||||
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
|
||||
|
@ -836,7 +828,7 @@ public class ConversationActivity extends XmppActivity
|
|||
if (getSelectedConversation() == null) {
|
||||
reInitLatestConversation();
|
||||
} else {
|
||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
||||
ConversationActivity.this.mConversationFragment.refresh();
|
||||
updateActionBarTitle();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ import android.content.pm.PackageManager;
|
|||
import android.databinding.DataBindingUtil;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -25,7 +23,6 @@ import android.os.SystemClock;
|
|||
import android.support.v13.view.inputmethod.InputConnectionCompat;
|
||||
import android.support.v13.view.inputmethod.InputContentInfoCompat;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.ContextMenu;
|
||||
|
@ -46,11 +43,8 @@ import android.widget.AbsListView.OnScrollListener;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -62,12 +56,9 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
|
@ -82,7 +73,6 @@ import eu.siacs.conversations.entities.DownloadableFile;
|
|||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.entities.MucOptions;
|
||||
import eu.siacs.conversations.entities.Presence;
|
||||
import eu.siacs.conversations.entities.Presences;
|
||||
import eu.siacs.conversations.entities.ReadByMarker;
|
||||
import eu.siacs.conversations.entities.Transferable;
|
||||
import eu.siacs.conversations.entities.TransferablePlaceholder;
|
||||
|
@ -105,7 +95,6 @@ import eu.siacs.conversations.utils.StylingHelper;
|
|||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
|
||||
import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT;
|
||||
|
@ -1247,7 +1236,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
this.activity.onConversationArchived(conversation);
|
||||
} else {
|
||||
activity.onConversationsListItemUpdated();
|
||||
updateMessages();
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
|
@ -1267,7 +1256,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
conversation.setMutedTill(till);
|
||||
activity.xmppConnectionService.updateConversation(conversation);
|
||||
activity.onConversationsListItemUpdated();
|
||||
updateMessages();
|
||||
refresh();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
});
|
||||
builder.create().show();
|
||||
|
@ -1277,7 +1266,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
conversation.setMutedTill(0);
|
||||
this.activity.xmppConnectionService.updateConversation(conversation);
|
||||
this.activity.onConversationsListItemUpdated();
|
||||
updateMessages();
|
||||
refresh();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
@ -1415,7 +1404,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
|
||||
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
|
||||
activity.onConversationsListItemUpdated();
|
||||
updateMessages();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1438,7 +1427,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
|
||||
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
|
||||
activity.onConversationsListItemUpdated();
|
||||
updateMessages();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1479,7 +1468,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
private void retryDecryption(Message message) {
|
||||
message.setEncryption(Message.ENCRYPTION_PGP);
|
||||
activity.onConversationsListItemUpdated();
|
||||
updateMessages();
|
||||
refresh();
|
||||
conversation.getAccount().getPgpDecryptionService().decrypt(message, false);
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1610,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
this.binding.textinput.setKeyboardListener(this);
|
||||
messageListAdapter.updatePreferences();
|
||||
this.binding.messagesView.setAdapter(messageListAdapter);
|
||||
updateMessages();
|
||||
refresh();
|
||||
this.conversation.messagesLoaded.set(true);
|
||||
synchronized (this.messageList) {
|
||||
final Message first = conversation.getFirstUnreadMessage();
|
||||
|
@ -1729,13 +1718,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
|
||||
public void updateMessages() {
|
||||
@Override
|
||||
public void refresh() {
|
||||
synchronized (this.messageList) {
|
||||
if (getView() == null) {
|
||||
return;
|
||||
}
|
||||
if (this.conversation != null) {
|
||||
conversation.populateWithMessages(ConversationFragment.this.messageList);
|
||||
conversation.populateWithMessages(this.messageList);
|
||||
updateSnackBar(conversation);
|
||||
updateStatusMessages();
|
||||
this.messageListAdapter.notifyDataSetChanged();
|
||||
|
@ -2200,11 +2187,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void refresh() {
|
||||
|
||||
}
|
||||
|
||||
public void clearPending() {
|
||||
if (postponedActivityResult.pop() != null) {
|
||||
Log.d(Config.LOGTAG, "cleared pending intent with unhandled result left");
|
||||
|
|
|
@ -40,18 +40,21 @@ import android.support.v7.app.ActionBar;
|
|||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.databinding.ActivityConversationsBinding;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.interfaces.OnConversationArchived;
|
||||
import eu.siacs.conversations.ui.interfaces.OnConversationRead;
|
||||
import eu.siacs.conversations.ui.interfaces.OnConversationSelected;
|
||||
import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated;
|
||||
import eu.siacs.conversations.ui.service.EmojiService;
|
||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
||||
|
||||
public class ConversationsMainActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead {
|
||||
public class ConversationsMainActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast {
|
||||
|
||||
|
||||
//secondary fragment (when holding the conversation, must be initialized before refreshing the overview fragment
|
||||
|
@ -174,8 +177,6 @@ public class ConversationsMainActivity extends XmppActivity implements OnConvers
|
|||
} else {
|
||||
transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment());
|
||||
}
|
||||
|
||||
//TODO, do this in backendConnected so we can actually decide what to display
|
||||
if (binding.secondaryFragment != null) {
|
||||
transaction.replace(R.id.secondary_fragment, new ConversationFragment());
|
||||
}
|
||||
|
@ -216,4 +217,29 @@ public class ConversationsMainActivity extends XmppActivity implements OnConvers
|
|||
public void onConversationRead(Conversation conversation) {
|
||||
Log.d(Config.LOGTAG, "read event for " + conversation.getName() + " received");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountUpdate() {
|
||||
this.refreshUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConversationUpdate() {
|
||||
this.refreshUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRosterUpdate() {
|
||||
this.refreshUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdateBlocklist(OnUpdateBlocklist.Status status) {
|
||||
this.refreshUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowErrorToast(int resId) {
|
||||
runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue