diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-01-26 21:54:10 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-01-26 21:54:10 +0100 |
commit | f84f77316c10328198b52fbdd8a0dce9f03604ff (patch) | |
tree | 6821a7a08a6a4aeeba03fe2a978c56a6cb9a9d85 /src/main/java/de/pixart/messenger/ui | |
parent | 563fd9f6a6c206e960ed6b5471869f9c1ed4d0ec (diff) |
add possibility to destroy group chat
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
3 files changed, 47 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 55a7ad85e..f17380843 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -5,8 +5,10 @@ import android.app.AlertDialog; import android.app.PendingIntent; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.os.Bundle; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -52,6 +54,27 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers inviteToConversation(mConversation); } }; + private OnClickListener destroyListener = new OnClickListener() { + + @Override + public void onClick(View v) { + final AlertDialog.Builder DestroyMucDialog = new AlertDialog.Builder(ConferenceDetailsActivity.this); + DestroyMucDialog.setNegativeButton(getString(R.string.cancel), null); + DestroyMucDialog.setTitle(getString(R.string.action_destroy_muc)); + DestroyMucDialog.setMessage(getString(R.string.destroy_muc_text, mConversation.getName())); + DestroyMucDialog.setPositiveButton(getString(R.string.delete), (dialogInterface, i) -> { + Intent intent = new Intent(xmppConnectionService, ConversationActivity.class); + intent.setAction(ConversationActivity.ACTION_DESTROY_MUC); + intent.putExtra("MUC_UUID", mConversation.getUuid()); + Log.d(Config.LOGTAG, "Sending DESTROY intent for " + mConversation.getName()); + startActivity(intent); + deleteBookmark(); + finish(); + }); + DestroyMucDialog.create().show(); + } + }; + private TextView ConferenceName; private TextView mYourNick; private ImageView mYourPhoto; @@ -68,6 +91,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private ImageButton mChangeConferenceSettingsButton; private ImageButton mNotifyStatusButton; private Button mInviteButton; + private Button mDestroyButton; private String uuid = null; private User mSelectedUser = null; @@ -264,6 +288,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers mInviteButton = findViewById(R.id.invite); mInviteButton.setVisibility(View.GONE); mInviteButton.setOnClickListener(inviteListener); + mDestroyButton = findViewById(R.id.destroy); + mDestroyButton.setVisibility(View.GONE); + mDestroyButton.setOnClickListener(destroyListener); mConferenceType = findViewById(R.id.muc_conference_type); if (getActionBar() != null) { getActionBar().setHomeButtonEnabled(true); @@ -604,8 +631,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers mConferenceInfoMam.setText(R.string.server_info_unavailable); } if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { + mDestroyButton.setVisibility(View.VISIBLE); mChangeConferenceSettingsButton.setVisibility(View.VISIBLE); } else { + mDestroyButton.setVisibility(View.GONE); mChangeConferenceSettingsButton.setVisibility(View.GONE); } } else { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 81611343a..005bc2b74 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -96,6 +96,7 @@ public class ConversationActivity extends XmppActivity implements OnAccountUpdate, OnConversationUpdate, OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, View.OnClickListener { public static final String ACTION_VIEW_CONVERSATION = "de.pixart.messenger.VIEW"; + public static final String ACTION_DESTROY_MUC = "de.pixart.messenger.DESTROY_MUC"; public static final String CONVERSATION = "conversationUuid"; public static final String EXTRA_DOWNLOAD_UUID = "de.pixart.messenger.download_uuid"; public static final String TEXT = "text"; @@ -1204,6 +1205,15 @@ public class ConversationActivity extends XmppActivity } else { setIntent(intent); } + } else if (intent != null && ACTION_DESTROY_MUC.equals(intent.getAction())) { + final Bundle extras = intent.getExtras(); + if (extras != null && extras.containsKey("MUC_UUID")) { + Log.d(Config.LOGTAG, "Get " + intent.getAction() + " intent for " + extras.getString("MUC_UUID")); + Conversation conversation = xmppConnectionService.findConversationByUuid(extras.getString("MUC_UUID")); + ConversationActivity.this.xmppConnectionService.clearConversationHistory(conversation); + xmppConnectionService.destroyMuc(conversation); + endConversation(conversation); + } } } @@ -1292,8 +1302,9 @@ public class ConversationActivity extends XmppActivity void onBackendConnected() { this.xmppConnectionService.getNotificationService().setIsInForeground(true); updateConversationList(); + final Intent intent = getIntent(); + final Bundle extras = intent.getExtras(); - Bundle extras = getIntent().getExtras(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (extras != null && extras.containsKey(PREF_FIRST_START)) { FirstStartTime = extras.getLong(PREF_FIRST_START); @@ -1321,13 +1332,13 @@ public class ConversationActivity extends XmppActivity editor.putLong(PREF_FIRST_START, FirstStartTime); editor.commit(); // restart - Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName()); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); + Intent restartintent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName()); + restartintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + restartintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(restartintent); System.exit(0); } - final Intent intent = getIntent(); + if (xmppConnectionService.getAccounts().size() == 0) { if (mRedirected.compareAndSet(false, true)) { if (Config.X509_VERIFICATION) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 509d4d17d..edd88d58a 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1145,8 +1145,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa showSnackbar(R.string.conference_kicked, R.string.join, joinMuc); break; case UNKNOWN: - activity.xmppConnectionService.joinMuc(conversation); - //showSnackbar(R.string.conference_unknown_error, R.string.try_again, joinMuc); + showSnackbar(R.string.conference_unknown_error, R.string.leave, leaveMuc); break; case INVALID_NICK: showSnackbar(R.string.invalid_muc_nick, R.string.edit, clickToMuc); |