mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 07:48:34 +00:00
Add ability to copy a number via long-press.
This commit is contained in:
parent
f6637b7caf
commit
6932340671
@ -22,6 +22,7 @@ import android.view.ViewGroup;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -77,8 +78,10 @@ import org.thoughtcrime.securesms.util.DynamicDarkToolbarTheme;
|
|||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
||||||
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
||||||
@ -728,6 +731,15 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||||||
public void onInSecureCallClicked() {
|
public void onInSecureCallClicked() {
|
||||||
CommunicationActions.startInsecureCall(requireActivity(), recipient.get());
|
CommunicationActions.startInsecureCall(requireActivity(), recipient.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongClick() {
|
||||||
|
if (recipient.get().hasE164()) {
|
||||||
|
Util.copyToClipboard(requireContext(), recipient.get().requireE164());
|
||||||
|
ServiceUtil.getVibrator(requireContext()).vibrate(250);
|
||||||
|
Toast.makeText(requireContext(), R.string.RecipientBottomSheet_copied_to_clipboard, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CustomNotificationsChangedListener implements Preference.OnPreferenceChangeListener {
|
private class CustomNotificationsChangedListener implements Preference.OnPreferenceChangeListener {
|
||||||
|
@ -17,6 +17,7 @@ public class ContactPreference extends Preference {
|
|||||||
private ImageView callButton;
|
private ImageView callButton;
|
||||||
private ImageView secureCallButton;
|
private ImageView secureCallButton;
|
||||||
private ImageView secureVideoButton;
|
private ImageView secureVideoButton;
|
||||||
|
private View itemView;
|
||||||
|
|
||||||
private Listener listener;
|
private Listener listener;
|
||||||
private boolean secure;
|
private boolean secure;
|
||||||
@ -50,6 +51,7 @@ public class ContactPreference extends Preference {
|
|||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(view);
|
||||||
|
|
||||||
|
this.itemView = view.itemView;
|
||||||
this.messageButton = (ImageView) view.findViewById(R.id.message);
|
this.messageButton = (ImageView) view.findViewById(R.id.message);
|
||||||
this.callButton = (ImageView) view.findViewById(R.id.call);
|
this.callButton = (ImageView) view.findViewById(R.id.call);
|
||||||
this.secureCallButton = (ImageView) view.findViewById(R.id.secure_call);
|
this.secureCallButton = (ImageView) view.findViewById(R.id.secure_call);
|
||||||
@ -88,13 +90,21 @@ public class ContactPreference extends Preference {
|
|||||||
if (this.secureCallButton != null) this.secureCallButton.setOnClickListener(v -> listener.onSecureCallClicked());
|
if (this.secureCallButton != null) this.secureCallButton.setOnClickListener(v -> listener.onSecureCallClicked());
|
||||||
if (this.secureVideoButton != null) this.secureVideoButton.setOnClickListener(v -> listener.onSecureVideoClicked());
|
if (this.secureVideoButton != null) this.secureVideoButton.setOnClickListener(v -> listener.onSecureVideoClicked());
|
||||||
if (this.callButton != null) this.callButton.setOnClickListener(v -> listener.onInSecureCallClicked());
|
if (this.callButton != null) this.callButton.setOnClickListener(v -> listener.onInSecureCallClicked());
|
||||||
|
|
||||||
|
if (this.itemView != null) {
|
||||||
|
itemView.setOnLongClickListener(v -> {
|
||||||
|
listener.onLongClick();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public void onMessageClicked();
|
void onMessageClicked();
|
||||||
public void onSecureCallClicked();
|
void onSecureCallClicked();
|
||||||
public void onSecureVideoClicked();
|
void onSecureVideoClicked();
|
||||||
public void onInSecureCallClicked();
|
void onInSecureCallClicked();
|
||||||
|
void onLongClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -20,7 +21,9 @@ import org.thoughtcrime.securesms.R;
|
|||||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||||
import org.thoughtcrime.securesms.groups.GroupId;
|
import org.thoughtcrime.securesms.groups.GroupId;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -110,6 +113,12 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
|||||||
.trim();
|
.trim();
|
||||||
usernameNumber.setText(usernameNumberString);
|
usernameNumber.setText(usernameNumberString);
|
||||||
usernameNumber.setVisibility(TextUtils.isEmpty(usernameNumberString) ? View.GONE : View.VISIBLE);
|
usernameNumber.setVisibility(TextUtils.isEmpty(usernameNumberString) ? View.GONE : View.VISIBLE);
|
||||||
|
usernameNumber.setOnLongClickListener(v -> {
|
||||||
|
Util.copyToClipboard(v.getContext(), usernameNumber.getText().toString());
|
||||||
|
ServiceUtil.getVibrator(v.getContext()).vibrate(250);
|
||||||
|
Toast.makeText(v.getContext(), R.string.RecipientBottomSheet_copied_to_clipboard, Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
boolean blocked = recipient.isBlocked();
|
boolean blocked = recipient.isBlocked();
|
||||||
blockButton.setVisibility(blocked ? View.GONE : View.VISIBLE);
|
blockButton.setVisibility(blocked ? View.GONE : View.VISIBLE);
|
||||||
|
@ -2312,6 +2312,7 @@
|
|||||||
|
|
||||||
<string name="RecipientBottomSheet_remove_s_from_s">Remove %1$s from "%2$s"?</string>
|
<string name="RecipientBottomSheet_remove_s_from_s">Remove %1$s from "%2$s"?</string>
|
||||||
<string name="RecipientBottomSheet_remove">Remove</string>
|
<string name="RecipientBottomSheet_remove">Remove</string>
|
||||||
|
<string name="RecipientBottomSheet_copied_to_clipboard">Copied to clipboard</string>
|
||||||
|
|
||||||
<string name="GroupRecipientListItem_admin">Admin</string>
|
<string name="GroupRecipientListItem_admin">Admin</string>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user