Revert "Migrate Fragments to AndroidX"

This reverts commit 231d97ea81.

Migrating to AndroidX Fragments seems to have some unforseen side effects
and no clear benefits
This commit is contained in:
Daniel Gultsch 2021-09-21 11:41:35 +02:00
parent 75c20a7a2b
commit 64a6edd3fb
7 changed files with 61 additions and 62 deletions

View file

@ -3,6 +3,8 @@ package eu.siacs.conversations.ui;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -50,8 +52,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.core.view.inputmethod.InputConnectionCompat; import androidx.core.view.inputmethod.InputConnectionCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat; import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.google.common.base.Optional; import com.google.common.base.Optional;
@ -467,41 +467,41 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private boolean firstWord = false; private boolean firstWord = false;
private Message mPendingDownloadableMessage; private Message mPendingDownloadableMessage;
private static ConversationFragment findConversationFragment(FragmentManager fragmentManager) { private static ConversationFragment findConversationFragment(Activity activity) {
Fragment fragment = fragmentManager.findFragmentById(R.id.main_fragment); Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment instanceof ConversationFragment) { if (fragment instanceof ConversationFragment) {
return (ConversationFragment) fragment; return (ConversationFragment) fragment;
} }
fragment = fragmentManager.findFragmentById(R.id.secondary_fragment); fragment = activity.getFragmentManager().findFragmentById(R.id.secondary_fragment);
if (fragment instanceof ConversationFragment) { if (fragment instanceof ConversationFragment) {
return (ConversationFragment) fragment; return (ConversationFragment) fragment;
} }
return null; return null;
} }
public static void startStopPending(FragmentManager fragmentManager) { public static void startStopPending(Activity activity) {
ConversationFragment fragment = findConversationFragment(fragmentManager); ConversationFragment fragment = findConversationFragment(activity);
if (fragment != null) { if (fragment != null) {
fragment.messageListAdapter.startStopPending(); fragment.messageListAdapter.startStopPending();
} }
} }
public static void downloadFile(FragmentManager fragmentManager, Message message) { public static void downloadFile(Activity activity, Message message) {
ConversationFragment fragment = findConversationFragment(fragmentManager); ConversationFragment fragment = findConversationFragment(activity);
if (fragment != null) { if (fragment != null) {
fragment.startDownloadable(message); fragment.startDownloadable(message);
} }
} }
public static void registerPendingMessage(FragmentManager fragmentManager, Message message) { public static void registerPendingMessage(Activity activity, Message message) {
ConversationFragment fragment = findConversationFragment(fragmentManager); ConversationFragment fragment = findConversationFragment(activity);
if (fragment != null) { if (fragment != null) {
fragment.pendingMessage.push(message); fragment.pendingMessage.push(message);
} }
} }
public static void openPendingMessage(FragmentManager fragmentManager) { public static void openPendingMessage(Activity activity) {
ConversationFragment fragment = findConversationFragment(fragmentManager); ConversationFragment fragment = findConversationFragment(activity);
if (fragment != null) { if (fragment != null) {
Message message = fragment.pendingMessage.pop(); Message message = fragment.pendingMessage.pop();
if (message != null) { if (message != null) {
@ -510,12 +510,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
public static Conversation getConversation(FragmentManager fragmentManager) { public static Conversation getConversation(Activity activity) {
return getConversation(fragmentManager, R.id.secondary_fragment); return getConversation(activity, R.id.secondary_fragment);
} }
private static Conversation getConversation(FragmentManager fragmentManager, @IdRes int res) { private static Conversation getConversation(Activity activity, @IdRes int res) {
final Fragment fragment = fragmentManager.findFragmentById(res); final Fragment fragment = activity.getFragmentManager().findFragmentById(res);
if (fragment instanceof ConversationFragment) { if (fragment instanceof ConversationFragment) {
return ((ConversationFragment) fragment).getConversation(); return ((ConversationFragment) fragment).getConversation();
} else { } else {
@ -523,7 +523,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
public static ConversationFragment get(FragmentManager fragmentManager) { public static ConversationFragment get(Activity activity) {
FragmentManager fragmentManager = activity.getFragmentManager();
Fragment fragment = fragmentManager.findFragmentById(R.id.main_fragment); Fragment fragment = fragmentManager.findFragmentById(R.id.main_fragment);
if (fragment instanceof ConversationFragment) { if (fragment instanceof ConversationFragment) {
return (ConversationFragment) fragment; return (ConversationFragment) fragment;
@ -533,12 +534,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
public static Conversation getConversationReliable(FragmentManager fragmentManager) { public static Conversation getConversationReliable(Activity activity) {
final Conversation conversation = getConversation(fragmentManager, R.id.secondary_fragment); final Conversation conversation = getConversation(activity, R.id.secondary_fragment);
if (conversation != null) { if (conversation != null) {
return conversation; return conversation;
} }
return getConversation(fragmentManager, R.id.main_fragment); return getConversation(activity, R.id.main_fragment);
} }
private static boolean scrolledToBottom(AbsListView listView) { private static boolean scrolledToBottom(AbsListView listView) {

View file

@ -34,6 +34,9 @@ import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -52,9 +55,6 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpApi;
@ -165,8 +165,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
invalidateActionBarTitle(); invalidateActionBarTitle();
if (binding.secondaryFragment != null && ConversationFragment.getConversation(getSupportFragmentManager()) == null) { if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
Conversation conversation = ConversationsOverviewFragment.getSuggestion(getSupportFragmentManager()); Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
if (conversation != null) { if (conversation != null) {
openConversation(conversation, null); openConversation(conversation, null);
} }
@ -202,7 +202,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (xmppConnectionService == null) { if (xmppConnectionService == null) {
return; return;
} }
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_fragment); final Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment instanceof ConversationsOverviewFragment) { if (fragment instanceof ConversationsOverviewFragment) {
if (ExceptionHelper.checkForCrash(this)) { if (ExceptionHelper.checkForCrash(this)) {
return; return;
@ -255,14 +255,14 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
private void notifyFragmentOfBackendConnected(@IdRes int id) { private void notifyFragmentOfBackendConnected(@IdRes int id) {
final Fragment fragment = getSupportFragmentManager().findFragmentById(id); final Fragment fragment = getFragmentManager().findFragmentById(id);
if (fragment instanceof OnBackendConnected) { if (fragment instanceof OnBackendConnected) {
((OnBackendConnected) fragment).onBackendConnected(); ((OnBackendConnected) fragment).onBackendConnected();
} }
} }
private void refreshFragment(@IdRes int id) { private void refreshFragment(@IdRes int id) {
final Fragment fragment = getSupportFragmentManager().findFragmentById(id); final Fragment fragment = getFragmentManager().findFragmentById(id);
if (fragment instanceof XmppFragment) { if (fragment instanceof XmppFragment) {
((XmppFragment) fragment).refresh(); ((XmppFragment) fragment).refresh();
} }
@ -288,10 +288,10 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
switch (requestCode) { switch (requestCode) {
case REQUEST_OPEN_MESSAGE: case REQUEST_OPEN_MESSAGE:
refreshUiReal(); refreshUiReal();
ConversationFragment.openPendingMessage(getSupportFragmentManager()); ConversationFragment.openPendingMessage(this);
break; break;
case REQUEST_PLAY_PAUSE: case REQUEST_PLAY_PAUSE:
ConversationFragment.startStopPending(getSupportFragmentManager()); ConversationFragment.startStopPending(this);
break; break;
} }
} }
@ -318,7 +318,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
private void handleNegativeActivityResult(int requestCode) { private void handleNegativeActivityResult(int requestCode) {
Conversation conversation = ConversationFragment.getConversationReliable(getSupportFragmentManager()); Conversation conversation = ConversationFragment.getConversationReliable(this);
switch (requestCode) { switch (requestCode) {
case REQUEST_DECRYPT_PGP: case REQUEST_DECRYPT_PGP:
if (conversation == null) { if (conversation == null) {
@ -333,7 +333,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
private void handlePositiveActivityResult(int requestCode, final Intent data) { private void handlePositiveActivityResult(int requestCode, final Intent data) {
Conversation conversation = ConversationFragment.getConversationReliable(getSupportFragmentManager()); Conversation conversation = ConversationFragment.getConversationReliable(this);
if (conversation == null) { if (conversation == null) {
Log.d(Config.LOGTAG, "conversation not found"); Log.d(Config.LOGTAG, "conversation not found");
return; return;
@ -365,8 +365,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
setSupportActionBar(binding.toolbar); setSupportActionBar(binding.toolbar);
configureActionBar(getSupportActionBar()); configureActionBar(getSupportActionBar());
this.getSupportFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle); this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
this.getSupportFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview); this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
this.initializeFragments(); this.initializeFragments();
this.invalidateActionBarTitle(); this.invalidateActionBarTitle();
final Intent intent; final Intent intent;
@ -387,7 +387,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
final MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); final MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
if (qrCodeScanMenuItem != null) { if (qrCodeScanMenuItem != null) {
if (isCameraFeatureAvailable()) { if (isCameraFeatureAvailable()) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_fragment); Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan) boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan)
&& fragment instanceof ConversationsOverviewFragment; && fragment instanceof ConversationsOverviewFragment;
qrCodeScanMenuItem.setVisible(visible); qrCodeScanMenuItem.setVisible(visible);
@ -401,7 +401,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
@Override @Override
public void onConversationSelected(Conversation conversation) { public void onConversationSelected(Conversation conversation) {
clearPendingViewIntent(); clearPendingViewIntent();
if (ConversationFragment.getConversation(getSupportFragmentManager()) == conversation) { if (ConversationFragment.getConversation(this) == conversation) {
Log.d(Config.LOGTAG, "ignore onConversationSelected() because conversation is already open"); Log.d(Config.LOGTAG, "ignore onConversationSelected() because conversation is already open");
return; return;
} }
@ -429,7 +429,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
private void openConversation(Conversation conversation, Bundle extras) { private void openConversation(Conversation conversation, Bundle extras) {
final FragmentManager fragmentManager = getSupportFragmentManager(); final FragmentManager fragmentManager = getFragmentManager();
executePendingTransactions(fragmentManager); executePendingTransactions(fragmentManager);
ConversationFragment conversationFragment = (ConversationFragment) fragmentManager.findFragmentById(R.id.secondary_fragment); ConversationFragment conversationFragment = (ConversationFragment) fragmentManager.findFragmentById(R.id.secondary_fragment);
final boolean mainNeedsRefresh; final boolean mainNeedsRefresh;
@ -489,7 +489,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
FragmentManager fm = getSupportFragmentManager(); FragmentManager fm = getFragmentManager();
if (fm.getBackStackEntryCount() > 0) { if (fm.getBackStackEntryCount() > 0) {
try { try {
fm.popBackStack(); fm.popBackStack();
@ -506,7 +506,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
startActivity(new Intent(this, SearchActivity.class)); startActivity(new Intent(this, SearchActivity.class));
return true; return true;
case R.id.action_search_this_conversation: case R.id.action_search_this_conversation:
final Conversation conversation = ConversationFragment.getConversation(getSupportFragmentManager()); final Conversation conversation = ConversationFragment.getConversation(this);
if (conversation == null) { if (conversation == null) {
return true; return true;
} }
@ -521,7 +521,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
@Override @Override
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) { public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && keyEvent.isCtrlPressed()) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP && keyEvent.isCtrlPressed()) {
final ConversationFragment conversationFragment = ConversationFragment.get(getSupportFragmentManager()); final ConversationFragment conversationFragment = ConversationFragment.get(this);
if (conversationFragment != null && conversationFragment.onArrowUpCtrlPressed()) { if (conversationFragment != null && conversationFragment.onArrowUpCtrlPressed()) {
return true; return true;
} }
@ -576,14 +576,14 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
private void initializeFragments() { private void initializeFragments() {
final FragmentManager fragmentManager = getSupportFragmentManager(); final FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction(); FragmentTransaction transaction = fragmentManager.beginTransaction();
final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment); final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
final Fragment secondaryFragment = fragmentManager.findFragmentById(R.id.secondary_fragment); final Fragment secondaryFragment = fragmentManager.findFragmentById(R.id.secondary_fragment);
if (mainFragment != null) { if (mainFragment != null) {
if (binding.secondaryFragment != null) { if (binding.secondaryFragment != null) {
if (mainFragment instanceof ConversationFragment) { if (mainFragment instanceof ConversationFragment) {
getSupportFragmentManager().popBackStack(); getFragmentManager().popBackStack();
transaction.remove(mainFragment); transaction.remove(mainFragment);
transaction.commit(); transaction.commit();
fragmentManager.executePendingTransactions(); fragmentManager.executePendingTransactions();
@ -597,7 +597,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (secondaryFragment instanceof ConversationFragment) { if (secondaryFragment instanceof ConversationFragment) {
transaction.remove(secondaryFragment); transaction.remove(secondaryFragment);
transaction.commit(); transaction.commit();
getSupportFragmentManager().executePendingTransactions(); getFragmentManager().executePendingTransactions();
transaction = fragmentManager.beginTransaction(); transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.main_fragment, secondaryFragment); transaction.replace(R.id.main_fragment, secondaryFragment);
transaction.addToBackStack(null); transaction.addToBackStack(null);
@ -619,7 +619,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (actionBar == null) { if (actionBar == null) {
return; return;
} }
final FragmentManager fragmentManager = getSupportFragmentManager(); final FragmentManager fragmentManager = getFragmentManager();
final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment); final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
if (mainFragment instanceof ConversationFragment) { if (mainFragment instanceof ConversationFragment) {
final Conversation conversation = ((ConversationFragment) mainFragment).getConversation(); final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
@ -656,7 +656,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (performRedirectIfNecessary(conversation, false)) { if (performRedirectIfNecessary(conversation, false)) {
return; return;
} }
final FragmentManager fragmentManager = getSupportFragmentManager(); final FragmentManager fragmentManager = getFragmentManager();
final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment); final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
if (mainFragment instanceof ConversationFragment) { if (mainFragment instanceof ConversationFragment) {
try { try {
@ -670,7 +670,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
final Fragment secondaryFragment = fragmentManager.findFragmentById(R.id.secondary_fragment); final Fragment secondaryFragment = fragmentManager.findFragmentById(R.id.secondary_fragment);
if (secondaryFragment instanceof ConversationFragment) { if (secondaryFragment instanceof ConversationFragment) {
if (((ConversationFragment) secondaryFragment).getConversation() == conversation) { if (((ConversationFragment) secondaryFragment).getConversation() == conversation) {
Conversation suggestion = ConversationsOverviewFragment.getSuggestion(getSupportFragmentManager(), conversation); Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
if (suggestion != null) { if (suggestion != null) {
openConversation(suggestion, null); openConversation(suggestion, null);
} }
@ -680,7 +680,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
@Override @Override
public void onConversationsListItemUpdated() { public void onConversationsListItemUpdated() {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_fragment); Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment instanceof ConversationsOverviewFragment) { if (fragment instanceof ConversationsOverviewFragment) {
((ConversationsOverviewFragment) fragment).refresh(); ((ConversationsOverviewFragment) fragment).refresh();
} }

View file

@ -31,6 +31,7 @@ package eu.siacs.conversations.ui;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -45,8 +46,6 @@ import android.view.ViewGroup;
import android.widget.Toast; import android.widget.Toast;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -140,7 +139,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
activity.xmppConnectionService.archiveConversation(c); activity.xmppConnectionService.archiveConversation(c);
return; return;
} }
final boolean formerlySelected = ConversationFragment.getConversation(requireActivity().getSupportFragmentManager()) == swipedConversation.peek(); final boolean formerlySelected = ConversationFragment.getConversation(getActivity()) == swipedConversation.peek();
if (activity instanceof OnConversationArchived) { if (activity instanceof OnConversationArchived) {
((OnConversationArchived) activity).onConversationArchived(swipedConversation.peek()); ((OnConversationArchived) activity).onConversationArchived(swipedConversation.peek());
} }
@ -203,19 +202,19 @@ public class ConversationsOverviewFragment extends XmppFragment {
private ItemTouchHelper touchHelper; private ItemTouchHelper touchHelper;
public static Conversation getSuggestion(FragmentManager fragmentManager) { public static Conversation getSuggestion(Activity activity) {
final Conversation exception; final Conversation exception;
Fragment fragment = fragmentManager.findFragmentById(R.id.main_fragment); Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment instanceof ConversationsOverviewFragment) { if (fragment instanceof ConversationsOverviewFragment) {
exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek(); exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek();
} else { } else {
exception = null; exception = null;
} }
return getSuggestion(fragmentManager, exception); return getSuggestion(activity, exception);
} }
public static Conversation getSuggestion(FragmentManager fragmentManager, Conversation exception) { public static Conversation getSuggestion(Activity activity, Conversation exception) {
Fragment fragment = fragmentManager.findFragmentById(R.id.main_fragment); Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment instanceof ConversationsOverviewFragment) { if (fragment instanceof ConversationsOverviewFragment) {
List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations; List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations;
if (conversations.size() > 0) { if (conversations.size() > 0) {

View file

@ -30,8 +30,7 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import androidx.fragment.app.Fragment;
import eu.siacs.conversations.ui.interfaces.OnBackendConnected; import eu.siacs.conversations.ui.interfaces.OnBackendConnected;

View file

@ -60,7 +60,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
viewHolder.binding.conversationName.setText(EmojiWrapper.transform(name)); viewHolder.binding.conversationName.setText(EmojiWrapper.transform(name));
} }
if (conversation == ConversationFragment.getConversation(activity.getSupportFragmentManager())) { if (conversation == ConversationFragment.getConversation(activity)) {
viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_tertiary)); viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_tertiary));
} else { } else {
viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_primary)); viewHolder.binding.frame.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_primary));

View file

@ -510,7 +510,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.audioPlayer.setVisibility(View.GONE); viewHolder.audioPlayer.setVisibility(View.GONE);
viewHolder.download_button.setVisibility(View.VISIBLE); viewHolder.download_button.setVisibility(View.VISIBLE);
viewHolder.download_button.setText(text); viewHolder.download_button.setText(text);
viewHolder.download_button.setOnClickListener(v -> ConversationFragment.downloadFile(activity.getSupportFragmentManager(), message)); viewHolder.download_button.setOnClickListener(v -> ConversationFragment.downloadFile(activity, message));
} }
private void displayOpenableMessage(ViewHolder viewHolder, final Message message, final boolean darkBackground) { private void displayOpenableMessage(ViewHolder viewHolder, final Message message, final boolean darkBackground) {
@ -872,7 +872,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
public void openDownloadable(Message message) { public void openDownloadable(Message message) {
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ConversationFragment.registerPendingMessage(activity.getSupportFragmentManager(), message); ConversationFragment.registerPendingMessage(activity, message);
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, ConversationsActivity.REQUEST_OPEN_MESSAGE); ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, ConversationsActivity.REQUEST_OPEN_MESSAGE);
return; return;
} }

View file

@ -172,7 +172,7 @@ public final class MucDetailsContextMenuHelper {
return true; return true;
case R.id.send_private_message: case R.id.send_private_message:
if (activity instanceof ConversationsActivity) { if (activity instanceof ConversationsActivity) {
ConversationFragment conversationFragment = ConversationFragment.get(activity.getSupportFragmentManager()); ConversationFragment conversationFragment = ConversationFragment.get(activity);
if (conversationFragment != null) { if (conversationFragment != null) {
conversationFragment.privateMessageWith(user.getFullJid()); conversationFragment.privateMessageWith(user.getFullJid());
return true; return true;