non functional muc edit button

This commit is contained in:
Daniel Gultsch 2018-06-22 21:55:54 +02:00
parent e6532e739a
commit 1f3b4e2ccf
17 changed files with 758 additions and 677 deletions

View File

@ -13,9 +13,7 @@ import android.os.AsyncTask;
import android.os.Bundle; 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.SpannableString;
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;
@ -49,7 +47,6 @@ import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdat
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.MyLinkify; import eu.siacs.conversations.ui.util.MyLinkify;
import eu.siacs.conversations.ui.widget.ClickableMovementMethod;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
import rocks.xmpp.addr.Jid; import rocks.xmpp.addr.Jid;
@ -269,6 +266,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
intent.putExtra("uuid", mConversation.getUuid()); intent.putExtra("uuid", mConversation.getUuid());
startActivity(intent); startActivity(intent);
}); });
this.binding.editMucNameButton.setOnClickListener(this::onMucEditButtonClicked);
} }
@Override @Override
@ -314,6 +312,40 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
return super.onOptionsItemSelected(menuItem); return super.onOptionsItemSelected(menuItem);
} }
public void onMucEditButtonClicked(View v) {
if (this.binding.mucEditor.getVisibility() == View.GONE) {
final MucOptions mucOptions = mConversation.getMucOptions();
this.binding.mucEditor.setVisibility(View.VISIBLE);
this.binding.mucDisplay.setVisibility(View.GONE);
this.binding.editMucNameButton.setImageResource(getThemeResource(R.attr.icon_save, R.drawable.ic_save_black_24dp));
final String name = mucOptions.getName();
this.binding.mucEditTitle.setText("");
final boolean owner = mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER);
if (owner || printableValue(name)) {
this.binding.mucEditTitle.setVisibility(View.VISIBLE);
if (name != null) {
this.binding.mucEditTitle.append(name);
}
} else {
this.binding.mucEditTitle.setVisibility(View.GONE);
}
this.binding.mucEditTitle.setEnabled(owner);
final String subject = mucOptions.getSubject();
this.binding.mucEditSubject.setText("");
if (subject != null) {
this.binding.mucEditSubject.append(subject);
}
this.binding.mucEditSubject.setEnabled(mucOptions.canChangeSubject());
if (!owner) {
this.binding.mucEditSubject.requestFocus();
}
} else {
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));
}
}
@Override @Override
protected String getShareableUri(boolean http) { protected String getShareableUri(boolean http) {
if (mConversation != null) { if (mConversation != null) {
@ -536,6 +568,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
} else { } else {
account = mConversation.getAccount().getJid().asBareJid().toString(); account = mConversation.getAccount().getJid().asBareJid().toString();
} }
this.binding.editMucNameButton.setVisibility((self.getAffiliation().ranks(MucOptions.Affiliation.OWNER) || mucOptions.canChangeSubject()) ? View.VISIBLE : View.GONE);
this.binding.detailsAccount.setText(getString(R.string.using_account, account)); this.binding.detailsAccount.setText(getString(R.string.using_account, account));
this.binding.jid.setText(mConversation.getJid().asBareJid().toEscapedString()); this.binding.jid.setText(mConversation.getJid().asBareJid().toEscapedString());
this.binding.yourPhoto.setImageBitmap(avatarService().get(mConversation, getPixel(72))); this.binding.yourPhoto.setImageBitmap(avatarService().get(mConversation, getPixel(72)));

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="?attr/color_background_primary" android:background="?attr/color_background_primary"

View File

@ -60,23 +60,67 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/muc_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/edit_muc_name_button"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/muc_title" android:id="@+id/muc_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/edit_muc_name_button"
android:textAppearance="@style/TextAppearance.Conversations.Title"/> android:textAppearance="@style/TextAppearance.Conversations.Title"/>
<TextView <TextView
android:id="@+id/muc_subject" android:id="@+id/muc_subject"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:autoLink="web" android:autoLink="web"
android:layout_below="@+id/muc_title"
android:layout_toStartOf="@+id/edit_muc_name_button"
android:textAppearance="@style/TextAppearance.Conversations.Subhead"/> android:textAppearance="@style/TextAppearance.Conversations.Subhead"/>
</LinearLayout>
<LinearLayout
android:id="@+id/muc_editor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/edit_muc_name_button"
android:orientation="vertical"
android:visibility="gone">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<android.support.design.widget.TextInputEditText
android:id="@+id/muc_edit_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/group_chat_name"
android:textAppearance="@style/Widget.Conversations.EditText"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<android.support.design.widget.TextInputEditText
android:id="@+id/muc_edit_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/topic"
android:textAppearance="@style/Widget.Conversations.EditText"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<ImageButton <ImageButton
android:id="@+id/edit_muc_name_button" android:id="@+id/edit_muc_name_button"
@ -152,6 +196,7 @@
</TableRow> </TableRow>
</TableLayout> </TableLayout>
<TextView <TextView
android:id="@+id/jid" android:id="@+id/jid"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -39,7 +39,7 @@
style="@style/Widget.Conversations.EditText" style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/edit_subject_hint" android:hint="@string/topic"
android:nextFocusDown="@+id/subject" android:nextFocusDown="@+id/subject"
android:nextFocusUp="@+id/subject"/> android:nextFocusUp="@+id/subject"/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>

View File

@ -56,6 +56,7 @@
<attr name="icon_download" format="reference"/> <attr name="icon_download" format="reference"/>
<attr name="icon_edit" format="reference"/> <attr name="icon_edit" format="reference"/>
<attr name="icon_edit_body" format="reference"/> <attr name="icon_edit_body" format="reference"/>
<attr name="icon_save" format="reference"/>
<attr name="icon_done" format="reference"/> <attr name="icon_done" format="reference"/>
<attr name="icon_group" format="reference"/> <attr name="icon_group" format="reference"/>
<attr name="icon_new" format="reference"/> <attr name="icon_new" format="reference"/>

View File

@ -228,7 +228,7 @@
<string name="delete_bookmark">Delete bookmark</string> <string name="delete_bookmark">Delete bookmark</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="edit_subject_hint">The subject of this group chat</string> <string name="topic">Topic</string>
<string name="joining_conference">Joining group chat…</string> <string name="joining_conference">Joining group chat…</string>
<string name="leave">Leave</string> <string name="leave">Leave</string>
<string name="contact_added_you">Contact added you to contact list</string> <string name="contact_added_you">Contact added you to contact list</string>
@ -721,4 +721,5 @@
<string name="only_the_owner_can_change_group_chat_avatar">Only the owner can change group chat avatar</string> <string name="only_the_owner_can_change_group_chat_avatar">Only the owner can change group chat avatar</string>
<string name="contact_name">Contact name</string> <string name="contact_name">Contact name</string>
<string name="nickname">Nickname</string> <string name="nickname">Nickname</string>
<string name="group_chat_name">Name</string>
</resources> </resources>

View File

@ -68,6 +68,7 @@
<item type="reference" name="icon_download">@drawable/ic_file_download_white_24dp</item> <item type="reference" name="icon_download">@drawable/ic_file_download_white_24dp</item>
<item type="reference" name="icon_edit">@drawable/ic_edit_white_24dp</item> <item type="reference" name="icon_edit">@drawable/ic_edit_white_24dp</item>
<item type="reference" name="icon_edit_body">@drawable/ic_edit_black_24dp</item> <item type="reference" name="icon_edit_body">@drawable/ic_edit_black_24dp</item>
<item type="reference" name="icon_save">@drawable/ic_save_black_24dp</item>
<item type="reference" name="icon_done">@drawable/ic_done_black_24dp</item> <item type="reference" name="icon_done">@drawable/ic_done_black_24dp</item>
<item type="reference" name="icon_group">@drawable/ic_group_white_24dp</item> <item type="reference" name="icon_group">@drawable/ic_group_white_24dp</item>
<item type="reference" name="icon_new">@drawable/ic_add_white_24dp</item> <item type="reference" name="icon_new">@drawable/ic_add_white_24dp</item>
@ -163,6 +164,7 @@
<item type="reference" name="icon_download">@drawable/ic_file_download_white_24dp</item> <item type="reference" name="icon_download">@drawable/ic_file_download_white_24dp</item>
<item type="reference" name="icon_edit">@drawable/ic_edit_white_24dp</item> <item type="reference" name="icon_edit">@drawable/ic_edit_white_24dp</item>
<item type="reference" name="icon_edit_body">@drawable/ic_edit_white_24dp</item> <item type="reference" name="icon_edit_body">@drawable/ic_edit_white_24dp</item>
<item type="reference" name="icon_save">@drawable/ic_save_white_24dp</item>
<item type="reference" name="icon_done">@drawable/ic_done_black_24dp</item> <item type="reference" name="icon_done">@drawable/ic_done_black_24dp</item>
<item type="reference" name="icon_group">@drawable/ic_group_white_24dp</item> <item type="reference" name="icon_group">@drawable/ic_group_white_24dp</item>
<item type="reference" name="icon_new">@drawable/ic_add_white_24dp</item> <item type="reference" name="icon_new">@drawable/ic_add_white_24dp</item>