mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
* BugFix #2915 * Refractor ReviewActivity and ReviewImageFragment and the related layout files, to properly use the scrollview * Use ButterKnife for ViewBindings in ReviewImageFragment * updated resource id names to follow underscore notation in xml * Use menu item instead of ImageView over toolbar in ReviewActivity * use tools:replace instead of android:text for dummy texts * merge nested if's [Codacy review] * updated string review_category_yes_button_text, use textAllCaps in yes and no button in ReviewFragment * updated other strings to use non bold letters
This commit is contained in:
parent
37e9eae314
commit
bb7ab62b34
6 changed files with 221 additions and 198 deletions
|
|
@ -4,24 +4,21 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.viewpagerindicator.CirclePageIndicator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.viewpagerindicator.CirclePageIndicator;
|
||||
import fr.free.nrw.commons.Media;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
||||
|
|
@ -32,10 +29,12 @@ import fr.free.nrw.commons.utils.ViewUtil;
|
|||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.ArrayList;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ReviewActivity extends AuthenticatedActivity {
|
||||
|
||||
@BindView(R.id.reviewPagerIndicator)
|
||||
@BindView(R.id.pager_indicator_review)
|
||||
public CirclePageIndicator pagerIndicator;
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
|
@ -43,20 +42,16 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
NavigationView navigationView;
|
||||
@BindView(R.id.drawer_layout)
|
||||
DrawerLayout drawerLayout;
|
||||
@BindView(R.id.reviewPager)
|
||||
@BindView(R.id.view_pager_review)
|
||||
ReviewViewPager reviewPager;
|
||||
@BindView(R.id.skip_image)
|
||||
Button skip_image_button;
|
||||
@BindView(R.id.imageView)
|
||||
Button btnSkipImage;
|
||||
@BindView(R.id.review_image_view)
|
||||
SimpleDraweeView simpleDraweeView;
|
||||
@BindView(R.id.progressBar)
|
||||
@BindView(R.id.pb_review_image)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.imageCaption)
|
||||
@BindView(R.id.tv_image_caption)
|
||||
TextView imageCaption;
|
||||
@BindView(R.id.skip_image_info)
|
||||
ImageView skipImageInfo;
|
||||
@BindView(R.id.review_image_info)
|
||||
ImageView reviewImageInfo;
|
||||
public ReviewPagerAdapter reviewPagerAdapter;
|
||||
public ReviewController reviewController;
|
||||
@Inject
|
||||
|
|
@ -96,6 +91,7 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_review);
|
||||
ButterKnife.bind(this);
|
||||
setSupportActionBar(toolbar);
|
||||
initDrawer();
|
||||
|
||||
reviewController = new ReviewController(deleteHelper, this);
|
||||
|
|
@ -108,9 +104,17 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
|
||||
runRandomizer(); //Run randomizer whenever everything is ready so that a first random image will be added
|
||||
|
||||
skip_image_button.setOnClickListener(view -> runRandomizer());
|
||||
skipImageInfo.setOnClickListener(view -> showSkipImageInfo());
|
||||
reviewImageInfo.setOnClickListener(view -> showReviewImageInfo());
|
||||
btnSkipImage.setOnClickListener(view -> runRandomizer());
|
||||
|
||||
btnSkipImage.setOnTouchListener((view, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP && event.getRawX() >= (
|
||||
btnSkipImage.getRight() - btnSkipImage
|
||||
.getCompoundDrawables()[2].getBounds().width())) {
|
||||
showSkipImageInfo();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
|
@ -187,4 +191,22 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.menu_review_activty, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_image_info:
|
||||
showReviewImageInfo();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.wikipedia.dataclient.mwapi.MwQueryPage;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import org.wikipedia.dataclient.mwapi.MwQueryPage;
|
||||
|
||||
public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
||||
|
||||
|
|
@ -27,16 +28,18 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
private String fileName;
|
||||
private String catString;
|
||||
|
||||
private View textViewQuestionContext;
|
||||
private View textViewQuestion;
|
||||
|
||||
private Button yesButton;
|
||||
private Button noButton;
|
||||
|
||||
|
||||
public ProgressBar progressBar;
|
||||
private MwQueryPage.Revision revision;
|
||||
|
||||
@BindView(R.id.tv_review_question)
|
||||
TextView textViewQuestion;
|
||||
@BindView(R.id.tv_review_question_context)
|
||||
TextView textViewQuestionContext;
|
||||
@BindView(R.id.button_yes)
|
||||
Button yesButton;
|
||||
@BindView(R.id.button_no)
|
||||
Button noButton;
|
||||
|
||||
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
|
|
@ -50,9 +53,9 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
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));
|
||||
textViewQuestionContext.setText(Html.fromHtml(stringToConvertHtml));
|
||||
} else if (textViewQuestionContext != null) {
|
||||
((TextView) textViewQuestionContext).setText(getResources().getString(R.string.review_no_category));
|
||||
textViewQuestionContext.setText(getResources().getString(R.string.review_no_category));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,10 +71,7 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
position = getArguments().getInt("position");
|
||||
View layoutView = inflater.inflate(R.layout.fragment_review_image, container,
|
||||
false);
|
||||
textViewQuestion = layoutView.findViewById(R.id.reviewQuestion);
|
||||
textViewQuestionContext = layoutView.findViewById(R.id.reviewQuestionContext);
|
||||
yesButton = layoutView.findViewById(R.id.yesButton);
|
||||
noButton = layoutView.findViewById(R.id.noButton);
|
||||
ButterKnife.bind(this,layoutView);
|
||||
|
||||
String question, explanation, yesButtonText, noButtonText;
|
||||
switch (position) {
|
||||
|
|
@ -118,10 +118,8 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
noButtonText = "no";
|
||||
}
|
||||
|
||||
noButton.setOnClickListener(view -> getReviewActivity().swipeToNext());
|
||||
|
||||
((TextView) textViewQuestion).setText(question);
|
||||
((TextView) textViewQuestionContext).setText(explanation);
|
||||
textViewQuestion.setText(question);
|
||||
textViewQuestionContext.setText(explanation);
|
||||
yesButton.setText(yesButtonText);
|
||||
noButton.setText(noButtonText);
|
||||
|
||||
|
|
@ -132,6 +130,11 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
return layoutView;
|
||||
}
|
||||
|
||||
@OnClick(R.id.button_no)
|
||||
public void onNoButtonClicked() {
|
||||
getReviewActivity().swipeToNext();
|
||||
}
|
||||
|
||||
private ReviewActivity getReviewActivity() {
|
||||
return (ReviewActivity) requireActivity();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue