-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude nominated media #2858
Exclude nominated media #2858
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Only a few minor style/javadoc improvements left :-)
@@ -74,14 +74,14 @@ public MediaWikiApi provideMediaWikiApi(Context context, | |||
public OkHttpJsonApiClient provideOkHttpJsonApiClient(OkHttpClient okHttpClient, | |||
@Named("tools_force") HttpUrl toolsForgeUrl, | |||
@Named("default_preferences") JsonKvStore defaultKvStore, | |||
Gson gson) { | |||
Gson gson,MediaWikiApi mediaWikiApi) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please insert a space after each comma, thanks! :-)
return new OkHttpJsonApiClient(okHttpClient, | ||
toolsForgeUrl, | ||
WIKIDATA_SPARQL_QUERY_URL, | ||
BuildConfig.WIKIMEDIA_CAMPAIGNS_URL, | ||
BuildConfig.WIKIMEDIA_API_HOST, | ||
defaultKvStore, | ||
gson); | ||
gson,mediaWikiApi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since each parameter is on its own line, I would suggest doing the same for mediaWikiApi
.
@@ -316,6 +317,17 @@ public String prependEdit(String editToken, String processedPageContent, String | |||
.getString("/api/flow-parsoid-utils/@content")); | |||
} | |||
|
|||
@Override | |||
@NonNull | |||
public String getWikiText(PageTitle title) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc explaining (in just a few words) what wikitext is, to avoid misunderstandings.
@@ -67,14 +69,15 @@ public OkHttpJsonApiClient(OkHttpClient okHttpClient, | |||
String campaignsUrl, | |||
String commonsBaseUrl, | |||
JsonKvStore defaultKvStore, | |||
Gson gson) { | |||
Gson gson,MediaWikiApi mediaWikiApi) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
own line
e.printStackTrace(); | ||
} | ||
|
||
if(!wikiText.contains("{{delete")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable :-)
if(!wikiText.contains("{{delete")){ | ||
mediaList.add(media); | ||
} | ||
} else mediaList.add(media); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest putting that into its own
{
...
}
block, to improve visibility, even if not required by the Java language.
Per https://google.github.io/styleguide/javaguide.html#s4.1.1-braces-always-used (which is linked to from https://github.com/commons-app/apps-android-commons/wiki/Contributing-Guidelines )
@@ -105,4 +107,8 @@ | |||
interface ProgressListener { | |||
void onProgress(long transferred, long total); | |||
} | |||
|
|||
@NonNull | |||
String getWikiText(PageTitle title) throws IOException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need a new API to check if the page has been nominated for deletion.
Checkout MediaDataExtractor
. It uses:
Single<Boolean> pageExistsSingle = mediaWikiApi.pageExists("Commons:Deletion_requests/" + filename);
@@ -330,7 +333,19 @@ public OkHttpJsonApiClient(OkHttpClient okHttpClient, | |||
for (MwQueryPage page : pages) { | |||
Media media = Media.from(page); | |||
if (media != null) { | |||
mediaList.add(media); | |||
if(keyword.equals("Category:Uploaded_with_Mobile/Android")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Special case handling for Category:Uploaded_with_Mobile/Android
category should not be the responsibility of OkHttpJsonApiClient
. Please add this check in CategoryImageController
.
@@ -58,6 +59,7 @@ | |||
private final String commonsBaseUrl; | |||
private final JsonKvStore defaultKvStore; | |||
private Gson gson; | |||
private MediaWikiApi mediaWikiApi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't reference MediaWikiApi
from this class. It already has commonsBaseUrl
which can be used to build a new HttpUrl
to call a commons MediaWiki API.
Thanks a lot for this PR @silkypriya . This Pr is requested some changes by reviewers, but seems inactive for long time.Can you inform us will you be able to do them? |
Closing stale PR for now, reopen if more work happening on it. |
Description
Not showing media that have been nominated for deletion in Explore's Uploaded via mobile tab.
Fixes #2658 In "Uploaded via mobile", hide media nominated for deletion
What changes did you make and why?
Getting wikitext of media using API:Parse and filtering that have been nominated for deletion.
Tests performed
Tested betaDebug on Realme 2 pro (Android Version 8.1.0) with API level 27.