Add formatting to categories and put them in the same textView

This commit is contained in:
neslihanturan 2018-05-20 10:55:56 +03:00 committed by maskara
parent c4978c164e
commit 029d742e58
3 changed files with 23 additions and 25 deletions

View file

@ -2,6 +2,7 @@ package fr.free.nrw.commons.review;
import android.app.AlertDialog;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@ -33,7 +34,8 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
private int position;
private String fileName;
private String catString;
private View catsView;
//private View catsView;
private View textViewQuestionContext;
private SimpleDraweeView simpleDraweeView;
public ProgressBar progressBar;
@ -48,11 +50,16 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
}
public void updateCategories(Iterable<String> categories) {
if (categories!=null && isAdded()) {
catString = TextUtils.join(", ", categories);
if (catsView != null) {
((TextView) catsView).setText(catString);
if (catString != null && !catString.equals("") && textViewQuestionContext != null) {
catString = "<b>"+catString+"</b>";
String stringToConvertHtml = String.format(getResources().getString(R.string.review_category_explanation), catString);
((TextView) textViewQuestionContext).setText(Html.fromHtml(stringToConvertHtml));
} else if (textViewQuestionContext != null) {
((TextView)textViewQuestionContext).setText(getResources().getString(R.string.review_no_category));
}
}
}
@Override
@ -68,19 +75,20 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
false);
progressBar = layoutView.findViewById(R.id.progressBar);
View textView = layoutView.findViewById(R.id.reviewQuestion);
View textViewQuestion = layoutView.findViewById(R.id.reviewQuestion);
View textViewQuestionContext = layoutView.findViewById(R.id.reviewQuestionContext);
catsView = layoutView.findViewById(R.id.reviewCategories);
//View textViewQuestion = layoutView.findViewById(R.id.reviewQuestion);
textViewQuestionContext = layoutView.findViewById(R.id.reviewQuestionContext);
//catsView = layoutView.findViewById(R.id.reviewCategories);
String question;
switch(position) {
case COPYRIGHT:
question = getString(R.string.review_copyright);
break;
case CATEGORY:
textViewQuestion.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT, 0.35f));
textViewQuestionContext.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT, 0.35f));
//textViewQuestion.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT, 0.35f));
//textViewQuestionContext.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT, 0.35f));
question = getString(R.string.review_category);
catsView.setVisibility(View.VISIBLE);
updateCategories(ReviewController.categories);
//catsView.setVisibility(View.VISIBLE);
break;
case SPAM:
question = getString(R.string.review_spam);
@ -95,9 +103,10 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
progressBar.setVisibility(View.GONE);
}
if (catString != null) {
/*if (catString != null) {
((TextView) catsView).setText(catString);
}
}*/
return layoutView;
}
}

View file

@ -52,18 +52,6 @@
android:text="testing2"
/>
<TextView
android:id="@+id/reviewCategories"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:textSize="24sp"
android:textStyle="bold"
android:textAlignment="center"
android:text="testing2"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"

View file

@ -481,5 +481,6 @@ Upload your first media by touching the camera or gallery icon above.</string>
<string name="review_category">Is this mis-categorized?</string>
<string name="review_spam">Is this spam?</string>
<string name="review_no_category">This image is uncategorized</string>
<string name="review_category_explanation">This image is under %1$s categories.</string>
</resources>