Merge pull request #1876 from deltachat/adb-issue-1869

finish action mode on tab switch
This commit is contained in:
Asiel Díaz Benítez
2021-04-17 12:53:26 -04:00
committed by GitHub
3 changed files with 28 additions and 0 deletions
@@ -29,6 +29,10 @@ public abstract class MessageSelectorFragment
protected abstract void setCorrectMenuVisibility(Menu menu);
protected ActionMode getActionMode() {
return actionMode;
}
protected DcMsg getSelectedMessageRecord(Set<DcMsg> messageRecords) {
if (messageRecords.size() == 1) return messageRecords.iterator().next();
else throw new AssertionError();
@@ -9,11 +9,13 @@ import android.provider.Settings;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -262,11 +264,29 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
}
private class ProfilePagerAdapter extends FragmentStatePagerAdapter {
private Object currentFragment = null;
ProfilePagerAdapter(FragmentManager fragmentManager) {
super(fragmentManager);
}
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
super.setPrimaryItem(container, position, object);
if (currentFragment != null && currentFragment != object) {
ActionMode action = null;
if (currentFragment instanceof MessageSelectorFragment) {
action = ((MessageSelectorFragment) currentFragment).getActionMode();
} else if (currentFragment instanceof ProfileSettingsFragment) {
action = ((ProfileSettingsFragment) currentFragment).getActionMode();
}
if (action != null) {
action.finish();
}
}
currentFragment = object;
}
@Override
public Fragment getItem(int position) {
int tabId = tabs.get(position);
@@ -63,6 +63,10 @@ public class ProfileSettingsFragment extends Fragment
protected int chatId;
private int contactId;
protected ActionMode getActionMode() {
return actionMode;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);