mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Resolves Reloading of image on moving to next question in peer review (#2709)
This commit is contained in:
parent
f7e6b20cab
commit
cbab7dd303
5 changed files with 114 additions and 143 deletions
|
|
@ -1,12 +1,15 @@
|
|||
package fr.free.nrw.commons.review;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
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;
|
||||
|
||||
|
|
@ -20,6 +23,7 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.Media;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
||||
import fr.free.nrw.commons.mwapi.MediaResult;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
|
|
@ -33,30 +37,41 @@ import timber.log.Timber;
|
|||
|
||||
public class ReviewActivity extends AuthenticatedActivity {
|
||||
|
||||
public ReviewPagerAdapter reviewPagerAdapter;
|
||||
public ReviewController reviewController;
|
||||
@BindView(R.id.reviewPagerIndicator)
|
||||
public CirclePageIndicator pagerIndicator;
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.navigation_view)
|
||||
NavigationView navigationView;
|
||||
@BindView(R.id.drawer_layout)
|
||||
DrawerLayout drawerLayout;
|
||||
|
||||
@BindView(R.id.reviewPager)
|
||||
ReviewViewPager reviewPager;
|
||||
|
||||
@BindView(R.id.skip_image)
|
||||
Button skip_image_button;
|
||||
@BindView(R.id.imageView)
|
||||
SimpleDraweeView simpleDraweeView;
|
||||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.imageCaption)
|
||||
TextView imageCaption;
|
||||
@Inject
|
||||
MediaWikiApi mwApi;
|
||||
|
||||
@Inject MediaWikiApi mwApi;
|
||||
/**
|
||||
* Consumers should be simply using this method to use this activity.
|
||||
*
|
||||
* @param context
|
||||
* @param title Page title
|
||||
*/
|
||||
public static void startYourself(Context context, String title) {
|
||||
Intent reviewActivity = new Intent(context, ReviewActivity.class);
|
||||
context.startActivity(reviewActivity);
|
||||
}
|
||||
@Inject
|
||||
ReviewHelper reviewHelper;
|
||||
|
||||
public ReviewPagerAdapter reviewPagerAdapter;
|
||||
|
||||
public ReviewController reviewController;
|
||||
|
||||
@BindView(R.id.reviewPagerIndicator)
|
||||
public CirclePageIndicator pagerIndicator;
|
||||
|
||||
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
|
||||
|
||||
|
|
@ -82,20 +97,16 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
reviewPager.setAdapter(reviewPagerAdapter);
|
||||
reviewPagerAdapter.getItem(0);
|
||||
pagerIndicator.setViewPager(reviewPager);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
runRandomizer(); //Run randomizer whenever everything is ready so that a first random image will be added
|
||||
|
||||
skip_image_button.setOnClickListener(view -> runRandomizer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public boolean runRandomizer() {
|
||||
ProgressBar progressBar = reviewPagerAdapter.reviewImageFragments[reviewPager.getCurrentItem()].progressBar;
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
reviewPager.setCurrentItem(0);
|
||||
compositeDisposable.add(reviewHelper.getRandomMedia()
|
||||
.map(Media::getFilename)
|
||||
|
|
@ -105,18 +116,22 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void updateImage(String fileName) {
|
||||
if (fileName.length() == 0) {
|
||||
ViewUtil.showShortSnackbar(drawerLayout, R.string.error_review);
|
||||
return;
|
||||
}
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
reviewController.onImageRefreshed(fileName); //file name is updated
|
||||
compositeDisposable.add(reviewHelper.getFirstRevisionOfFile("File:" + fileName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(revision -> {
|
||||
reviewController.firstRevision = revision;
|
||||
reviewPagerAdapter.updateFileInformation(fileName, revision);
|
||||
reviewPagerAdapter.updateFileInformation(fileName);
|
||||
((TextView) imageCaption).setText(fileName + " is uploaded by: " + revision.getUser());
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}));
|
||||
reviewPager.setCurrentItem(0);
|
||||
compositeDisposable.add(Observable.fromCallable(() -> {
|
||||
|
|
@ -148,14 +163,4 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
runRandomizer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumers should be simply using this method to use this activity.
|
||||
* @param context
|
||||
* @param title Page title
|
||||
*/
|
||||
public static void startYourself(Context context, String title) {
|
||||
Intent reviewActivity = new Intent(context, ReviewActivity.class);
|
||||
context.startActivity(reviewActivity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ import android.widget.Button;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.media.model.MwQueryPage;
|
||||
|
||||
|
|
@ -30,28 +27,20 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
private String catString;
|
||||
|
||||
private View textViewQuestionContext;
|
||||
private View imageCaption;
|
||||
private View textViewQuestion;
|
||||
private SimpleDraweeView simpleDraweeView;
|
||||
|
||||
private Button yesButton;
|
||||
private Button noButton;
|
||||
|
||||
|
||||
public ProgressBar progressBar;
|
||||
private MwQueryPage.Revision revision;
|
||||
|
||||
|
||||
public void update(int position, String fileName, MwQueryPage.Revision revision) {
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
this.fileName = fileName;
|
||||
this.revision = revision;
|
||||
|
||||
fillImageCaption();
|
||||
|
||||
if (simpleDraweeView != null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCategories(Iterable<String> categories) {
|
||||
|
|
@ -78,15 +67,11 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
position = getArguments().getInt("position");
|
||||
View layoutView = inflater.inflate(R.layout.fragment_review_image, container,
|
||||
false);
|
||||
progressBar = layoutView.findViewById(R.id.progressBar);
|
||||
textViewQuestion = layoutView.findViewById(R.id.reviewQuestion);
|
||||
textViewQuestionContext = layoutView.findViewById(R.id.reviewQuestionContext);
|
||||
imageCaption = layoutView.findViewById(R.id.imageCaption);
|
||||
yesButton = layoutView.findViewById(R.id.yesButton);
|
||||
noButton = layoutView.findViewById(R.id.noButton);
|
||||
|
||||
fillImageCaption();
|
||||
|
||||
String question, explanation, yesButtonText, noButtonText;
|
||||
switch (position) {
|
||||
case COPYRIGHT:
|
||||
|
|
@ -125,7 +110,7 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
getReviewActivity().swipeToNext();
|
||||
});
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
question = "How did we get here?";
|
||||
explanation = "No idea.";
|
||||
yesButtonText = "yes";
|
||||
|
|
@ -139,26 +124,13 @@ public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
|||
yesButton.setText(yesButtonText);
|
||||
noButton.setText(noButtonText);
|
||||
|
||||
if(position==CATEGORY){
|
||||
if (position == CATEGORY) {
|
||||
updateCategories(ReviewController.categories);
|
||||
}
|
||||
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
|
||||
if (fileName != null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
return layoutView;
|
||||
}
|
||||
|
||||
private ReviewActivity getReviewActivity() {
|
||||
return (ReviewActivity) requireActivity();
|
||||
}
|
||||
|
||||
private void fillImageCaption() {
|
||||
if (imageCaption != null && fileName != null && revision != null) {
|
||||
((TextView) imageCaption).setText(fileName + " is uploaded by: " + revision.getUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ public class ReviewPagerAdapter extends FragmentStatePagerAdapter {
|
|||
|
||||
public ReviewPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
reviewImageFragments = new ReviewImageFragment[] {
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment()
|
||||
reviewImageFragments = new ReviewImageFragment[]{
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -26,10 +26,10 @@ public class ReviewPagerAdapter extends FragmentStatePagerAdapter {
|
|||
return reviewImageFragments.length;
|
||||
}
|
||||
|
||||
public void updateFileInformation(String fileName, MwQueryPage.Revision revision) {
|
||||
public void updateFileInformation(String fileName) {
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
ReviewImageFragment fragment = reviewImageFragments[i];
|
||||
fragment.update(i, fileName, revision);
|
||||
fragment.update(i, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -26,31 +26,71 @@
|
|||
android:id="@+id/skip_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:text="SKIP THIS IMAGE"
|
||||
android:textColor="@color/button_blue_dark"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_weight="1"
|
||||
android:textStyle="bold"/>
|
||||
android:textStyle="bold" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginTop="5dp">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="0dp"
|
||||
android:src="@drawable/commons_logo_large" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/uploadOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="center|bottom"
|
||||
android:background="#77000000"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/tiny_gap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/imageCaption"
|
||||
style="?android:textAppearanceMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFFFF" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<fr.free.nrw.commons.review.ReviewViewPager
|
||||
android:id="@+id/reviewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:fadingEdge="none"
|
||||
android:layout_weight="13.5"/>
|
||||
android:layout_weight="13.5"
|
||||
android:fadingEdge="none" />
|
||||
|
||||
|
||||
<com.viewpagerindicator.CirclePageIndicator
|
||||
android:id="@+id/reviewPagerIndicator"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center"
|
||||
android:foregroundGravity="center_vertical"
|
||||
android:elevation="1dp"
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
android:layout_weight="0.5"
|
||||
/>
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
android:elevation="1dp"
|
||||
android:foregroundGravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/scroll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -16,103 +14,59 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="6dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="0dp"
|
||||
android:src="@drawable/commons_logo_large" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/uploadOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center|bottom"
|
||||
android:gravity="center"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#77000000"
|
||||
android:padding="@dimen/tiny_gap"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/imageCaption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFFFF"
|
||||
style="?android:textAppearanceMedium"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="visible"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reviewQuestion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="32sp"
|
||||
android:textColor="?attr/reviewHeading"
|
||||
android:gravity="center_vertical"
|
||||
android:text="testing1"
|
||||
/>
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/reviewHeading"
|
||||
android:textSize="32sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reviewQuestionContext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="22sp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="testing2"
|
||||
/>
|
||||
android:textAlignment="center"
|
||||
android:textSize="22sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:weightSum="2"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
<Button
|
||||
android:id="@+id/yesButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="@dimen/activity_margin_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:text="@string/yes"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/yes_button_color"
|
||||
android:textAlignment="center"
|
||||
/>
|
||||
android:textColor="@color/yes_button_color"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/noButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="@dimen/activity_margin_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:text="@string/no"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/no_button_color"
|
||||
android:textAlignment="center"
|
||||
/>
|
||||
android:textColor="@color/no_button_color"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue