Merge branch 'implement_room_destruction' of https://github.com/area-42/Conversations into bookmarks
This commit is contained in:
commit
9d849f540f
|
@ -2829,6 +2829,26 @@ public class XmppConnectionService extends Service {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroyRoom(final Conversation conversation, final OnRoomDestroy callback) {
|
||||||
|
IqPacket request = new IqPacket(IqPacket.TYPE.SET);
|
||||||
|
request.setTo(conversation.getJid().asBareJid());
|
||||||
|
request.query("http://jabber.org/protocol/muc#owner").addChild("destroy");
|
||||||
|
sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() {
|
||||||
|
@Override
|
||||||
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onRoomDestroySucceeded();
|
||||||
|
}
|
||||||
|
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onRoomDestroyFailed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void disconnect(Account account, boolean force) {
|
private void disconnect(Account account, boolean force) {
|
||||||
if ((account.getStatus() == Account.State.ONLINE)
|
if ((account.getStatus() == Account.State.ONLINE)
|
||||||
|| (account.getStatus() == Account.State.DISABLED)) {
|
|| (account.getStatus() == Account.State.DISABLED)) {
|
||||||
|
@ -4147,6 +4167,12 @@ public class XmppConnectionService extends Service {
|
||||||
void onPasswordChangeFailed();
|
void onPasswordChangeFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnRoomDestroy {
|
||||||
|
void onRoomDestroySucceeded();
|
||||||
|
|
||||||
|
void onRoomDestroyFailed();
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnAffiliationChanged {
|
public interface OnAffiliationChanged {
|
||||||
void onAffiliationChangedSuccessful(Jid jid);
|
void onAffiliationChangedSuccessful(Jid jid);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ import rocks.xmpp.addr.Jid;
|
||||||
import static eu.siacs.conversations.entities.Bookmark.printableValue;
|
import static eu.siacs.conversations.entities.Bookmark.printableValue;
|
||||||
import static eu.siacs.conversations.utils.StringUtils.changed;
|
import static eu.siacs.conversations.utils.StringUtils.changed;
|
||||||
|
|
||||||
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, TextWatcher, OnMediaLoaded {
|
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, XmppConnectionService.OnRoomDestroy, TextWatcher, OnMediaLoaded {
|
||||||
public static final String ACTION_VIEW_MUC = "view_muc";
|
public static final String ACTION_VIEW_MUC = "view_muc";
|
||||||
|
|
||||||
private static final float INACTIVE_ALPHA = 0.4684f; //compromise between dark and light theme
|
private static final float INACTIVE_ALPHA = 0.4684f; //compromise between dark and light theme
|
||||||
|
@ -319,6 +319,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
case R.id.action_delete_bookmark:
|
case R.id.action_delete_bookmark:
|
||||||
deleteBookmark();
|
deleteBookmark();
|
||||||
break;
|
break;
|
||||||
|
case R.id.action_destroy_room:
|
||||||
|
destroyRoom();
|
||||||
|
break;
|
||||||
case R.id.action_advanced_mode:
|
case R.id.action_advanced_mode:
|
||||||
this.mAdvancedMode = !menuItem.isChecked();
|
this.mAdvancedMode = !menuItem.isChecked();
|
||||||
menuItem.setChecked(this.mAdvancedMode);
|
menuItem.setChecked(this.mAdvancedMode);
|
||||||
|
@ -406,6 +409,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
|
MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
|
||||||
MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
|
MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
|
||||||
MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode);
|
MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode);
|
||||||
|
MenuItem menuItemDestroyRoom = menu.findItem(R.id.action_destroy_room);
|
||||||
menuItemAdvancedMode.setChecked(mAdvancedMode);
|
menuItemAdvancedMode.setChecked(mAdvancedMode);
|
||||||
if (mConversation == null) {
|
if (mConversation == null) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -417,6 +421,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
menuItemDeleteBookmark.setVisible(false);
|
menuItemDeleteBookmark.setVisible(false);
|
||||||
menuItemSaveBookmark.setVisible(true);
|
menuItemSaveBookmark.setVisible(true);
|
||||||
}
|
}
|
||||||
|
menuItemDestroyRoom.setVisible(mConversation.getMucOptions().getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +486,19 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void destroyRoom() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.destroy_room);
|
||||||
|
builder.setMessage(R.string.destroy_room_dialog);
|
||||||
|
builder.setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||||
|
xmppConnectionService.destroyRoom(mConversation, ConferenceDetailsActivity.this);
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
|
final AlertDialog dialog = builder.create();
|
||||||
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {
|
||||||
if (mPendingConferenceInvite != null) {
|
if (mPendingConferenceInvite != null) {
|
||||||
|
@ -687,6 +705,15 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
displayToast(getString(resId, nick));
|
displayToast(getString(resId, nick));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRoomDestroySucceeded() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onRoomDestroyFailed() {
|
||||||
|
displayToast(getString(R.string.could_not_destroy_room));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPushSucceeded() {
|
public void onPushSucceeded() {
|
||||||
displayToast(getString(R.string.modified_conference_options));
|
displayToast(getString(R.string.modified_conference_options));
|
||||||
|
|
|
@ -31,6 +31,11 @@
|
||||||
android:orderInCategory="80"
|
android:orderInCategory="80"
|
||||||
app:showAsAction="never"
|
app:showAsAction="never"
|
||||||
android:title="@string/delete_bookmark"/>
|
android:title="@string/delete_bookmark"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_destroy_room"
|
||||||
|
android:orderInCategory="82"
|
||||||
|
app:showAsAction="never"
|
||||||
|
android:title="@string/destroy_room"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_advanced_mode"
|
android:id="@+id/action_advanced_mode"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
|
|
|
@ -228,6 +228,9 @@
|
||||||
<string name="conference_address_example">room@conference.example.com/nick</string>
|
<string name="conference_address_example">room@conference.example.com/nick</string>
|
||||||
<string name="save_as_bookmark">Save as bookmark</string>
|
<string name="save_as_bookmark">Save as bookmark</string>
|
||||||
<string name="delete_bookmark">Delete bookmark</string>
|
<string name="delete_bookmark">Delete bookmark</string>
|
||||||
|
<string name="destroy_room">Destroy group chat</string>
|
||||||
|
<string name="destroy_room_dialog">Are you sure you want to destroy this group chat?\n\n<b>Warning:</b> The group chat will be completely removed on the server.</string>
|
||||||
|
<string name="could_not_destroy_room">Could not destroy room</string>
|
||||||
<string name="bookmark_already_exists">This bookmark already exists</string>
|
<string name="bookmark_already_exists">This bookmark already exists</string>
|
||||||
<string name="action_edit_subject">Edit group chat subject</string>
|
<string name="action_edit_subject">Edit group chat subject</string>
|
||||||
<string name="topic">Topic</string>
|
<string name="topic">Topic</string>
|
||||||
|
|
Loading…
Reference in New Issue