mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
don't save dcContext in MessageSelectorFragment and derivates
This commit is contained in:
@@ -54,7 +54,6 @@ public class AllMediaDocumentsFragment
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
dcContext = DcHelper.getContext(getContext());
|
||||
chatId = getArguments().getInt(CHAT_ID_EXTRA, -1);
|
||||
viewtype1 = getArguments().getInt(VIEWTYPE1, 0);
|
||||
viewtype2 = getArguments().getInt(VIEWTYPE2, 0);
|
||||
|
||||
@@ -52,7 +52,6 @@ public class AllMediaGalleryFragment
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
dcContext = DcHelper.getContext(getContext());
|
||||
chatId = getArguments().getInt(CHAT_ID_EXTRA, -1);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
|
||||
@@ -982,7 +982,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
if (accountId != dcContext.getAccountId()) {
|
||||
switchedProfile = true;
|
||||
AccountManager.getInstance().switchAccount(context, accountId);
|
||||
fragment.dcContext = context.getDcContext();
|
||||
initializeBackground();
|
||||
}
|
||||
chatId = getIntent().getIntExtra(CHAT_ID_EXTRA, -1);
|
||||
|
||||
@@ -106,7 +106,6 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
this.dcContext = DcHelper.getContext(getContext());
|
||||
|
||||
DcEventCenter eventCenter = DcHelper.getEventCenter(getContext());
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_INCOMING_MSG, this);
|
||||
@@ -208,7 +207,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Util.runOnBackground(() -> dcContext.marknoticedChat((int) chatId));
|
||||
Util.runOnBackground(() -> DcHelper.getContext(getContext()).marknoticedChat((int) chatId));
|
||||
if (list.getAdapter() != null) {
|
||||
list.getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
@@ -287,7 +286,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
dateDecoration = new StickyHeaderDecoration(adapter, false, false);
|
||||
list.addItemDecoration(dateDecoration);
|
||||
|
||||
int freshMsgs = dcContext.getFreshMsgCount((int) chatId);
|
||||
int freshMsgs = DcHelper.getContext(getContext()).getFreshMsgCount((int) chatId);
|
||||
SetStartingPositionLinearLayoutManager layoutManager = (SetStartingPositionLinearLayoutManager) list.getLayoutManager();
|
||||
if (startingPosition > -1) {
|
||||
layoutManager.setStartingPosition(startingPosition);
|
||||
@@ -429,6 +428,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
DcMsg prevMsg = new DcMsg(dcContext, DcMsg.DC_MSG_TEXT);
|
||||
for (DcMsg msg : dcMsgsList) {
|
||||
if (result.length() > 0) {
|
||||
@@ -485,6 +485,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
private void handleReplyMessagePrivately(final DcMsg msg) {
|
||||
|
||||
if (getActivity() != null) {
|
||||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
int privateChatId = dcContext.createChatByContactId(msg.getFromId());
|
||||
DcMsg replyMsg = new DcMsg(dcContext, DcMsg.DC_MSG_TEXT);
|
||||
replyMsg.setQuote(msg);
|
||||
@@ -501,6 +502,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
|
||||
private void handleToggleSave(final Set<DcMsg> messageRecords) {
|
||||
DcMsg msg = getSelectedMessageRecord(messageRecords);
|
||||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
if (msg.getSavedMsgId() != 0) {
|
||||
dcContext.deleteMsgs(new int[]{msg.getSavedMsgId()});
|
||||
} else {
|
||||
@@ -574,7 +576,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
}
|
||||
|
||||
private void updateLocationButton() {
|
||||
floatingLocationButton.setVisibility(dcContext.isSendingLocationsToChat((int) chatId)? View.VISIBLE : View.GONE);
|
||||
floatingLocationButton.setVisibility(DcHelper.getContext(getContext()).isSendingLocationsToChat((int) chatId)? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void scrollAndHighlight(final int pos, boolean smooth) {
|
||||
@@ -719,7 +721,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
index++;
|
||||
}
|
||||
}
|
||||
Util.runOnAnyBackgroundThread(() -> dcContext.markseenMsgs(ids));
|
||||
Util.runOnAnyBackgroundThread(() -> DcHelper.getContext(getContext()).markseenMsgs(ids));
|
||||
}
|
||||
|
||||
private class ConversationFragmentItemClickListener implements ItemClickListener {
|
||||
@@ -761,7 +763,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
startActivity(intent);
|
||||
}
|
||||
else {
|
||||
String self_mail = dcContext.getConfig("configured_mail_user");
|
||||
String self_mail = DcHelper.getContext(getContext()).getConfig("configured_mail_user");
|
||||
if (self_mail != null && !self_mail.isEmpty()
|
||||
&& messageRecord.getText().contains(self_mail)
|
||||
&& getListAdapter().getChat().isDeviceTalk()) {
|
||||
@@ -800,7 +802,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
if (foreignChatId != 0 && foreignChatId != chatId) {
|
||||
Intent intent = new Intent(getActivity(), ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, foreignChatId);
|
||||
int start = DcMsg.getMessagePosition(original, dcContext);
|
||||
int start = DcMsg.getMessagePosition(original, DcHelper.getContext(getContext()));
|
||||
intent.putExtra(ConversationActivity.STARTING_POSITION_EXTRA, start);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
((ConversationActivity) getActivity()).hideSoftKeyboard();
|
||||
@@ -816,7 +818,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
|
||||
@Override
|
||||
public void onJumpToOriginalClicked(DcMsg messageRecord) {
|
||||
jumpToOriginal(dcContext.getMsg(messageRecord.getOriginalMsgId()));
|
||||
jumpToOriginal(DcHelper.getContext(getContext()).getMsg(messageRecord.getOriginalMsgId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -835,7 +837,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
|
||||
@Override
|
||||
public void onDownloadClicked(DcMsg messageRecord) {
|
||||
dcContext.downloadFullMsg(messageRecord.getId());
|
||||
DcHelper.getContext(getContext()).downloadFullMsg(messageRecord.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,7 +32,6 @@ public abstract class MessageSelectorFragment
|
||||
implements DcEventCenter.DcEventDelegate
|
||||
{
|
||||
protected ActionMode actionMode;
|
||||
protected DcContext dcContext;
|
||||
|
||||
protected abstract void setCorrectMenuVisibility(Menu menu);
|
||||
|
||||
@@ -48,7 +47,7 @@ public abstract class MessageSelectorFragment
|
||||
protected void handleDisplayDetails(DcMsg dcMsg) {
|
||||
View view = View.inflate(getActivity(), R.layout.message_details_view, null);
|
||||
TextView detailsText = view.findViewById(R.id.details_text);
|
||||
detailsText.setText(dcContext.getMsgInfo(dcMsg.getId()));
|
||||
detailsText.setText(DcHelper.getContext(getContext()).getMsgInfo(dcMsg.getId()));
|
||||
|
||||
AlertDialog d = new AlertDialog.Builder(getActivity())
|
||||
.setView(view)
|
||||
@@ -62,6 +61,7 @@ public abstract class MessageSelectorFragment
|
||||
}
|
||||
|
||||
protected void handleDeleteMessages(int chatId, final int[] messageIds) {
|
||||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
DcChat dcChat = dcContext.getChat(chatId);
|
||||
boolean canDeleteForAll = true;
|
||||
if (dcChat.isEncrypted() && dcChat.canSend() && !dcChat.isSelfTalk()) {
|
||||
@@ -135,7 +135,7 @@ public abstract class MessageSelectorFragment
|
||||
protected void handleShowInChat(final DcMsg dcMsg) {
|
||||
Intent intent = new Intent(getContext(), ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, dcMsg.getChatId());
|
||||
intent.putExtra(ConversationActivity.STARTING_POSITION_EXTRA, DcMsg.getMessagePosition(dcMsg, dcContext));
|
||||
intent.putExtra(ConversationActivity.STARTING_POSITION_EXTRA, DcMsg.getMessagePosition(dcMsg, DcHelper.getContext(getContext())));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ public abstract class MessageSelectorFragment
|
||||
|
||||
protected void handleResendMessage(final Set<DcMsg> dcMsgsSet) {
|
||||
int[] ids = DcMsg.msgSetToIds(dcMsgsSet);
|
||||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
Util.runOnAnyBackgroundThread(() -> {
|
||||
boolean success = dcContext.resendMsgs(ids);
|
||||
Util.runOnMain(() -> {
|
||||
|
||||
Reference in New Issue
Block a user