Include previous Wikimedia hackathon (2018) task, peer review, to codebase (#2602)

* Add new activity to manifest

* Create review activity layout base

* Add a new menu item to drawer for peer review

* Add a top menu with randomizer icon to review activity

* Add strings for review button

* Add activity to ActivityBuilderModule for injection

* Add a new drawer item to start review acitivty

* Create base of the Review Activity

* Add fragment pager

* Add new fragment for injection

* Create a fragment pager layout

* Wikimedia hackathon 2018 (#1533)

* First draft of fn to get random recent image

* Use log entries for requests to beta, try to connect refresh button

FIXME: runs http request on main thread, breaks

* Tweak button connection

* Add ReviewController class

* Fix fragments

* Wmhack2018 (#1534)

* tiny fixes

* Load pictures into activities

* Re-use same class for all review fragments (#1537)

And try to add pager indicator

* [WIP] category check

* [WIP] add on-click actions to ReviewActivity

* [WIP] add SendThankTask

* Make it beautiful

* Add some category stuff back in to review (#1538)

* Use standalone category extraction code in MediaDataExtractor

* Add categories to category review page

* Change category question text sizes

* Call randomizer whenever the activity is ready

* Add progressbar

* [WIP] add DeleteTask.askReasonAndExecute

* Fix refresh button string

* Typo: "nominate *for* deletion"

* Add formatting to categories and put them in the same textView

* Pass context and adapters as parameters to controller

* Add actions to controller

* Make everyting work

* Add another fragment to thank

* Fix npe

* Add missing execute method

* Some codes

* Add a funy text

* More random recent image selection (#1542)

time-based randomness is biased - if someone uploaded 100 images in
hour, one week ago, and I select a random point in time, their last
image is way more likely to come up than anything else.

With this, there is still bias towards choosing one of the last N
in any burst of uploads (where N is the number of recent changes
fetched) but it's a bit better than before.

* Create Revision class

* Add meaningluf strings

* Error handling for review image/category fetch (#1543)

* Add information layout for username and filename

* Use Single to get firstRevision

* try to add username and filename

* Ensure caption is shown on every review fragment

* Fix build

* Fixes missing import

* Change button text,show current category, add skip image button

* Modify texts, fix night mode issues

* Positive Wording

* fix landscape issue

* Add checkbox popup,rewording

* Spelling Correction

* Fix merge

* Remove commented out code, use lambda

* Simplify toolbar include
This commit is contained in:
Silky Priya 2019-03-21 17:35:23 +05:30 committed by neslihanturan
parent a1a65d0832
commit a32ba452ec
33 changed files with 1594 additions and 33 deletions

View file

@ -2,14 +2,16 @@ package fr.free.nrw.commons.media;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@ -17,6 +19,7 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
@ -31,6 +34,7 @@ import java.util.Locale;
import javax.inject.Inject;
import javax.inject.Provider;
import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@ -414,6 +418,53 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
if(isDeleted) {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
//Reviewer correct me if i have misunderstood something over here
//But how does this if (delete.getVisibility() == View.VISIBLE) {
// enableDeleteButton(true); makes sense ?
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setMessage("Why should this fileckathon-2018 be deleted?");
final EditText input = new EditText(getActivity());
alert.setView(input);
input.requestFocus();
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String reason = input.getText().toString();
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
deleteTask.execute();
enableDeleteButton(false);
}
});
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
AlertDialog d = alert.create();
input.addTextChangedListener(new TextWatcher() {
private void handleText() {
final Button okButton = d.getButton(AlertDialog.BUTTON_POSITIVE);
if (input.getText().length() == 0) {
okButton.setEnabled(false);
} else {
okButton.setEnabled(true);
}
}
@Override
public void afterTextChanged(Editable arg0) {
handleText();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
d.show();
d.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
@SuppressLint("CheckResult")

View file

@ -0,0 +1,49 @@
package fr.free.nrw.commons.media;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import java.util.Random;
import javax.annotation.Nullable;
public class RecentChangesImageUtils {
private static final String[] imageExtensions = new String[]
{".jpg", ".jpeg", ".png"};
@Nullable
public static String findImageInRecentChanges(NodeList childNodes) {
String imageTitle;
Random r = new Random();
int count = childNodes.getLength();
// Build a range array
int[] randomIndexes = new int[count];
for (int i = 0; i < count; i++) {
randomIndexes[i] = i;
}
// Then shuffle it
for (int i = 0; i < count; i++) {
int swapIndex = r.nextInt(count);
int temp = randomIndexes[i];
randomIndexes[i] = randomIndexes[swapIndex];
randomIndexes[swapIndex] = temp;
}
for (int i = 0; i < count; i++) {
int randomIndex = randomIndexes[i];
Element e = (Element) childNodes.item(randomIndex);
if (e.getAttribute("type").equals("log") && !e.getAttribute("old_revid").equals("0")) {
// For log entries, we only want ones where old_revid is zero, indicating a new file
continue;
}
imageTitle = e.getAttribute("title");
for (String imageExtension : imageExtensions) {
if (imageTitle.toLowerCase().endsWith(imageExtension)) {
return imageTitle;
}
}
}
return null;
}
}