mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
code-quality: remove CDATA and <u> tags from string.xml (#3310)
Remove CDATA and <u> tags from string resources. Instead use setUnderlinedText() method added in Utils to create underlined string resources.
This commit is contained in:
parent
75d489128c
commit
4038519012
5 changed files with 34 additions and 24 deletions
|
|
@ -33,7 +33,10 @@ public class AboutActivity extends NavigationBaseActivity {
|
|||
@BindView(R.id.about_license) HtmlTextView aboutLicenseText;
|
||||
@BindView(R.id.about_faq) TextView faqText;
|
||||
@BindView(R.id.about_improve) HtmlTextView improve;
|
||||
|
||||
@BindView(R.id.about_rate_us) TextView rateUsText;
|
||||
@BindView(R.id.about_privacy_policy) TextView privacyPolicyText;
|
||||
@BindView(R.id.about_translate) TextView translateText;
|
||||
@BindView(R.id.about_credits) TextView creditsText;
|
||||
/**
|
||||
* This method helps in the creation About screen
|
||||
*
|
||||
|
|
@ -54,22 +57,13 @@ public class AboutActivity extends NavigationBaseActivity {
|
|||
String improveText = String.format(getString(R.string.about_improve), Urls.NEW_ISSUE_URL);
|
||||
improve.setHtmlText(improveText);
|
||||
|
||||
SpannableString content = new SpannableString(getString(R.string.about_faq));
|
||||
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
|
||||
faqText.setText(content);
|
||||
|
||||
versionText.setText(ConfigUtils.getVersionNameWithSha(getApplicationContext()));
|
||||
|
||||
TextView rate_us = findViewById(R.id.about_rate_us);
|
||||
TextView privacy_policy = findViewById(R.id.about_privacy_policy);
|
||||
TextView translate = findViewById(R.id.about_translate);
|
||||
TextView credits = findViewById(R.id.about_credits);
|
||||
TextView faq = findViewById(R.id.about_faq);
|
||||
rate_us.setText(StringUtil.fromHtml(getString(R.string.about_rate_us)));
|
||||
privacy_policy.setText(StringUtil.fromHtml(getString(R.string.about_privacy_policy)));
|
||||
translate.setText(StringUtil.fromHtml(getString(R.string.about_translate)));
|
||||
credits.setText(StringUtil.fromHtml(getString(R.string.about_credits)));
|
||||
faq.setText(StringUtil.fromHtml(getString(R.string.about_faq)));
|
||||
Utils.setUnderlinedText(faqText, R.string.about_faq, getApplicationContext());
|
||||
Utils.setUnderlinedText(rateUsText, R.string.about_rate_us, getApplicationContext());
|
||||
Utils.setUnderlinedText(privacyPolicyText, R.string.about_privacy_policy, getApplicationContext());
|
||||
Utils.setUnderlinedText(translateText, R.string.about_translate, getApplicationContext());
|
||||
Utils.setUnderlinedText(creditsText, R.string.about_credits, getApplicationContext());
|
||||
|
||||
initDrawer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -185,4 +188,17 @@ public class Utils {
|
|||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets underlined string text to a TextView
|
||||
*
|
||||
* @param textView TextView associated with string resource
|
||||
* @param stringResourceName string resource name
|
||||
* @param context
|
||||
*/
|
||||
public static void setUnderlinedText(TextView textView, int stringResourceName, Context context) {
|
||||
SpannableString content = new SpannableString(context.getString(stringResourceName));
|
||||
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
|
||||
textView.setText(content);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
|||
if (position == PAGE_LAYOUTS.length - 1) {
|
||||
// Add link to more information
|
||||
TextView moreInfo = layout.findViewById(R.id.welcomeInfo);
|
||||
moreInfo.setText(Html.fromHtml(container.getContext().getString(R.string.welcome_help_button_text)));
|
||||
Utils.setUnderlinedText(moreInfo, R.string.welcome_help_button_text, container.getContext());
|
||||
moreInfo.setOnClickListener(view -> Utils.handleWebUrl(
|
||||
container.getContext(),
|
||||
Uri.parse("https://commons.wikimedia.org/wiki/Help:Contents")
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
final View view = inflater.inflate(R.layout.fragment_media_detail, container, false);
|
||||
|
||||
ButterKnife.bind(this,view);
|
||||
seeMore.setText(StringUtil.fromHtml(getString(R.string.nominated_see_more)));
|
||||
Utils.setUnderlinedText(seeMore, R.string.nominated_see_more, container.getContext());
|
||||
|
||||
if (isCategoryImage){
|
||||
authorLayout.setVisibility(VISIBLE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue