Skip to content

Commit

Permalink
Adds visible contact id in the contact properties. Allows copying the…
Browse files Browse the repository at this point in the history
… id. Fixes element-hq#2756
  • Loading branch information
vranki committed Dec 13, 2018
1 parent 1e78cf4 commit 4996e04
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public class VectorMemberDetailsActivity extends MXCActionBarActivity implements
private static final int ITEM_ACTION_START_VIDEO_CALL = 13;
private static final int ITEM_ACTION_MENTION = 14;
private static final int ITEM_ACTION_DEVICES = 15;

private static final int VECTOR_ROOM_MODERATOR_LEVEL = 50;
private static final int VECTOR_ROOM_ADMIN_LEVEL = 100;

Expand All @@ -131,6 +130,8 @@ public class VectorMemberDetailsActivity extends MXCActionBarActivity implements
ImageView mMemberAvatarBadgeImageView;
@BindView(R.id.member_details_name)
TextView mMemberNameTextView;
@BindView(R.id.member_details_id)
TextView mMemberIdTextView;
@BindView(R.id.member_details_presence)
TextView mPresenceTextView;

Expand Down Expand Up @@ -1223,23 +1224,6 @@ public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition
});


// when clicking on the username
// switch member name <-> member id
mMemberNameTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
User user = mSession.getDataHandler().getUser(mMemberId);

if (TextUtils.equals(mMemberNameTextView.getText(), mMemberId)) {
if ((null != user) && !TextUtils.isEmpty(user.displayname)) {
mMemberNameTextView.setText(user.displayname);
}
} else {
mMemberNameTextView.setText(mMemberId);
}
}
});

// long tap : copy to the clipboard
mMemberNameTextView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
Expand All @@ -1249,6 +1233,14 @@ public boolean onLongClick(View v) {
}
});

// copy id to the clipboard on click
mMemberIdTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SystemUtilsKt.copyToClipboard(VectorMemberDetailsActivity.this, mMemberIdTextView.getText());
}
});

mMemberAvatarImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -1478,9 +1470,11 @@ private void updateUi() {
if (null != mMemberNameTextView) {
if ((null != mRoomMember) && !TextUtils.isEmpty(mRoomMember.displayname)) {
mMemberNameTextView.setText(mRoomMember.displayname);
mMemberIdTextView.setText(mRoomMember.getUserId());
} else {
refreshUser();
mMemberNameTextView.setText(mUser.displayname);
mMemberIdTextView.setText(mUser.user_id);
}

// do not display the activity name in the action bar
Expand Down
29 changes: 28 additions & 1 deletion vector/src/main/res/layout/activity_member_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,39 @@
android:textColor="@android:color/white"
android:textSize="20sp" />

<!-- member id -->
<TextView
android:id="@+id/member_details_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/member_details_name"
android:layout_marginBottom="16dp"
android:gravity="center_horizontal"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?attr/vctr_default_text_light_color"
android:textSize="18sp" />
<!-- member id copy button -->
<TextView
android:id="@+id/member_details_id_copy"
android:text="@string/copy_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/member_details_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:paddingRight="10dp"
android:paddingEnd="10dp"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="20sp" />

<!-- the member presence -->
<TextView
android:id="@+id/member_details_presence"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/member_details_name"
android:layout_below="@id/member_details_id"
android:layout_marginBottom="16dp"
android:ellipsize="end"
android:gravity="center_horizontal"
Expand Down
1 change: 1 addition & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="leave">Leave</string>
<string name="send">Send</string>
<string name="copy">Copy</string>
<string name="copy_icon">⎘</string>
<string name="resend">Resend</string>
<string name="redact">Redact</string>
<string name="quote">Quote</string>
Expand Down

0 comments on commit 4996e04

Please sign in to comment.