Skip to content

Commit

Permalink
add copy function for id
Browse files Browse the repository at this point in the history
  • Loading branch information
ksxkq committed Jul 25, 2022
1 parent 97ea74d commit b7aace7
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/src/main/java/co/tinode/tindroid/AccountInfoFragment.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package co.tinode.tindroid;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.TextUtils;
Expand All @@ -10,6 +13,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
Expand Down Expand Up @@ -48,6 +52,13 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
toolbar.setTitle(R.string.account_settings);
toolbar.setNavigationOnClickListener(v -> activity.getSupportFragmentManager().popBackStack());

fragment.findViewById(R.id.copy_iv).setOnClickListener(v -> {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) {
clipboard.setPrimaryClip(ClipData.newPlainText("message text", Cache.getTinode().getMyId()));
Toast.makeText(activity, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
}
});
fragment.findViewById(R.id.notifications).setOnClickListener(v ->
((ChatsActivity) activity).showFragment(ChatsActivity.FRAGMENT_ACC_NOTIFICATIONS, null));
fragment.findViewById(R.id.security).setOnClickListener(v ->
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/layout/fragment_account_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
<TextView
android:id="@+id/topicAddress"
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:clickable="false"
android:ellipsize="end"
Expand All @@ -56,6 +57,13 @@
android:textIsSelectable="false"
android:typeface="monospace"
tools:text="usrfv2qrUr6vAd" />

<ImageView
android:id="@+id/copy_iv"
app:tint="@color/colorAccent"
android:src="@drawable/ic_copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

<TextView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,5 @@
<string name="toggle_camera_button">Kamera umschalten</string>
<string name="toggle_microphone_button">Mikrofon umschalten</string>
<string name="voice_calls_limited">Sie können einige eingehende Sprachanrufe nicht empfangen.</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,5 @@
<string name="toggle_camera_button">Alternar cámara</string>
<string name="toggle_microphone_button">Alternar micrófono</string>
<string name="voice_calls_limited">No podrá recibir algunas llamadas de voz entrantes.</string>
<string name="copied_to_clipboard">Copiar al portapapeles</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,5 @@
<string name="toggle_camera_button">Basculer la caméra</string>
<string name="toggle_microphone_button">Basculer le microphone</string>
<string name="voice_calls_limited">Vous ne pourrez pas recevoir certains appels vocaux entrants.</string>
<string name="copied_to_clipboard">Copié dans le presse-papiers</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,5 @@
<string name="toggle_camera_button">카메라 토글</string>
<string name="toggle_microphone_button">마이크 토글</string>
<string name="voice_calls_limited">일부 수신 음성 전화를 받을 수 없습니다.</string>
<string name="copied_to_clipboard">클립보드에 복사 되었습니다</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,5 @@
<string name="outgoing_call">Исходящий звонок</string>
<string name="incoming_call">Входящий звонок</string>
<string name="voice_calls_limited">Вы не сможете принимать некоторые входящие звонки.</string>
<string name="copied_to_clipboard">Скопировано в буфер обмена</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,5 @@
<string name="toggle_camera_button">切換相機</string>
<string name="toggle_microphone_button">切換麥克風</string>
<string name="voice_calls_limited">您將無法接聽某些來電。</string>
<string name="copied_to_clipboard">拷貝成功</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,5 @@
<string name="toggle_camera_button">切换相机</string>
<string name="toggle_microphone_button">切换麦克风</string>
<string name="voice_calls_limited">您将无法接听某些来电。</string>
<string name="copied_to_clipboard">复制成功</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,6 @@
<string name="finish_call_button">Finish call</string>
<string name="video_calls_unavailable">Video calls unavailable</string>
<string name="voice_calls_limited">You will not be able to receive some incoming voice calls.</string>
<string name="copied_to_clipboard">Copied to clipboard</string>

</resources>

0 comments on commit b7aace7

Please sign in to comment.