Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/src/main/java/fr/free/nrw/commons/Media.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public Media[] newArray(int i) {
protected String imageUrl;
protected String filename;
protected String description; // monolingual description on input...
protected String discussion;
protected long dataLength;
private String discussion;
private long dataLength;
protected Date dateCreated;
protected @Nullable Date dateUploaded;
protected int width;
protected int height;
protected String license;
protected String licenseUrl;
private String licenseUrl;
protected String creator;
protected ArrayList<String> categories; // as loaded at runtime?
protected boolean requestedDeletion;
private boolean requestedDeletion;
private Map<String, String> descriptions; // multilingual descriptions as loaded
private HashMap<String, Object> tags = new HashMap<>();
private @Nullable LatLng coordinates;
Expand Down Expand Up @@ -261,7 +261,7 @@ public void setFilename(String filename) {
* Sets the discussion of the file.
* @param discussion
*/
public void setDiscussion(String discussion) {
void setDiscussion(String discussion) {
this.discussion = discussion;
}

Expand Down Expand Up @@ -387,7 +387,7 @@ public String getLicense() {
return license;
}

public void setThumbUrl(String thumbUrl) {
private void setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
}

Expand All @@ -399,7 +399,7 @@ public String getLicenseUrl() {
* Sets the license name of the file.
* @param license license name as a String
*/
public void setLicenseInformation(String license, String licenseUrl) {
private void setLicenseInformation(String license, String licenseUrl) {
this.license = license;

if (!licenseUrl.startsWith("http://") && !licenseUrl.startsWith("https://")) {
Expand Down Expand Up @@ -450,7 +450,7 @@ public void setCategories(List<String> categories) {
* Modifies (or sets) media descriptions
* @param descriptions Media descriptions
*/
void setDescriptions(Map<String, String> descriptions) {
private void setDescriptions(Map<String, String> descriptions) {
this.descriptions.clear();
this.descriptions.putAll(descriptions);
}
Expand Down Expand Up @@ -521,7 +521,7 @@ public void writeToParcel(Parcel parcel, int flags) {
/**
* Set requested deletion to true
*/
public void setRequestedDeletion(){
void setRequestedDeletion(){
requestedDeletion = true;
}

Expand Down
28 changes: 7 additions & 21 deletions app/src/main/java/fr/free/nrw/commons/category/CategoryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
@Singleton
public class CategoryClient {

private final CategoryInterface CategoryInterface;
private final CategoryInterface categoryInterface;

@Inject
public CategoryClient(CategoryInterface CategoryInterface) {
this.CategoryInterface = CategoryInterface;
public CategoryClient(CategoryInterface categoryInterface) {
this.categoryInterface = categoryInterface;
}

/**
Expand All @@ -37,7 +37,7 @@ public CategoryClient(CategoryInterface CategoryInterface) {
* @return
*/
public Observable<String> searchCategories(String filter, int itemLimit, int offset) {
return responseToCategoryName(CategoryInterface.searchCategories(filter, itemLimit, offset));
return responseToCategoryName(categoryInterface.searchCategories(filter, itemLimit, offset));

}

Expand All @@ -53,18 +53,6 @@ public Observable<String> searchCategories(String filter, int itemLimit) {

}

/**
* Searches for categories starting with the specified string.
*
* @param prefix The prefix to be searched
* @param itemLimit How many results are returned
* @param offset Starts returning items from the nth result. If offset is 9, the response starts with the 9th item of the search result
* @return
*/
public Observable<String> searchCategoriesForPrefix(String prefix, int itemLimit, int offset) {
return responseToCategoryName(CategoryInterface.searchCategoriesForPrefix(prefix, itemLimit, offset));
}

/**
* Searches for categories starting with the specified string.
*
Expand All @@ -73,10 +61,9 @@ public Observable<String> searchCategoriesForPrefix(String prefix, int itemLimit
* @return
*/
public Observable<String> searchCategoriesForPrefix(String prefix, int itemLimit) {
return searchCategoriesForPrefix(prefix, itemLimit, 0);
return responseToCategoryName(categoryInterface.searchCategoriesForPrefix(prefix, itemLimit));
}


/**
* The method takes categoryName as input and returns a List of Subcategories
* It uses the generator query API to get the subcategories in a category, 500 at a time.
Expand All @@ -85,7 +72,7 @@ public Observable<String> searchCategoriesForPrefix(String prefix, int itemLimit
* @return Observable emitting the categories returned. If our search yielded "Category:Test", "Test" is emitted.
*/
public Observable<String> getSubCategoryList(String categoryName) {
return responseToCategoryName(CategoryInterface.getSubCategoryList(categoryName));
return responseToCategoryName(categoryInterface.getSubCategoryList(categoryName));
}

/**
Expand All @@ -97,7 +84,7 @@ public Observable<String> getSubCategoryList(String categoryName) {
*/
@NonNull
public Observable<String> getParentCategoryList(String categoryName) {
return responseToCategoryName(CategoryInterface.getParentCategoryList(categoryName));
return responseToCategoryName(categoryInterface.getParentCategoryList(categoryName));
}

/**
Expand All @@ -119,7 +106,6 @@ private Observable<String> responseToCategoryName(Observable<MwQueryResponse> re
return Observable.fromIterable(pages);
})
.map(MwQueryPage::title)
.doOnEach(s -> Timber.d("Category returned: %s", s))
.map(cat -> cat.replace("Category:", ""));
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package fr.free.nrw.commons.category;

import android.content.Context;
import android.content.Intent;
import android.database.DataSetObserver;
import android.os.Bundle;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;

import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import butterknife.ButterKnife;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R;
Expand Down Expand Up @@ -127,20 +125,6 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
forceInitBackButton();
}

/**
* Consumers should be simply using this method to use this activity.
* @param context A Context of the application package implementing this class.
* @param title Page title
* @param categoryName Name of the category for displaying its images
*/
public static void startYourself(Context context, String title, String categoryName) {
Intent intent = new Intent(context, CategoryImagesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("title", title);
intent.putExtra("categoryName", categoryName);
context.startActivity(intent);
}

/**
* This method is called mediaDetailPagerFragment. It returns the Media Object at that Index
* @param i It is the index of which media object is to be returned which is same as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import java.util.List;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;
import javax.inject.Named;

import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import dagger.android.support.DaggerFragment;
Expand Down Expand Up @@ -90,6 +91,9 @@ private void initViews() {
String categoryName = getArguments().getString("categoryName");
if (getArguments() != null && categoryName != null) {
this.categoryName = categoryName;
if (!this.categoryName.startsWith("Category:")) {
this.categoryName = "Category:" + categoryName;
}
resetQueryContinueValues(categoryName);
initList();
setScrollListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Observable<MwQueryResponse> searchCategories(@Query("gsrsearch") String filter,
@GET("w/api.php?action=query&format=json&formatversion=2"
+ "&generator=allcategories")
Observable<MwQueryResponse> searchCategoriesForPrefix(@Query("gacprefix") String prefix,
@Query("gaclimit") int itemLimit, @Query("gacoffset") int offset);
@Query("gaclimit") int itemLimit);

@GET("w/api.php?action=query&format=json&formatversion=2"
+ "&generator=categorymembers&gcmtype=subcat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package fr.free.nrw.commons.contributions;

import static fr.free.nrw.commons.contributions.Contribution.STATE_FAILED;
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;

import android.Manifest;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentManager.OnBackStackChangedListener;
import androidx.fragment.app.FragmentTransaction;

import javax.inject.Inject;
import javax.inject.Named;

import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.HandlerService;
Expand Down Expand Up @@ -57,11 +57,12 @@
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import java.util.ArrayList;
import javax.inject.Inject;
import javax.inject.Named;
import timber.log.Timber;

import static fr.free.nrw.commons.contributions.Contribution.STATE_FAILED;
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;

public class ContributionsFragment
extends CommonsDaggerSupportFragment
implements
Expand All @@ -78,15 +79,14 @@ public class ContributionsFragment
@Inject CampaignsPresenter presenter;
@Inject LocationServiceManager locationManager;

private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<>();
private UploadService uploadService;
private boolean isUploadServiceConnected;
private CompositeDisposable compositeDisposable = new CompositeDisposable();

private ContributionsListFragment contributionsListFragment;
private MediaDetailPagerFragment mediaDetailPagerFragment;
public static final String CONTRIBUTION_LIST_FRAGMENT_TAG = "ContributionListFragmentTag";
public static final String MEDIA_DETAIL_PAGER_FRAGMENT_TAG = "MediaDetailFragmentTag";
private static final String CONTRIBUTION_LIST_FRAGMENT_TAG = "ContributionListFragmentTag";
static final String MEDIA_DETAIL_PAGER_FRAGMENT_TAG = "MediaDetailFragmentTag";

@BindView(R.id.card_view_nearby) public NearbyNotificationCardView nearbyNotificationCardView;
@BindView(R.id.campaigns_view) CampaignView campaignView;
Expand Down Expand Up @@ -268,7 +268,7 @@ public void onAttach(Context context) {
* Replace FrameLayout with ContributionsListFragment, user will see contributions list. Creates
* new one if null.
*/
public void showContributionsListFragment() {
private void showContributionsListFragment() {
// show tabs on contribution list is visible
((MainActivity) getActivity()).showTabs();
// show nearby card view on contributions list is visible
Expand All @@ -289,7 +289,7 @@ public void showContributionsListFragment() {
* Replace FrameLayout with MediaDetailPagerFragment, user will see details of selected media.
* Creates new one if null.
*/
public void showMediaDetailPagerFragment() {
private void showMediaDetailPagerFragment() {
// hide tabs on media detail view is visible
((MainActivity)getActivity()).hideTabs();
// hide nearby card view on media detail is visible
Expand All @@ -308,7 +308,7 @@ public void onBackStackChanged() {
* Called when onAuthCookieAcquired is called on authenticated parent activity
* @param uploadServiceIntent
*/
public void onAuthCookieAcquired(Intent uploadServiceIntent) {
void onAuthCookieAcquired(Intent uploadServiceIntent) {
// Since we call onAuthCookieAcquired method from onAttach, isAdded is still false. So don't use it

if (getActivity() != null) { // If fragment is attached to parent activity
Expand All @@ -324,7 +324,7 @@ public void onAuthCookieAcquired(Intent uploadServiceIntent) {
* mediaDetailPagerFragment, and preserve previous state in back stack.
* Called when user selects a contribution.
*/
public void showDetail(int i) {
private void showDetail(int i) {
if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
mediaDetailPagerFragment = new MediaDetailPagerFragment();
showMediaDetailPagerFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public class SearchCategoryFragment extends CommonsDaggerSupportFragment {
ProgressBar progressBar;
@BindView(R.id.imagesNotFound)
TextView categoriesNotFoundView;
String query;
private String query;
@BindView(R.id.bottomProgressBar)
ProgressBar bottomProgressBar;
boolean isLoadingCategories;
private boolean isLoadingCategories;

@Inject RecentSearchesDao recentSearchesDao;
@Inject MediaWikiApi mwApi;
Expand Down Expand Up @@ -152,7 +152,7 @@ public void updateCategoryList(String query) {
/**
* Adds 25 more results to existing search results
*/
public void addCategoriesToList(String query) {
private void addCategoriesToList(String query) {
if(isLoadingCategories) return;
isLoadingCategories=true;
this.query = query;
Expand Down
Loading