Update URL formatting for username links.
This commit is contained in:
parent
58489bab61
commit
7e45fc4a3e
3 changed files with 20 additions and 3 deletions
|
@ -22,6 +22,7 @@ import com.airbnb.lottie.SimpleColorFilter;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import org.signal.core.util.logging.Log;
|
||||||
import org.thoughtcrime.securesms.AvatarPreviewActivity;
|
import org.thoughtcrime.securesms.AvatarPreviewActivity;
|
||||||
import org.thoughtcrime.securesms.LoggingFragment;
|
import org.thoughtcrime.securesms.LoggingFragment;
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
@ -42,11 +43,16 @@ import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
|
||||||
import org.thoughtcrime.securesms.util.navigation.SafeNavigation;
|
import org.thoughtcrime.securesms.util.navigation.SafeNavigation;
|
||||||
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;
|
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ManageProfileFragment extends LoggingFragment {
|
public class ManageProfileFragment extends LoggingFragment {
|
||||||
|
|
||||||
|
private static final String TAG = Log.tag(ManageProfileFragment.class);
|
||||||
|
|
||||||
private AlertDialog avatarProgress;
|
private AlertDialog avatarProgress;
|
||||||
private ManageProfileViewModel viewModel;
|
private ManageProfileViewModel viewModel;
|
||||||
private ManageProfileFragmentBinding binding;
|
private ManageProfileFragmentBinding binding;
|
||||||
|
@ -214,6 +220,14 @@ public class ManageProfileFragment extends LoggingFragment {
|
||||||
binding.manageProfileUsernameShare.setVisibility(View.GONE);
|
binding.manageProfileUsernameShare.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
binding.manageProfileUsername.setText(username);
|
binding.manageProfileUsername.setText(username);
|
||||||
|
|
||||||
|
try {
|
||||||
|
binding.manageProfileUsernameSubtitle.setText(getString(R.string.signal_me_username_url_no_scheme, URLEncoder.encode(username, StandardCharsets.UTF_8.toString())));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
Log.w(TAG, "Could not format username link", e);
|
||||||
|
binding.manageProfileUsernameSubtitle.setText(R.string.ManageProfileFragment_your_username);
|
||||||
|
}
|
||||||
|
|
||||||
binding.manageProfileUsernameShare.setVisibility(View.VISIBLE);
|
binding.manageProfileUsernameShare.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.util.FragmentResultContract
|
import org.thoughtcrime.securesms.util.FragmentResultContract
|
||||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||||
import org.thoughtcrime.securesms.util.Util
|
import org.thoughtcrime.securesms.util.Util
|
||||||
|
import java.net.URLEncoder
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the user to either share their username directly or to copy it to their clipboard.
|
* Allows the user to either share their username directly or to copy it to their clipboard.
|
||||||
|
@ -69,7 +71,7 @@ class UsernameShareBottomSheet : DSLSettingsBottomSheetFragment() {
|
||||||
|
|
||||||
customPref(
|
customPref(
|
||||||
CopyButton.Model(
|
CopyButton.Model(
|
||||||
text = getString(R.string.signal_me_url, username),
|
text = getString(R.string.signal_me_username_url, URLEncoder.encode(username, StandardCharsets.UTF_8.toString())),
|
||||||
onClick = {
|
onClick = {
|
||||||
copyToClipboard(it)
|
copyToClipboard(it)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +82,7 @@ class UsernameShareBottomSheet : DSLSettingsBottomSheetFragment() {
|
||||||
|
|
||||||
customPref(
|
customPref(
|
||||||
ShareButton.Model(
|
ShareButton.Model(
|
||||||
text = getString(R.string.signal_me_url, username),
|
text = getString(R.string.signal_me_username_url, URLEncoder.encode(username, StandardCharsets.UTF_8.toString())),
|
||||||
onClick = {
|
onClick = {
|
||||||
openShareSheet(it.text)
|
openShareSheet(it.text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<string name="sustainer_boost_and_badges" translatable="false">https://support.signal.org/hc/articles/4408365318426</string>
|
<string name="sustainer_boost_and_badges" translatable="false">https://support.signal.org/hc/articles/4408365318426</string>
|
||||||
<string name="google_pay_url" translatable="false">https://pay.google.com</string>
|
<string name="google_pay_url" translatable="false">https://pay.google.com</string>
|
||||||
<string name="donation_decline_code_error_url" translatable="false">https://support.signal.org/hc/articles/4408365318426#errors</string>
|
<string name="donation_decline_code_error_url" translatable="false">https://support.signal.org/hc/articles/4408365318426#errors</string>
|
||||||
<string name="signal_me_url" translatable="false">https://signal.me/%1$s</string>
|
<string name="signal_me_username_url" translatable="false">https://signal.me/#u/%1$s</string>
|
||||||
|
<string name="signal_me_username_url_no_scheme" translatable="false">signal.me/#u/%1$s</string>
|
||||||
|
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue