diff options
Diffstat (limited to 'src/main')
4 files changed, 56 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index c1aa6caaa..a6c135437 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -209,6 +209,15 @@ public class ConversationActivity extends XmppActivity implements OnConversation } @Override + protected void onStart() { + final int theme = findTheme(); + if (this.mTheme != theme) { + recreate(); + } + super.onStart(); + } + + @Override protected void onNewIntent(final Intent intent) { if (isViewIntent(intent)) { if (xmppConnectionService != null) { @@ -228,10 +237,6 @@ public class ConversationActivity extends XmppActivity implements OnConversation @Override public void onResume() { super.onResume(); - final int theme = findTheme(); - if (this.mTheme != theme) { - recreate(); - } this.mActivityPaused = false; } @@ -335,7 +340,22 @@ public class ConversationActivity extends XmppActivity implements OnConversation @Override public void onConversationArchived(Conversation conversation) { - + //TODO; check if nothing more left; + Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment); + if (mainFragment != null && mainFragment instanceof ConversationFragment) { + getFragmentManager().popBackStack(); + return; + } + Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment); + if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) { + if (((ConversationFragment) secondaryFragment).getConversation() == conversation) { + Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation); + if (suggestion != null) { + openConversation(suggestion, null); + return; + } + } + } } @Override diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 42f0b431c..7b52a1c2d 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -169,6 +169,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke @Override public void onClick(View v) { + activity.xmppConnectionService.archiveConversation(conversation); activity.onConversationArchived(conversation); } }; @@ -1267,16 +1268,20 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke handleAttachmentSelection(item); break; case R.id.action_archive_chat: + activity.xmppConnectionService.archiveConversation(conversation); activity.onConversationArchived(conversation); break; case R.id.action_archive_muc: - getActivity().runOnUiThread(() -> { + activity.runOnUiThread(() -> { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.action_end_conversation_muc)); builder.setMessage(getString(R.string.leave_conference_warning)); builder.setNegativeButton(getString(R.string.cancel), null); builder.setPositiveButton(getString(R.string.action_end_conversation_muc), - (dialog, which) -> activity.onConversationArchived(conversation)); + (dialog, which) -> { + activity.xmppConnectionService.archiveConversation(conversation); + activity.onConversationArchived(conversation); + }); builder.create().show(); }); break; @@ -1491,6 +1496,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke builder.setPositiveButton(getString(R.string.delete_messages), (dialog, which) -> { this.activity.xmppConnectionService.clearConversationHistory(conversation); if (endConversationCheckBox.isChecked()) { + this.activity.xmppConnectionService.archiveConversation(conversation); this.activity.onConversationArchived(conversation); } else { activity.onConversationsListItemUpdated(); @@ -1584,6 +1590,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke @Override public void onResume() { new Handler().post(() -> { + final Activity activity = getActivity(); + if (activity == null) { + return; + } getActivity().invalidateOptionsMenu(); }); super.onResume(); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java index 8c77b7c51..6242e80a9 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java @@ -58,11 +58,29 @@ public class ConversationsOverviewFragment extends XmppFragment { private XmppActivity activity; public static Conversation getSuggestion(Activity activity) { + final Conversation exception; + Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment); + if (fragment != null && fragment instanceof ConversationsOverviewFragment) { + exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek(); + } else { + exception = null; + } + return getSuggestion(activity, exception); + } + + public static Conversation getSuggestion(Activity activity, Conversation exception) { Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment); if (fragment != null && fragment instanceof ConversationsOverviewFragment) { List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations; if (conversations.size() > 0) { - return conversations.get(0); + Conversation suggestion = conversations.get(0); + if (suggestion == exception) { + if (conversations.size() > 1) { + return conversations.get(1); + } + } else { + return suggestion; + } } } return null; @@ -72,7 +90,6 @@ public class ConversationsOverviewFragment extends XmppFragment { @Override public void onAttach(Activity activity) { super.onAttach(activity); - Log.d(Config.LOGTAG, "on attach"); if (activity instanceof XmppActivity) { this.activity = (XmppActivity) activity; } else { diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java index 74a2b0e91..16ad8f6a0 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java @@ -10,7 +10,6 @@ import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; -import android.util.Log; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; @@ -23,7 +22,6 @@ import java.lang.ref.WeakReference; import java.util.List; import java.util.concurrent.RejectedExecutionException; -import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.Message; @@ -301,10 +299,6 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { @Override public void notifyDataSetChanged() { this.selectedConversation = ConversationFragment.getConversation(activity); - Log.d(Config.LOGTAG, "notify data set changed"); - if (this.selectedConversation == null) { - Log.d(Config.LOGTAG, "selected conversation is null"); - } super.notifyDataSetChanged(); } |