make archive menu item work
This commit is contained in:
parent
5e28a8f8d5
commit
4c8cbfe966
|
@ -204,6 +204,15 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
final int theme = findTheme();
|
||||||
|
if (this.mTheme != theme) {
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(final Intent intent) {
|
protected void onNewIntent(final Intent intent) {
|
||||||
if (isViewIntent(intent)) {
|
if (isViewIntent(intent)) {
|
||||||
|
@ -224,10 +233,6 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
final int theme = findTheme();
|
|
||||||
if (this.mTheme != theme) {
|
|
||||||
recreate();
|
|
||||||
}
|
|
||||||
this.mActivityPaused = false;
|
this.mActivityPaused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +296,22 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConversationArchived(Conversation conversation) {
|
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
|
@Override
|
||||||
|
|
|
@ -149,6 +149,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
activity.xmppConnectionService.archiveConversation(conversation);
|
||||||
activity.onConversationArchived(conversation);
|
activity.onConversationArchived(conversation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1032,6 +1033,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
handleAttachmentSelection(item);
|
handleAttachmentSelection(item);
|
||||||
break;
|
break;
|
||||||
case R.id.action_archive:
|
case R.id.action_archive:
|
||||||
|
activity.xmppConnectionService.archiveConversation(conversation);
|
||||||
activity.onConversationArchived(conversation);
|
activity.onConversationArchived(conversation);
|
||||||
break;
|
break;
|
||||||
case R.id.action_contact_details:
|
case R.id.action_contact_details:
|
||||||
|
@ -1239,6 +1241,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
builder.setPositiveButton(getString(R.string.delete_messages), (dialog, which) -> {
|
builder.setPositiveButton(getString(R.string.delete_messages), (dialog, which) -> {
|
||||||
this.activity.xmppConnectionService.clearConversationHistory(conversation);
|
this.activity.xmppConnectionService.clearConversationHistory(conversation);
|
||||||
if (endConversationCheckBox.isChecked()) {
|
if (endConversationCheckBox.isChecked()) {
|
||||||
|
this.activity.xmppConnectionService.archiveConversation(conversation);
|
||||||
this.activity.onConversationArchived(conversation);
|
this.activity.onConversationArchived(conversation);
|
||||||
} else {
|
} else {
|
||||||
activity.onConversationsListItemUpdated();
|
activity.onConversationsListItemUpdated();
|
||||||
|
@ -1353,7 +1356,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
new Handler().post(() -> {
|
new Handler().post(() -> {
|
||||||
final PackageManager packageManager = getActivity().getPackageManager();
|
final Activity activity = getActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PackageManager packageManager = activity.getPackageManager();
|
||||||
ConversationMenuConfigurator.updateAttachmentAvailability(packageManager);
|
ConversationMenuConfigurator.updateAttachmentAvailability(packageManager);
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,11 +60,29 @@ public class ConversationsOverviewFragment extends XmppFragment implements Enhan
|
||||||
private XmppActivity activity;
|
private XmppActivity activity;
|
||||||
|
|
||||||
public static Conversation getSuggestion(Activity 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);
|
Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
|
||||||
if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
|
if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
|
||||||
List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations;
|
List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations;
|
||||||
if (conversations.size() > 0) {
|
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;
|
return null;
|
||||||
|
@ -74,7 +92,6 @@ public class ConversationsOverviewFragment extends XmppFragment implements Enhan
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
Log.d(Config.LOGTAG, "on attach");
|
|
||||||
if (activity instanceof XmppActivity) {
|
if (activity instanceof XmppActivity) {
|
||||||
this.activity = (XmppActivity) activity;
|
this.activity = (XmppActivity) activity;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -173,10 +173,6 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
@Override
|
@Override
|
||||||
public void notifyDataSetChanged() {
|
public void notifyDataSetChanged() {
|
||||||
this.selectedConversation = ConversationFragment.getConversation(activity);
|
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();
|
super.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue