make safe button work

This commit is contained in:
Daniel Gultsch 2018-06-23 00:58:20 +02:00
parent 1f3b4e2ccf
commit 64aa238d57
3 changed files with 44 additions and 22 deletions

View File

@ -2538,14 +2538,6 @@ public class XmppConnectionService extends Service {
public void pushSubjectToConference(final Conversation conference, final String subject) { public void pushSubjectToConference(final Conversation conference, final String subject) {
MessagePacket packet = this.getMessageGenerator().conferenceSubject(conference, subject); MessagePacket packet = this.getMessageGenerator().conferenceSubject(conference, subject);
this.sendMessagePacket(conference.getAccount(), packet); this.sendMessagePacket(conference.getAccount(), packet);
final MucOptions mucOptions = conference.getMucOptions();
final MucOptions.User self = mucOptions.getSelf();
if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
Bundle options = new Bundle();
options.putString("muc#roomconfig_persistentroom", "1");
options.putString("muc#roomconfig_roomname", subject);
this.pushConferenceConfiguration(conference, options, null);
}
} }
public void changeAffiliationInConference(final Conversation conference, Jid user, final MucOptions.Affiliation affiliation, final OnAffiliationChanged callback) { public void changeAffiliationInConference(final Conversation conference, Jid user, final MucOptions.Affiliation affiliation, final OnAffiliationChanged callback) {

View File

@ -14,6 +14,7 @@ import android.os.Bundle;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -182,14 +183,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
builder.create().show(); builder.create().show();
} }
}; };
private OnValueEdited onSubjectEdited = new OnValueEdited() {
@Override
public String onValueEdited(String value) {
xmppConnectionService.pushSubjectToConference(mConversation, value.trim().isEmpty() ? null : value.trim());
return null;
}
};
public static boolean cancelPotentialWork(User user, ImageView imageView) { public static boolean cancelPotentialWork(User user, ImageView imageView) {
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
@ -339,13 +332,41 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (!owner) { if (!owner) {
this.binding.mucEditSubject.requestFocus(); this.binding.mucEditSubject.requestFocus();
} }
this.binding.yourPhoto.setVisibility(View.GONE);
} else { } else {
this.binding.mucEditor.setVisibility(View.GONE); String subject = this.binding.mucEditSubject.isEnabled() ? this.binding.mucEditSubject.getEditableText().toString().trim() : null;
this.binding.mucDisplay.setVisibility(View.VISIBLE); String name = this.binding.mucEditTitle.isEnabled() ? this.binding.mucEditTitle.getEditableText().toString().trim() : null;
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_edit_body, R.drawable.ic_edit_black_24dp)); onMucInfoUpdated(subject, name);
hideEditor();
} }
} }
private void hideEditor() {
this.binding.mucEditor.setVisibility(View.GONE);
this.binding.mucDisplay.setVisibility(View.VISIBLE);
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_edit_body, R.drawable.ic_edit_black_24dp));
this.binding.yourPhoto.setVisibility(View.VISIBLE);
}
private void onMucInfoUpdated(String subject, String name) {
final MucOptions mucOptions = mConversation.getMucOptions();
if (mucOptions.canChangeSubject() && !blankOnNull(mucOptions.getSubject()).equals(subject)) {
Log.d(Config.LOGTAG,"subject changed");
xmppConnectionService.pushSubjectToConference(mConversation, subject);
}
if (mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER) && !blankOnNull(mucOptions.getName()).equals(name)) {
Log.d(Config.LOGTAG,"name changed");
Bundle options = new Bundle();
options.putString("muc#roomconfig_persistentroom", "1");
options.putString("muc#roomconfig_roomname", name);
xmppConnectionService.pushConferenceConfiguration(mConversation, options, null);
}
}
private static String blankOnNull(String input) {
return input == null ? "" : input;
}
@Override @Override
protected String getShareableUri(boolean http) { protected String getShareableUri(boolean http) {
if (mConversation != null) { if (mConversation != null) {
@ -558,6 +579,15 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
} }
} }
@Override
public void onBackPressed() {
if (this.binding.mucEditor.getVisibility() == View.VISIBLE) {
hideEditor();
} else {
super.onBackPressed();
}
}
private void updateView() { private void updateView() {
invalidateOptionsMenu(); invalidateOptionsMenu();
final MucOptions mucOptions = mConversation.getMucOptions(); final MucOptions mucOptions = mConversation.getMucOptions();

View File

@ -46,15 +46,15 @@
android:layout_width="72dp" android:layout_width="72dp"
android:layout_height="72dp" android:layout_height="72dp"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
app:riv_corner_radius="2dp"/> app:riv_corner_radius="2dp"
android:layout_marginEnd="@dimen/avatar_item_distance"/>
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/your_photo" android:layout_toEndOf="@+id/your_photo"
android:orientation="vertical" android:orientation="vertical">
android:paddingStart="@dimen/avatar_item_distance">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"