Skip to content

Commit 4343bd4

Browse files
committed
add copy ID button to Topic Info
1 parent d1abd6e commit 4343bd4

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

app/src/main/java/co/tinode/tindroid/AccountInfoFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
5252
toolbar.setTitle(R.string.account_settings);
5353
toolbar.setNavigationOnClickListener(v -> activity.getSupportFragmentManager().popBackStack());
5454

55-
fragment.findViewById(R.id.copy_iv).setOnClickListener(v -> {
55+
fragment.findViewById(R.id.buttonCopyID).setOnClickListener(v -> {
5656
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
5757
if (clipboard != null) {
58-
clipboard.setPrimaryClip(ClipData.newPlainText("message text", Cache.getTinode().getMyId()));
58+
clipboard.setPrimaryClip(ClipData.newPlainText("account ID", Cache.getTinode().getMyId()));
5959
Toast.makeText(activity, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
6060
}
6161
});

app/src/main/java/co/tinode/tindroid/TopicGeneralFragment.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import android.annotation.SuppressLint;
44
import android.app.Activity;
5+
import android.content.ClipData;
6+
import android.content.ClipboardManager;
7+
import android.content.Context;
58
import android.content.Intent;
69
import android.os.Bundle;
710
import android.text.TextUtils;
@@ -14,6 +17,7 @@
1417
import android.view.ViewGroup;
1518
import android.widget.EditText;
1619
import android.widget.TextView;
20+
import android.widget.Toast;
1721

1822
import com.google.android.flexbox.FlexboxLayout;
1923

@@ -98,6 +102,13 @@ public void onViewCreated(@NonNull View view, Bundle savedInstance) {
98102
mAvatarPickerLauncher.launch(launcher);
99103
}
100104
});
105+
view.findViewById(R.id.buttonCopyID).setOnClickListener(v -> {
106+
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
107+
if (clipboard != null && mTopic != null) {
108+
clipboard.setPrimaryClip(ClipData.newPlainText("contact ID", mTopic.getName()));
109+
Toast.makeText(activity, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
110+
}
111+
});
101112
}
102113

103114
@Override

app/src/main/res/layout/fragment_account_info.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@
5858
android:typeface="monospace"
5959
tools:text="usrfv2qrUr6vAd" />
6060

61-
<ImageView
62-
android:id="@+id/copy_iv"
63-
app:tint="@color/colorAccent"
64-
android:src="@drawable/ic_copy"
61+
<androidx.appcompat.widget.AppCompatButton
62+
android:id="@+id/buttonCopyID"
63+
style="?attr/buttonBarButtonStyle"
6564
android:layout_width="wrap_content"
66-
android:layout_height="wrap_content" />
65+
android:layout_height="wrap_content"
66+
android:contentDescription="@string/action_copy"
67+
android:drawablePadding="4sp"
68+
app:drawableStartCompat="@drawable/ic_copy"
69+
app:drawableTint="?android:textColorPrimary" />
6770
</LinearLayout>
6871

6972
<TextView

app/src/main/res/layout/fragment_tpc_general.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,25 @@
116116
<TextView
117117
android:id="@+id/topicAddress"
118118
style="?android:textAppearanceMedium"
119-
android:layout_width="wrap_content"
119+
android:layout_width="0dp"
120120
android:layout_height="wrap_content"
121+
android:layout_weight="1"
121122
android:fontFamily="monospace"
122123
android:textIsSelectable="true"
123124
android:typeface="monospace"
124125
tools:ignore="TouchTargetSizeCheck"
125126
tools:text="grpFv2qrUr6vAd" />
126127

128+
<androidx.appcompat.widget.AppCompatButton
129+
android:id="@+id/buttonCopyID"
130+
style="?attr/buttonBarButtonStyle"
131+
android:layout_width="wrap_content"
132+
android:layout_height="wrap_content"
133+
android:contentDescription="@string/action_copy"
134+
android:drawablePadding="4sp"
135+
app:drawableStartCompat="@drawable/ic_copy"
136+
app:drawableTint="?android:textColorPrimary" />
137+
127138
</LinearLayout>
128139

129140
<View

0 commit comments

Comments
 (0)