mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* Edited Project.xml to make indent size 4 * Changed files with 2 space indentation to use 4 space indentation * Edited Project.xml to make indent size 4 * changed files with 2 space indent to 4 space indent * fix :Back Pressed Event not work in Explore tab when user not login (#4404) * fix :Back Pressed Event not work in Explore tab * minor changes * fix :Upload count or number of contribution does not get updated when media is successful uploaded (#4399) * * fix:Number of Contributions not updated * Add javadocs * minor changes * made minor changes * String was nonsense and untranslatible, fixed (#4466) * Ability to show captions and descriptions in all entered languages (#4355) * implement Ability to show captions and descriptions in all entered languages *Add Javadoc * handle Back event of fragment(mediaDetailFragment) * fix minor bugs * add internationalization * revert previous changes * fix visibility bug * resolve conflict Co-authored-by: Prince kushwaha <65972015+Prince-kushwaha@users.noreply.github.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com>
This commit is contained in:
parent
b202f553f0
commit
ca9f6f5e47
36 changed files with 3047 additions and 2988 deletions
1
.idea/codeStyles/Project.xml
generated
1
.idea/codeStyles/Project.xml
generated
|
|
@ -111,7 +111,6 @@
|
||||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="FOR_BRACE_FORCE" value="3" />
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
<indentOptions>
|
<indentOptions>
|
||||||
<option name="INDENT_SIZE" value="2" />
|
|
||||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
<option name="TAB_SIZE" value="2" />
|
<option name="TAB_SIZE" value="2" />
|
||||||
</indentOptions>
|
</indentOptions>
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,8 @@ import timber.log.Timber;
|
||||||
buildConfigClass = BuildConfig.class,
|
buildConfigClass = BuildConfig.class,
|
||||||
resReportSendSuccessToast = R.string.crash_dialog_ok_toast,
|
resReportSendSuccessToast = R.string.crash_dialog_ok_toast,
|
||||||
reportFormat = StringFormat.KEY_VALUE_LIST,
|
reportFormat = StringFormat.KEY_VALUE_LIST,
|
||||||
reportContent = {USER_COMMENT, APP_VERSION_CODE, APP_VERSION_NAME, ANDROID_VERSION, PHONE_MODEL, STACK_TRACE}
|
reportContent = {USER_COMMENT, APP_VERSION_CODE, APP_VERSION_NAME, ANDROID_VERSION, PHONE_MODEL,
|
||||||
|
STACK_TRACE}
|
||||||
)
|
)
|
||||||
|
|
||||||
@AcraMailSender(
|
@AcraMailSender(
|
||||||
|
|
@ -118,16 +119,19 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
private RefWatcher refWatcher;
|
private RefWatcher refWatcher;
|
||||||
|
|
||||||
private static CommonsApplication INSTANCE;
|
private static CommonsApplication INSTANCE;
|
||||||
|
|
||||||
public static CommonsApplication getInstance() {
|
public static CommonsApplication getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AppLanguageLookUpTable languageLookUpTable;
|
private AppLanguageLookUpTable languageLookUpTable;
|
||||||
|
|
||||||
public AppLanguageLookUpTable getLanguageLookUpTable() {
|
public AppLanguageLookUpTable getLanguageLookUpTable() {
|
||||||
return languageLookUpTable;
|
return languageLookUpTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject ContributionDao contributionDao;
|
@Inject
|
||||||
|
ContributionDao contributionDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In memory list of contributios whose uploads ahve been paused by the user
|
* In memory list of contributios whose uploads ahve been paused by the user
|
||||||
|
|
@ -154,7 +158,6 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
|
|
||||||
initTimber();
|
initTimber();
|
||||||
|
|
||||||
|
|
||||||
if (!defaultPrefs.getBoolean("has_user_manually_removed_location")) {
|
if (!defaultPrefs.getBoolean("has_user_manually_removed_location")) {
|
||||||
Set<String> defaultExifTagsSet = defaultPrefs.getStringSet(Prefs.MANAGED_EXIF_TAGS);
|
Set<String> defaultExifTagsSet = defaultPrefs.getStringSet(Prefs.MANAGED_EXIF_TAGS);
|
||||||
if (null == defaultExifTagsSet) {
|
if (null == defaultExifTagsSet) {
|
||||||
|
|
@ -192,9 +195,7 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plants debug and file logging tree.
|
* Plants debug and file logging tree. Timber lets you plant your own logging trees.
|
||||||
* Timber lets you plant your own logging trees.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private void initTimber() {
|
private void initTimber() {
|
||||||
boolean isBeta = ConfigUtils.isBetaFlavour();
|
boolean isBeta = ConfigUtils.isBetaFlavour();
|
||||||
|
|
@ -247,22 +248,27 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
|
|
||||||
public static void createNotificationChannel(@NonNull Context context) {
|
public static void createNotificationChannel(@NonNull Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager manager = (NotificationManager) context
|
||||||
NotificationChannel channel = manager.getNotificationChannel(NOTIFICATION_CHANNEL_ID_ALL);
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
NotificationChannel channel = manager
|
||||||
|
.getNotificationChannel(NOTIFICATION_CHANNEL_ID_ALL);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID_ALL,
|
channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID_ALL,
|
||||||
context.getString(R.string.notifications_channel_name_all), NotificationManager.IMPORTANCE_DEFAULT);
|
context.getString(R.string.notifications_channel_name_all),
|
||||||
|
NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
manager.createNotificationChannel(channel);
|
manager.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserAgent() {
|
public String getUserAgent() {
|
||||||
return "Commons/" + ConfigUtils.getVersionNameWithSha(this) + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE;
|
return "Commons/" + ConfigUtils.getVersionNameWithSha(this)
|
||||||
|
+ " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps in setting up LeakCanary library
|
* Helps in setting up LeakCanary library
|
||||||
|
*
|
||||||
* @return instance of LeakCanary
|
* @return instance of LeakCanary
|
||||||
*/
|
*/
|
||||||
protected RefWatcher setupLeakCanary() {
|
protected RefWatcher setupLeakCanary() {
|
||||||
|
|
@ -285,6 +291,7 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clears data of current application
|
* clears data of current application
|
||||||
|
*
|
||||||
* @param context Application context
|
* @param context Application context
|
||||||
* @param logoutListener Implementation of interface LogoutListener
|
* @param logoutListener Implementation of interface LogoutListener
|
||||||
*/
|
*/
|
||||||
|
|
@ -302,7 +309,7 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionManager.logout()
|
sessionManager.logout()
|
||||||
.andThen(Completable.fromAction(() ->{
|
.andThen(Completable.fromAction(() -> {
|
||||||
Timber.d("All accounts have been removed");
|
Timber.d("All accounts have been removed");
|
||||||
clearImageCache();
|
clearImageCache();
|
||||||
//TODO: fix preference manager
|
//TODO: fix preference manager
|
||||||
|
|
@ -332,7 +339,8 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
||||||
|
|
||||||
CategoryDao.Table.onDelete(db);
|
CategoryDao.Table.onDelete(db);
|
||||||
dbOpenHelper.deleteTable(db,CONTRIBUTIONS_TABLE);//Delete the contributions table in the existing db on older versions
|
dbOpenHelper.deleteTable(db,
|
||||||
|
CONTRIBUTIONS_TABLE);//Delete the contributions table in the existing db on older versions
|
||||||
|
|
||||||
try {
|
try {
|
||||||
contributionDao.deleteAll();
|
contributionDao.deleteAll();
|
||||||
|
|
@ -348,6 +356,7 @@ public class CommonsApplication extends MultiDexApplication {
|
||||||
* Interface used to get log-out events
|
* Interface used to get log-out events
|
||||||
*/
|
*/
|
||||||
public interface LogoutListener {
|
public interface LogoutListener {
|
||||||
|
|
||||||
void onLogoutComplete();
|
void onLogoutComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ public final class LocationPicker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getting camera position from the intent using constants
|
* Getting camera position from the intent using constants
|
||||||
|
*
|
||||||
* @param data intent
|
* @param data intent
|
||||||
* @return CameraPosition
|
* @return CameraPosition
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,6 +33,7 @@ public final class LocationPicker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets and puts location in intent
|
* Gets and puts location in intent
|
||||||
|
*
|
||||||
* @param position CameraPosition
|
* @param position CameraPosition
|
||||||
* @return LocationPicker.IntentBuilder
|
* @return LocationPicker.IntentBuilder
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,6 +45,7 @@ public final class LocationPicker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets and sets the activity
|
* Gets and sets the activity
|
||||||
|
*
|
||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
* @return Intent
|
* @return Intent
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,8 @@ public class LocationPickerActivity extends AppCompatActivity implements OnMapRe
|
||||||
setContentView(R.layout.activity_location_picker);
|
setContentView(R.layout.activity_location_picker);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
cameraPosition = getIntent().getParcelableExtra(LocationPickerConstants.MAP_CAMERA_POSITION);
|
cameraPosition = getIntent()
|
||||||
|
.getParcelableExtra(LocationPickerConstants.MAP_CAMERA_POSITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
final LocationPickerViewModel viewModel = new ViewModelProvider(this)
|
final LocationPickerViewModel viewModel = new ViewModelProvider(this)
|
||||||
|
|
@ -137,6 +138,7 @@ public class LocationPickerActivity extends AppCompatActivity implements OnMapRe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes action when map is ready to show
|
* Takes action when map is ready to show
|
||||||
|
*
|
||||||
* @param mapboxMap map
|
* @param mapboxMap map
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -158,9 +160,10 @@ public class LocationPickerActivity extends AppCompatActivity implements OnMapRe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables location components
|
* Enables location components
|
||||||
|
*
|
||||||
* @param loadedMapStyle Style
|
* @param loadedMapStyle Style
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings( {"MissingPermission"})
|
@SuppressWarnings({"MissingPermission"})
|
||||||
private void enableLocationComponent(@NonNull final Style loadedMapStyle) {
|
private void enableLocationComponent(@NonNull final Style loadedMapStyle) {
|
||||||
final UiSettings uiSettings = mapboxMap.getUiSettings();
|
final UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||||
uiSettings.setAttributionEnabled(false);
|
uiSettings.setAttributionEnabled(false);
|
||||||
|
|
@ -189,6 +192,7 @@ public class LocationPickerActivity extends AppCompatActivity implements OnMapRe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acts on camera moving
|
* Acts on camera moving
|
||||||
|
*
|
||||||
* @param reason int
|
* @param reason int
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -212,6 +216,7 @@ public class LocationPickerActivity extends AppCompatActivity implements OnMapRe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes action on camera position
|
* Takes action on camera position
|
||||||
|
*
|
||||||
* @param position position of picker
|
* @param position position of picker
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public class LocationPickerViewModel extends AndroidViewModel implements Callbac
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for this class
|
* Constructor for this class
|
||||||
|
*
|
||||||
* @param application Application
|
* @param application Application
|
||||||
*/
|
*/
|
||||||
public LocationPickerViewModel(@NonNull final Application application) {
|
public LocationPickerViewModel(@NonNull final Application application) {
|
||||||
|
|
@ -31,13 +32,14 @@ public class LocationPickerViewModel extends AndroidViewModel implements Callbac
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responses on camera position changing
|
* Responses on camera position changing
|
||||||
|
*
|
||||||
* @param call Call<CameraPosition>
|
* @param call Call<CameraPosition>
|
||||||
* @param response Response<CameraPosition>
|
* @param response Response<CameraPosition>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(final @NotNull Call<CameraPosition> call,
|
public void onResponse(final @NotNull Call<CameraPosition> call,
|
||||||
final Response<CameraPosition> response) {
|
final Response<CameraPosition> response) {
|
||||||
if(response.body()==null){
|
if (response.body() == null) {
|
||||||
result.setValue(null);
|
result.setValue(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +53,7 @@ public class LocationPickerViewModel extends AndroidViewModel implements Callbac
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets live CameraPosition
|
* Gets live CameraPosition
|
||||||
|
*
|
||||||
* @return MutableLiveData<CameraPosition>
|
* @return MutableLiveData<CameraPosition>
|
||||||
*/
|
*/
|
||||||
public MutableLiveData<CameraPosition> getResult() {
|
public MutableLiveData<CameraPosition> getResult() {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScroll(boolean canScroll){
|
public void setScroll(boolean canScroll) {
|
||||||
viewPager.setCanScroll(canScroll);
|
viewPager.setCanScroll(canScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
((MainActivity)getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
|
||||||
setupTabLayout();
|
setupTabLayout();
|
||||||
|
|
@ -88,10 +88,10 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method sets up the tab layout.
|
* This method sets up the tab layout. If the adapter has only one element it sets the
|
||||||
* If the adapter has only one element it sets the visibility of tabLayout to gone.
|
* visibility of tabLayout to gone.
|
||||||
*/
|
*/
|
||||||
public void setupTabLayout(){
|
public void setupTabLayout() {
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
if (adapter.getCount() == 1) {
|
if (adapter.getCount() == 1) {
|
||||||
tabLayout.setVisibility(View.GONE);
|
tabLayout.setVisibility(View.GONE);
|
||||||
|
|
@ -100,11 +100,12 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
|
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if(((BookmarkListRootFragment)(adapter.getItem(tabLayout.getSelectedTabPosition()))).backPressed()) {
|
if (((BookmarkListRootFragment) (adapter.getItem(tabLayout.getSelectedTabPosition())))
|
||||||
|
.backPressed()) {
|
||||||
// The event is handled internally by the adapter , no further action required.
|
// The event is handled internally by the adapter , no further action required.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Event is not handled by the adapter ( performed back action ) change action bar.
|
// Event is not handled by the adapter ( performed back action ) change action bar.
|
||||||
((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.Iterator;
|
||||||
public class BookmarkListRootFragment extends CommonsDaggerSupportFragment implements
|
public class BookmarkListRootFragment extends CommonsDaggerSupportFragment implements
|
||||||
FragmentManager.OnBackStackChangedListener,
|
FragmentManager.OnBackStackChangedListener,
|
||||||
MediaDetailPagerFragment.MediaDetailProvider,
|
MediaDetailPagerFragment.MediaDetailProvider,
|
||||||
AdapterView.OnItemClickListener, CategoryImagesCallback{
|
AdapterView.OnItemClickListener, CategoryImagesCallback {
|
||||||
|
|
||||||
private MediaDetailPagerFragment mediaDetails;
|
private MediaDetailPagerFragment mediaDetails;
|
||||||
//private BookmarkPicturesFragment bookmarkPicturesFragment;
|
//private BookmarkPicturesFragment bookmarkPicturesFragment;
|
||||||
|
|
@ -41,7 +41,7 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
@BindView(R.id.explore_container)
|
@BindView(R.id.explore_container)
|
||||||
FrameLayout container;
|
FrameLayout container;
|
||||||
|
|
||||||
public BookmarkListRootFragment(){
|
public BookmarkListRootFragment() {
|
||||||
//empty constructor necessary otherwise crashes on recreate
|
//empty constructor necessary otherwise crashes on recreate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,8 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container,
|
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||||
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
||||||
|
|
@ -72,7 +73,7 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
if(savedInstanceState==null) {
|
if (savedInstanceState == null) {
|
||||||
setFragment(listFragment, mediaDetails);
|
setFragment(listFragment, mediaDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,18 +83,18 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
getChildFragmentManager()
|
getChildFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.hide(otherFragment)
|
.hide(otherFragment)
|
||||||
.show( fragment)
|
.show(fragment)
|
||||||
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
||||||
.commit();
|
.commit();
|
||||||
getChildFragmentManager().executePendingTransactions();
|
getChildFragmentManager().executePendingTransactions();
|
||||||
} else if (fragment.isAdded() && otherFragment == null) {
|
} else if (fragment.isAdded() && otherFragment == null) {
|
||||||
getChildFragmentManager()
|
getChildFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.show( fragment)
|
.show(fragment)
|
||||||
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
||||||
.commit();
|
.commit();
|
||||||
getChildFragmentManager().executePendingTransactions();
|
getChildFragmentManager().executePendingTransactions();
|
||||||
}else if (!fragment.isAdded() && otherFragment != null ) {
|
} else if (!fragment.isAdded() && otherFragment != null) {
|
||||||
getChildFragmentManager()
|
getChildFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.hide(otherFragment)
|
.hide(otherFragment)
|
||||||
|
|
@ -126,7 +127,7 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int position) {
|
public void onMediaClicked(int position) {
|
||||||
Log.d("deneme8","on media clicked");
|
Log.d("deneme8", "on media clicked");
|
||||||
/*container.setVisibility(View.VISIBLE);
|
/*container.setVisibility(View.VISIBLE);
|
||||||
((BookmarkFragment)getParentFragment()).tabLayout.setVisibility(View.GONE);
|
((BookmarkFragment)getParentFragment()).tabLayout.setVisibility(View.GONE);
|
||||||
mediaDetails = new MediaDetailPagerFragment(false, true, position);
|
mediaDetails = new MediaDetailPagerFragment(false, true, position);
|
||||||
|
|
@ -176,7 +177,7 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void refreshNominatedMedia(int index) {
|
public void refreshNominatedMedia(int index) {
|
||||||
if(mediaDetails != null && !listFragment.isVisible()) {
|
if (mediaDetails != null && !listFragment.isVisible()) {
|
||||||
removeFragment(mediaDetails);
|
removeFragment(mediaDetails);
|
||||||
mediaDetails = new MediaDetailPagerFragment(false, true);
|
mediaDetails = new MediaDetailPagerFragment(false, true);
|
||||||
((BookmarkFragment) getParentFragment()).setScroll(false);
|
((BookmarkFragment) getParentFragment()).setScroll(false);
|
||||||
|
|
@ -198,24 +199,25 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
|
|
||||||
public boolean backPressed() {
|
public boolean backPressed() {
|
||||||
//check mediaDetailPage fragment is not null then we check mediaDetail.is Visible or not to avoid NullPointerException
|
//check mediaDetailPage fragment is not null then we check mediaDetail.is Visible or not to avoid NullPointerException
|
||||||
if(mediaDetails!=null) {
|
if (mediaDetails != null) {
|
||||||
if (mediaDetails.isVisible()) {
|
if (mediaDetails.isVisible()) {
|
||||||
if(mediaDetails.backButtonClicked()) {
|
if (mediaDetails.backButtonClicked()) {
|
||||||
// mediaDetails handled the back clicked , no further action required.
|
// mediaDetails handled the back clicked , no further action required.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// todo add get list fragment
|
// todo add get list fragment
|
||||||
((BookmarkFragment) getParentFragment()).setupTabLayout();
|
((BookmarkFragment) getParentFragment()).setupTabLayout();
|
||||||
ArrayList<Integer> removed=mediaDetails.getRemovedItems();
|
ArrayList<Integer> removed = mediaDetails.getRemovedItems();
|
||||||
removeFragment(mediaDetails);
|
removeFragment(mediaDetails);
|
||||||
((BookmarkFragment) getParentFragment()).setScroll(true);
|
((BookmarkFragment) getParentFragment()).setScroll(true);
|
||||||
setFragment(listFragment, mediaDetails);
|
setFragment(listFragment, mediaDetails);
|
||||||
((MainActivity) getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
if(listFragment instanceof BookmarkPicturesFragment){
|
if (listFragment instanceof BookmarkPicturesFragment) {
|
||||||
GridViewAdapter adapter=((GridViewAdapter)((BookmarkPicturesFragment)listFragment).getAdapter());
|
GridViewAdapter adapter = ((GridViewAdapter) ((BookmarkPicturesFragment) listFragment)
|
||||||
|
.getAdapter());
|
||||||
Iterator i = removed.iterator();
|
Iterator i = removed.iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
adapter.remove(adapter.getItem((int)i.next()));
|
adapter.remove(adapter.getItem((int) i.next()));
|
||||||
}
|
}
|
||||||
mediaDetails.clearRemoved();
|
mediaDetails.clearRemoved();
|
||||||
|
|
||||||
|
|
@ -230,15 +232,16 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveToContributionsFragment(){
|
void moveToContributionsFragment() {
|
||||||
((MainActivity) getActivity()).setSelectedItemId(NavTab.CONTRIBUTIONS.code());
|
((MainActivity) getActivity()).setSelectedItemId(NavTab.CONTRIBUTIONS.code());
|
||||||
((MainActivity) getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Log.d("deneme8","on media clicked");
|
Log.d("deneme8", "on media clicked");
|
||||||
container.setVisibility(View.VISIBLE);
|
container.setVisibility(View.VISIBLE);
|
||||||
((BookmarkFragment)getParentFragment()).tabLayout.setVisibility(View.GONE);
|
((BookmarkFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
|
||||||
mediaDetails = new MediaDetailPagerFragment(false, true);
|
mediaDetails = new MediaDetailPagerFragment(false, true);
|
||||||
((BookmarkFragment) getParentFragment()).setScroll(false);
|
((BookmarkFragment) getParentFragment()).setScroll(false);
|
||||||
setFragment(mediaDetails, listFragment);
|
setFragment(mediaDetails, listFragment);
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
public void init(final int position, final Contribution contribution) {
|
public void init(final int position, final Contribution contribution) {
|
||||||
|
|
||||||
//handling crashes when the contribution is null.
|
//handling crashes when the contribution is null.
|
||||||
if( null == contribution) {
|
if (null == contribution) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,6 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
imageView.getHierarchy().setPlaceholderImage(R.drawable.image_placeholder);
|
imageView.getHierarchy().setPlaceholderImage(R.drawable.image_placeholder);
|
||||||
imageView.getHierarchy().setFailureImage(R.drawable.image_placeholder);
|
imageView.getHierarchy().setFailureImage(R.drawable.image_placeholder);
|
||||||
|
|
||||||
|
|
||||||
final String imageSource = chooseImageSource(contribution.getMedia().getThumbUrl(),
|
final String imageSource = chooseImageSource(contribution.getMedia().getThumbUrl(),
|
||||||
contribution.getLocalUri());
|
contribution.getLocalUri());
|
||||||
if (!TextUtils.isEmpty(imageSource)) {
|
if (!TextUtils.isEmpty(imageSource)) {
|
||||||
|
|
@ -150,8 +149,8 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a media exists on the corresponding Wikipedia article Currently the check is made for
|
* Checks if a media exists on the corresponding Wikipedia article Currently the check is made
|
||||||
* the device's current language Wikipedia
|
* for the device's current language Wikipedia
|
||||||
*
|
*
|
||||||
* @param contribution
|
* @param contribution
|
||||||
*/
|
*/
|
||||||
|
|
@ -170,9 +169,9 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle action buttons visibility if the corresponding wikipedia page doesn't contain any media.
|
* Handle action buttons visibility if the corresponding wikipedia page doesn't contain any
|
||||||
* This method needs to control the state of just the scenario where media does not exists as
|
* media. This method needs to control the state of just the scenario where media does not
|
||||||
* other scenarios are already handled in the init method.
|
* exists as other scenarios are already handled in the init method.
|
||||||
*
|
*
|
||||||
* @param mediaExists
|
* @param mediaExists
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,9 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
||||||
public void onItemRangeInserted(int positionStart, int itemCount) {
|
public void onItemRangeInserted(int positionStart, int itemCount) {
|
||||||
super.onItemRangeInserted(positionStart, itemCount);
|
super.onItemRangeInserted(positionStart, itemCount);
|
||||||
if (itemCount > 0 && positionStart == 0) {
|
if (itemCount > 0 && positionStart == 0) {
|
||||||
if(adapter.getContributionForPosition(positionStart)!=null) {
|
if (adapter.getContributionForPosition(positionStart) != null) {
|
||||||
rvContributionsList.scrollToPosition(0);//Newly upload items are always added to the top
|
rvContributionsList
|
||||||
|
.scrollToPosition(0);//Newly upload items are always added to the top
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +233,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
||||||
fab_layout.setOrientation(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE ?
|
fab_layout.setOrientation(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE ?
|
||||||
LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
|
LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
|
||||||
rvContributionsList
|
rvContributionsList
|
||||||
.setLayoutManager(new GridLayoutManager(getContext(), getSpanCount(newConfig.orientation)));
|
.setLayoutManager(
|
||||||
|
new GridLayoutManager(getContext(), getSpanCount(newConfig.orientation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeAnimations() {
|
private void initializeAnimations() {
|
||||||
|
|
@ -353,6 +355,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pauses the current upload
|
* Pauses the current upload
|
||||||
|
*
|
||||||
* @param contribution
|
* @param contribution
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -363,6 +366,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resumes the current upload
|
* Resumes the current upload
|
||||||
|
*
|
||||||
* @param contribution
|
* @param contribution
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -386,7 +390,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
||||||
|
|
||||||
|
|
||||||
public Media getMediaAtPosition(final int i) {
|
public Media getMediaAtPosition(final int i) {
|
||||||
if(adapter.getContributionForPosition(i) != null) {
|
if (adapter.getContributionForPosition(i) != null) {
|
||||||
return adapter.getContributionForPosition(i).getMedia();
|
return adapter.getContributionForPosition(i).getMedia();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ public class ContributionsListPresenter implements UserActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the paged list. This method sets the configuration for paged list and ties it up with the
|
* Setup the paged list. This method sets the configuration for paged list and ties it up with
|
||||||
* live data object. This method can be tweaked to update the lazy loading behavior of the
|
* the live data object. This method can be tweaked to update the lazy loading behavior of the
|
||||||
* contributions list
|
* contributions list
|
||||||
*/
|
*/
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
@ -48,7 +48,8 @@ public class ContributionsListPresenter implements UserActionListener {
|
||||||
(new PagedList.Config.Builder())
|
(new PagedList.Config.Builder())
|
||||||
.setPrefetchDistance(50)
|
.setPrefetchDistance(50)
|
||||||
.setPageSize(10).build();
|
.setPageSize(10).build();
|
||||||
contributionList = (new LivePagedListBuilder(repository.fetchContributions(), pagedListConfig)
|
contributionList = (new LivePagedListBuilder(repository.fetchContributions(),
|
||||||
|
pagedListConfig)
|
||||||
.setBoundaryCallback(contributionBoundaryCallback)).build();
|
.setBoundaryCallback(contributionBoundaryCallback)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ import fr.free.nrw.commons.upload.depicts.DepictsDao
|
||||||
* The database for accessing the respective DAOs
|
* The database for accessing the respective DAOs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Database(entities = [Contribution::class,Depicts::class], version = 8, exportSchema = false)
|
@Database(entities = [Contribution::class, Depicts::class], version = 8, exportSchema = false)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
abstract fun contributionDao(): ContributionDao
|
abstract fun contributionDao(): ContributionDao
|
||||||
abstract fun DepictsDao (): DepictsDao;
|
abstract fun DepictsDao(): DepictsDao;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
@BindView(R.id.explore_container)
|
@BindView(R.id.explore_container)
|
||||||
FrameLayout container;
|
FrameLayout container;
|
||||||
|
|
||||||
public ExploreListRootFragment(){
|
public ExploreListRootFragment() {
|
||||||
//empty constructor necessary otherwise crashes on recreate
|
//empty constructor necessary otherwise crashes on recreate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +43,8 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container,
|
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||||
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
||||||
|
|
@ -54,7 +55,7 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
if(savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
setFragment(listFragment, mediaDetails);
|
setFragment(listFragment, mediaDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,18 +65,18 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
getChildFragmentManager()
|
getChildFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.hide(otherFragment)
|
.hide(otherFragment)
|
||||||
.show( fragment)
|
.show(fragment)
|
||||||
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
||||||
.commit();
|
.commit();
|
||||||
getChildFragmentManager().executePendingTransactions();
|
getChildFragmentManager().executePendingTransactions();
|
||||||
} else if (fragment.isAdded() && otherFragment == null) {
|
} else if (fragment.isAdded() && otherFragment == null) {
|
||||||
getChildFragmentManager()
|
getChildFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.show( fragment)
|
.show(fragment)
|
||||||
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
.addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
||||||
.commit();
|
.commit();
|
||||||
getChildFragmentManager().executePendingTransactions();
|
getChildFragmentManager().executePendingTransactions();
|
||||||
} else if (!fragment.isAdded() && otherFragment != null ) {
|
} else if (!fragment.isAdded() && otherFragment != null) {
|
||||||
getChildFragmentManager()
|
getChildFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.hide(otherFragment)
|
.hide(otherFragment)
|
||||||
|
|
@ -109,7 +110,7 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int position) {
|
public void onMediaClicked(int position) {
|
||||||
container.setVisibility(View.VISIBLE);
|
container.setVisibility(View.VISIBLE);
|
||||||
((ExploreFragment)getParentFragment()).tabLayout.setVisibility(View.GONE);
|
((ExploreFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
|
||||||
mediaDetails = new MediaDetailPagerFragment(false, true);
|
mediaDetails = new MediaDetailPagerFragment(false, true);
|
||||||
setFragment(mediaDetails, listFragment);
|
setFragment(mediaDetails, listFragment);
|
||||||
mediaDetails.showImage(position);
|
mediaDetails.showImage(position);
|
||||||
|
|
@ -139,7 +140,7 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getTotalMediaCount() {
|
public int getTotalMediaCount() {
|
||||||
if (listFragment!=null) {
|
if (listFragment != null) {
|
||||||
return listFragment.getTotalMediaCount();
|
return listFragment.getTotalMediaCount();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -158,7 +159,7 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void refreshNominatedMedia(int index) {
|
public void refreshNominatedMedia(int index) {
|
||||||
if(mediaDetails != null && !listFragment.isVisible()) {
|
if (mediaDetails != null && !listFragment.isVisible()) {
|
||||||
removeFragment(mediaDetails);
|
removeFragment(mediaDetails);
|
||||||
onMediaClicked(index);
|
onMediaClicked(index);
|
||||||
}
|
}
|
||||||
|
|
@ -176,8 +177,9 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs back pressed action on the fragment.
|
* Performs back pressed action on the fragment. Return true if the event was handled by the
|
||||||
* Return true if the event was handled by the mediaDetails otherwise returns false.
|
* mediaDetails otherwise returns false.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean backPressed() {
|
public boolean backPressed() {
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ import android.view.MotionEvent;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ParentViewPager
|
* ParentViewPager A custom viewPager whose scrolling can be enabled and disabled.
|
||||||
* A custom viewPager whose scrolling can be enabled and disabled.
|
|
||||||
*/
|
*/
|
||||||
public class ParentViewPager extends ViewPager {
|
public class ParentViewPager extends ViewPager {
|
||||||
|
|
||||||
|
|
@ -55,8 +54,8 @@ public class ParentViewPager extends ViewPager {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A facilitator method that allows parent to intercept touch events before its children.
|
* A facilitator method that allows parent to intercept touch events before its children. thus
|
||||||
* thus making it possible to prevent swiping parent on child end.
|
* making it possible to prevent swiping parent on child end.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
|
@ -64,6 +63,4 @@ public class ParentViewPager extends ViewPager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,11 @@ import fr.free.nrw.commons.explore.SearchActivity;
|
||||||
* Displays the recent searches screen.
|
* Displays the recent searches screen.
|
||||||
*/
|
*/
|
||||||
public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
@Inject RecentSearchesDao recentSearchesDao;
|
|
||||||
@BindView(R.id.recent_searches_list) ListView recentSearchesList;
|
@Inject
|
||||||
|
RecentSearchesDao recentSearchesDao;
|
||||||
|
@BindView(R.id.recent_searches_list)
|
||||||
|
ListView recentSearchesList;
|
||||||
List<String> recentSearches;
|
List<String> recentSearches;
|
||||||
ArrayAdapter adapter;
|
ArrayAdapter adapter;
|
||||||
@BindView(R.id.recent_searches_delete_button)
|
@BindView(R.id.recent_searches_delete_button)
|
||||||
|
|
@ -43,7 +46,7 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
|
|
||||||
if(recentSearches.isEmpty()) {
|
if (recentSearches.isEmpty()) {
|
||||||
recent_searches_delete_button.setVisibility(View.GONE);
|
recent_searches_delete_button.setVisibility(View.GONE);
|
||||||
recent_searches_text_view.setText(R.string.no_recent_searches);
|
recent_searches_text_view.setText(R.string.no_recent_searches);
|
||||||
}
|
}
|
||||||
|
|
@ -55,9 +58,11 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
recentSearchesDao.deleteAll();
|
recentSearchesDao.deleteAll();
|
||||||
recent_searches_delete_button.setVisibility(View.GONE);
|
recent_searches_delete_button.setVisibility(View.GONE);
|
||||||
recent_searches_text_view.setText(R.string.no_recent_searches);
|
recent_searches_text_view.setText(R.string.no_recent_searches);
|
||||||
Toast.makeText(getContext(),getString(R.string.search_history_deleted),Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), getString(R.string.search_history_deleted),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
adapter = new ArrayAdapter<>(getContext(), R.layout.item_recent_searches, recentSearches);
|
adapter = new ArrayAdapter<>(getContext(), R.layout.item_recent_searches,
|
||||||
|
recentSearches);
|
||||||
recentSearchesList.setAdapter(adapter);
|
recentSearchesList.setAdapter(adapter);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
@ -67,22 +72,24 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter = new ArrayAdapter<>(requireContext(), R.layout.item_recent_searches, recentSearches);
|
adapter = new ArrayAdapter<>(requireContext(), R.layout.item_recent_searches,
|
||||||
|
recentSearches);
|
||||||
recentSearchesList.setAdapter(adapter);
|
recentSearchesList.setAdapter(adapter);
|
||||||
recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
|
recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
|
||||||
(SearchActivity)getContext()).updateText(recentSearches.get(position)));
|
(SearchActivity) getContext()).updateText(recentSearches.get(position)));
|
||||||
recentSearchesList.setOnItemLongClickListener((parent, view, position, id) -> {
|
recentSearchesList.setOnItemLongClickListener((parent, view, position, id) -> {
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setMessage(R.string.delete_search_dialog)
|
.setMessage(R.string.delete_search_dialog)
|
||||||
.setPositiveButton(getString(R.string.delete).toUpperCase(),((dialog, which) -> {
|
.setPositiveButton(getString(R.string.delete).toUpperCase(), ((dialog, which) -> {
|
||||||
recentSearchesDao.delete(recentSearchesDao.find(recentSearches.get(position)));
|
recentSearchesDao.delete(recentSearchesDao.find(recentSearches.get(position)));
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
adapter = new ArrayAdapter<>(getContext(), R.layout.item_recent_searches, recentSearches);
|
adapter = new ArrayAdapter<>(getContext(), R.layout.item_recent_searches,
|
||||||
|
recentSearches);
|
||||||
recentSearchesList.setAdapter(adapter);
|
recentSearchesList.setAdapter(adapter);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}))
|
}))
|
||||||
.setNegativeButton(android.R.string.cancel,null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -92,8 +99,8 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called on back press of activity
|
* This method is called on back press of activity so we are updating the list from database to
|
||||||
* so we are updating the list from database to refresh the recent searches list.
|
* refresh the recent searches list.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
|
@ -108,7 +115,7 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
if(!recentSearches.isEmpty()) {
|
if (!recentSearches.isEmpty()) {
|
||||||
recent_searches_delete_button.setVisibility(View.VISIBLE);
|
recent_searches_delete_button.setVisibility(View.VISIBLE);
|
||||||
recent_searches_text_view.setText(R.string.search_recent_header);
|
recent_searches_text_view.setText(R.string.search_recent_header);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,10 @@ public class CustomOkHttpNetworkFetcher
|
||||||
public Map<String, String> getExtraMap(OkHttpNetworkFetchState fetchState, int byteSize) {
|
public Map<String, String> getExtraMap(OkHttpNetworkFetchState fetchState, int byteSize) {
|
||||||
Map<String, String> extraMap = new HashMap<>(4);
|
Map<String, String> extraMap = new HashMap<>(4);
|
||||||
extraMap.put(QUEUE_TIME, Long.toString(fetchState.responseTime - fetchState.submitTime));
|
extraMap.put(QUEUE_TIME, Long.toString(fetchState.responseTime - fetchState.submitTime));
|
||||||
extraMap.put(FETCH_TIME, Long.toString(fetchState.fetchCompleteTime - fetchState.responseTime));
|
extraMap
|
||||||
extraMap.put(TOTAL_TIME, Long.toString(fetchState.fetchCompleteTime - fetchState.submitTime));
|
.put(FETCH_TIME, Long.toString(fetchState.fetchCompleteTime - fetchState.responseTime));
|
||||||
|
extraMap
|
||||||
|
.put(TOTAL_TIME, Long.toString(fetchState.fetchCompleteTime - fetchState.submitTime));
|
||||||
extraMap.put(IMAGE_SIZE, Integer.toString(byteSize));
|
extraMap.put(IMAGE_SIZE, Integer.toString(byteSize));
|
||||||
return extraMap;
|
return extraMap;
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +169,8 @@ public class CustomOkHttpNetworkFetcher
|
||||||
try {
|
try {
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
handleException(
|
handleException(
|
||||||
call, new IOException("Unexpected HTTP code " + response), callback);
|
call, new IOException("Unexpected HTTP code " + response),
|
||||||
|
callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,7 +206,8 @@ public class CustomOkHttpNetworkFetcher
|
||||||
/**
|
/**
|
||||||
* Handles exceptions.
|
* Handles exceptions.
|
||||||
*
|
*
|
||||||
* <p>OkHttp notifies callers of cancellations via an IOException. If IOException is caught after
|
* <p>OkHttp notifies callers of cancellations via an IOException. If IOException is caught
|
||||||
|
* after
|
||||||
* request cancellation, then the exception is interpreted as successful cancellation and
|
* request cancellation, then the exception is interpreted as successful cancellation and
|
||||||
* onCancellation is called. Otherwise onFailure is called.
|
* onCancellation is called. Otherwise onFailure is called.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ public class OkHttpJsonApiClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method will gradually calls the leaderboard API and fetches the leaderboard
|
* The method will gradually calls the leaderboard API and fetches the leaderboard
|
||||||
|
*
|
||||||
* @param userName username of leaderboard user
|
* @param userName username of leaderboard user
|
||||||
* @param duration duration for leaderboard
|
* @param duration duration for leaderboard
|
||||||
* @param category category for leaderboard
|
* @param category category for leaderboard
|
||||||
|
|
@ -78,7 +79,8 @@ public class OkHttpJsonApiClient {
|
||||||
* @return LeaderboardResponse object
|
* @return LeaderboardResponse object
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public Observable<LeaderboardResponse> getLeaderboard(String userName, String duration, String category, String limit, String offset) {
|
public Observable<LeaderboardResponse> getLeaderboard(String userName, String duration,
|
||||||
|
String category, String limit, String offset) {
|
||||||
final String fetchLeaderboardUrlTemplate = wikiMediaTestToolforgeUrl
|
final String fetchLeaderboardUrlTemplate = wikiMediaTestToolforgeUrl
|
||||||
+ LEADERBOARD_END_POINT;
|
+ LEADERBOARD_END_POINT;
|
||||||
String url = String.format(Locale.ENGLISH,
|
String url = String.format(Locale.ENGLISH,
|
||||||
|
|
@ -118,6 +120,7 @@ public class OkHttpJsonApiClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will update the leaderboard user avatar
|
* This method will update the leaderboard user avatar
|
||||||
|
*
|
||||||
* @param username username to update
|
* @param username username to update
|
||||||
* @param avatar url of the new avatar
|
* @param avatar url of the new avatar
|
||||||
* @return UpdateAvatarResponse object
|
* @return UpdateAvatarResponse object
|
||||||
|
|
@ -222,8 +225,8 @@ public class OkHttpJsonApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This takes userName as input, which is then used to fetch the feedback/achievements statistics
|
* This takes userName as input, which is then used to fetch the feedback/achievements
|
||||||
* using OkHttp and JavaRx. This function return JSONObject
|
* statistics using OkHttp and JavaRx. This function return JSONObject
|
||||||
*
|
*
|
||||||
* @param userName MediaWiki user name
|
* @param userName MediaWiki user name
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -261,7 +264,8 @@ public class OkHttpJsonApiClient {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<List<Place>> getNearbyPlaces(LatLng cur, String language, double radius) throws IOException {
|
public Observable<List<Place>> getNearbyPlaces(LatLng cur, String language, double radius)
|
||||||
|
throws IOException {
|
||||||
String wikidataQuery = FileUtils.readFromResource("/queries/nearby_query.rq");
|
String wikidataQuery = FileUtils.readFromResource("/queries/nearby_query.rq");
|
||||||
String query = wikidataQuery
|
String query = wikidataQuery
|
||||||
.replace("${RAD}", String.format(Locale.ROOT, "%.2f", radius))
|
.replace("${RAD}", String.format(Locale.ROOT, "%.2f", radius))
|
||||||
|
|
@ -304,7 +308,8 @@ public class OkHttpJsonApiClient {
|
||||||
*/
|
*/
|
||||||
public Single<List<DepictedItem>> getChildDepictions(String qid, int startPosition,
|
public Single<List<DepictedItem>> getChildDepictions(String qid, int startPosition,
|
||||||
int limit) throws IOException {
|
int limit) throws IOException {
|
||||||
return depictedItemsFrom(sparqlQuery(qid, startPosition, limit,"/queries/subclasses_query.rq"));
|
return depictedItemsFrom(
|
||||||
|
sparqlQuery(qid, startPosition, limit, "/queries/subclasses_query.rq"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -326,12 +331,13 @@ public class OkHttpJsonApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Request sparqlQuery(String qid, int startPosition, int limit, String fileName) throws IOException {
|
private Request sparqlQuery(String qid, int startPosition, int limit, String fileName)
|
||||||
|
throws IOException {
|
||||||
String query = FileUtils.readFromResource(fileName)
|
String query = FileUtils.readFromResource(fileName)
|
||||||
.replace("${QID}", qid)
|
.replace("${QID}", qid)
|
||||||
.replace("${LANG}", "\"" + Locale.getDefault().getLanguage() + "\"")
|
.replace("${LANG}", "\"" + Locale.getDefault().getLanguage() + "\"")
|
||||||
.replace("${LIMIT}",""+ limit)
|
.replace("${LIMIT}", "" + limit)
|
||||||
.replace("${OFFSET}",""+ startPosition);
|
.replace("${OFFSET}", "" + startPosition);
|
||||||
HttpUrl.Builder urlBuilder = HttpUrl
|
HttpUrl.Builder urlBuilder = HttpUrl
|
||||||
.parse(sparqlQueryUrl)
|
.parse(sparqlQueryUrl)
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import org.wikipedia.model.EnumCodeMap;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum NavTab implements EnumCode {
|
public enum NavTab implements EnumCode {
|
||||||
CONTRIBUTIONS(R.string.contributions_fragment, R.drawable.ic_baseline_person_24) {
|
CONTRIBUTIONS(R.string.contributions_fragment, R.drawable.ic_baseline_person_24) {
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
@ -25,7 +24,7 @@ public enum NavTab implements EnumCode {
|
||||||
return ContributionsFragment.newInstance();
|
return ContributionsFragment.newInstance();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NEARBY(R.string.nearby_fragment, R.drawable.ic_location_on_black_24dp){
|
NEARBY(R.string.nearby_fragment, R.drawable.ic_location_on_black_24dp) {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Fragment newInstance() {
|
public Fragment newInstance() {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentPagerAdapter;
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
|
||||||
public class NavTabFragmentPagerAdapter extends FragmentPagerAdapter {
|
public class NavTabFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
private Fragment currentFragment;
|
private Fragment currentFragment;
|
||||||
|
|
||||||
public NavTabFragmentPagerAdapter(FragmentManager mgr) {
|
public NavTabFragmentPagerAdapter(FragmentManager mgr) {
|
||||||
|
|
@ -19,11 +20,13 @@ public class NavTabFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||||
return currentFragment;
|
return currentFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Fragment getItem(int pos) {
|
@Override
|
||||||
|
public Fragment getItem(int pos) {
|
||||||
return NavTab.of(pos).newInstance();
|
return NavTab.of(pos).newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getCount() {
|
@Override
|
||||||
|
public int getCount() {
|
||||||
return NavTab.size();
|
return NavTab.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class NavTabLayout extends BottomNavigationView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTabViews() {
|
private void setTabViews() {
|
||||||
if (((MainActivity)getContext()).applicationKvStore.getBoolean("login_skipped") == true) {
|
if (((MainActivity) getContext()).applicationKvStore.getBoolean("login_skipped") == true) {
|
||||||
for (int i = 0; i < NavTabLoggedOut.size(); i++) {
|
for (int i = 0; i < NavTabLoggedOut.size(); i++) {
|
||||||
NavTabLoggedOut navTab = NavTabLoggedOut.of(i);
|
NavTabLoggedOut navTab = NavTabLoggedOut.of(i);
|
||||||
getMenu().add(Menu.NONE, i, i, navTab.text()).setIcon(navTab.icon());
|
getMenu().add(Menu.NONE, i, i, navTab.text()).setIcon(navTab.icon());
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@ public enum NavTabLoggedOut implements EnumCode {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final EnumCodeMap<NavTabLoggedOut> MAP = new EnumCodeMap<>(NavTabLoggedOut.class);
|
private static final EnumCodeMap<NavTabLoggedOut> MAP = new EnumCodeMap<>(
|
||||||
|
NavTabLoggedOut.class);
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
private final int text;
|
private final int text;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import timber.log.Timber;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ImageProcessingService {
|
public class ImageProcessingService {
|
||||||
|
|
||||||
private final FileUtilsWrapper fileUtilsWrapper;
|
private final FileUtilsWrapper fileUtilsWrapper;
|
||||||
private final ImageUtilsWrapper imageUtilsWrapper;
|
private final ImageUtilsWrapper imageUtilsWrapper;
|
||||||
private final ReadFBMD readFBMD;
|
private final ReadFBMD readFBMD;
|
||||||
|
|
@ -62,7 +63,8 @@ public class ImageProcessingService {
|
||||||
checkFBMD(filePath),
|
checkFBMD(filePath),
|
||||||
checkEXIF(filePath),
|
checkEXIF(filePath),
|
||||||
(duplicateImage, wrongGeoLocation, darkImage, itemTitle, fbmd, exif) -> {
|
(duplicateImage, wrongGeoLocation, darkImage, itemTitle, fbmd, exif) -> {
|
||||||
Timber.d("duplicate: %d, geo: %d, dark: %d, title: %d" + "fbmd:" + fbmd + "exif:" + exif,
|
Timber.d("duplicate: %d, geo: %d, dark: %d, title: %d" + "fbmd:" + fbmd + "exif:"
|
||||||
|
+ exif,
|
||||||
duplicateImage, wrongGeoLocation, darkImage, itemTitle);
|
duplicateImage, wrongGeoLocation, darkImage, itemTitle);
|
||||||
return duplicateImage | wrongGeoLocation | darkImage | itemTitle | fbmd | exif;
|
return duplicateImage | wrongGeoLocation | darkImage | itemTitle | fbmd | exif;
|
||||||
}
|
}
|
||||||
|
|
@ -79,10 +81,10 @@ public class ImageProcessingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We try to minimize uploads from the Commons app that might be copyright violations.
|
* We try to minimize uploads from the Commons app that might be copyright violations. If an
|
||||||
* If an image does not have any Exif metadata, then it was likely downloaded from the internet,
|
* image does not have any Exif metadata, then it was likely downloaded from the internet, and
|
||||||
* and is probably not an original work by the user. We detect these kinds of images by looking
|
* is probably not an original work by the user. We detect these kinds of images by looking for
|
||||||
* for the presence of some basic Exif metadata.
|
* the presence of some basic Exif metadata.
|
||||||
*/
|
*/
|
||||||
private Single<Integer> checkEXIF(String filepath) {
|
private Single<Integer> checkEXIF(String filepath) {
|
||||||
return EXIFReader.processMetadata(filepath);
|
return EXIFReader.processMetadata(filepath);
|
||||||
|
|
@ -90,9 +92,7 @@ public class ImageProcessingService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks item caption
|
* Checks item caption - empty caption - existing caption
|
||||||
* - empty caption
|
|
||||||
* - existing caption
|
|
||||||
*
|
*
|
||||||
* @param uploadItem
|
* @param uploadItem
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -142,8 +142,8 @@ public class ImageProcessingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for image geolocation
|
* Checks for image geolocation returns IMAGE_OK if the place is null or if the file doesn't
|
||||||
* returns IMAGE_OK if the place is null or if the file doesn't contain a geolocation
|
* contain a geolocation
|
||||||
*
|
*
|
||||||
* @param filePath file to be checked
|
* @param filePath file to be checked
|
||||||
* @return IMAGE_GEOLOCATION_DIFFERENT or IMAGE_OK
|
* @return IMAGE_GEOLOCATION_DIFFERENT or IMAGE_OK
|
||||||
|
|
@ -159,7 +159,8 @@ public class ImageProcessingService {
|
||||||
if (StringUtils.isBlank(geoLocation)) {
|
if (StringUtils.isBlank(geoLocation)) {
|
||||||
return Single.just(ImageUtils.IMAGE_OK);
|
return Single.just(ImageUtils.IMAGE_OK);
|
||||||
}
|
}
|
||||||
return imageUtilsWrapper.checkImageGeolocationIsDifferent(geoLocation, place.getLocation());
|
return imageUtilsWrapper
|
||||||
|
.checkImageGeolocationIsDifferent(geoLocation, place.getLocation());
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.io());
|
.subscribeOn(Schedulers.io());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,9 @@ public class UploadClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload file to stash in chunks of specified size. Uploading files in chunks will make handling
|
* Upload file to stash in chunks of specified size. Uploading files in chunks will make
|
||||||
* of large files easier. Also, it will be useful in supporting pause/resume of uploads
|
* handling of large files easier. Also, it will be useful in supporting pause/resume of
|
||||||
|
* uploads
|
||||||
*/
|
*/
|
||||||
public Observable<StashUploadResult> uploadFileToStash(
|
public Observable<StashUploadResult> uploadFileToStash(
|
||||||
final Context context, final String filename, final Contribution contribution,
|
final Context context, final String filename, final Contribution contribution,
|
||||||
|
|
@ -102,7 +103,8 @@ public class UploadClient {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunkInfo.get() != null && index.get() < chunkInfo.get().getIndexOfNextChunkToUpload()) {
|
if (chunkInfo.get() != null && index.get() < chunkInfo.get()
|
||||||
|
.getIndexOfNextChunkToUpload()) {
|
||||||
index.incrementAndGet();
|
index.incrementAndGet();
|
||||||
Timber.d("Chunk: Increment and return: %s", index.get());
|
Timber.d("Chunk: Increment and return: %s", index.get());
|
||||||
return;
|
return;
|
||||||
|
|
@ -155,6 +157,7 @@ public class UploadClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stash is valid for 6 hours. This function checks the validity of stash
|
* Stash is valid for 6 hours. This function checks the validity of stash
|
||||||
|
*
|
||||||
* @param contribution
|
* @param contribution
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -217,9 +220,11 @@ public class UploadClient {
|
||||||
CommonsApplication.DEFAULT_EDIT_SUMMARY,
|
CommonsApplication.DEFAULT_EDIT_SUMMARY,
|
||||||
uniqueFileName,
|
uniqueFileName,
|
||||||
fileKey).map(uploadResponse -> {
|
fileKey).map(uploadResponse -> {
|
||||||
UploadResponse uploadResult = gson.fromJson(uploadResponse, UploadResponse.class);
|
UploadResponse uploadResult = gson
|
||||||
|
.fromJson(uploadResponse, UploadResponse.class);
|
||||||
if (uploadResult.getUpload() == null) {
|
if (uploadResult.getUpload() == null) {
|
||||||
final MwException exception = gson.fromJson(uploadResponse, MwException.class);
|
final MwException exception = gson
|
||||||
|
.fromJson(uploadResponse, MwException.class);
|
||||||
Timber.e(exception, "Error in uploading file from stash");
|
Timber.e(exception, "Error in uploading file from stash");
|
||||||
throw new RuntimeException(exception.getErrorCode());
|
throw new RuntimeException(exception.getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ public class UploadItem {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the corresponding place to the uploadItem
|
* Sets the corresponding place to the uploadItem
|
||||||
|
*
|
||||||
* @param place geolocated Wikidata item
|
* @param place geolocated Wikidata item
|
||||||
*/
|
*/
|
||||||
public void setPlace(Place place) {
|
public void setPlace(Place place) {
|
||||||
|
|
@ -114,7 +115,7 @@ public class UploadItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHasInvalidLocation(boolean hasInvalidLocation) {
|
public void setHasInvalidLocation(boolean hasInvalidLocation) {
|
||||||
this.hasInvalidLocation=hasInvalidLocation;
|
this.hasInvalidLocation = hasInvalidLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasInvalidLocation() {
|
public boolean hasInvalidLocation() {
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
public class ActivityUtils {
|
public class ActivityUtils {
|
||||||
|
|
||||||
public static <T> void startActivityWithFlags(Context context, Class<T> cls, int... flags) {
|
public static <T> void startActivityWithFlags(Context context, Class<T> cls, int... flags) {
|
||||||
Intent intent = new Intent(context, cls);
|
Intent intent = new Intent(context, cls);
|
||||||
for (int flag: flags) {
|
for (int flag : flags) {
|
||||||
intent.addFlags(flag);
|
intent.addFlags(flag);
|
||||||
}
|
}
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ public class WikiBaseClient {
|
||||||
String languageCode, String captionValue) {
|
String languageCode, String captionValue) {
|
||||||
return csrfToken()
|
return csrfToken()
|
||||||
.switchMap(editToken -> wikiBaseInterface
|
.switchMap(editToken -> wikiBaseInterface
|
||||||
.addLabelstoWikidata(PAGE_ID_PREFIX + fileEntityId, editToken, languageCode, captionValue));
|
.addLabelstoWikidata(PAGE_ID_PREFIX + fileEntityId, editToken, languageCode,
|
||||||
|
captionValue));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ public class WikidataClient {
|
||||||
*/
|
*/
|
||||||
Observable<Long> setClaim(Statement_partial claim, String tags) {
|
Observable<Long> setClaim(Statement_partial claim, String tags) {
|
||||||
return getCsrfToken()
|
return getCsrfToken()
|
||||||
.flatMap(csrfToken -> wikidataInterface.postSetClaim(gson.toJson(claim), tags, csrfToken))
|
.flatMap(
|
||||||
|
csrfToken -> wikidataInterface.postSetClaim(gson.toJson(claim), tags, csrfToken))
|
||||||
.map(mwPostResponse -> mwPostResponse.getPageinfo().getLastrevid());
|
.map(mwPostResponse -> mwPostResponse.getPageinfo().getLastrevid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,8 @@ public class WikidataEditService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits the wikibase entity by adding DEPICTS property. Adding DEPICTS property requires call to
|
* Edits the wikibase entity by adding DEPICTS property. Adding DEPICTS property requires call
|
||||||
* the wikibase API to set tag against the entity.
|
* to the wikibase API to set tag against the entity.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
private Observable<Boolean> addDepictsProperty(final String fileEntityId,
|
private Observable<Boolean> addDepictsProperty(final String fileEntityId,
|
||||||
|
|
@ -137,8 +137,8 @@ public class WikidataEditService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long createClaim(@Nullable final WikidataPlace wikidataPlace, final String fileName, final
|
public Long createClaim(@Nullable final WikidataPlace wikidataPlace, final String fileName,
|
||||||
Map<String, String> captions) {
|
final Map<String, String> captions) {
|
||||||
if (!(directKvStore.getBoolean("Picture_Has_Correct_Location", true))) {
|
if (!(directKvStore.getBoolean("Picture_Has_Correct_Location", true))) {
|
||||||
Timber
|
Timber
|
||||||
.d("Image location and nearby place location mismatched, so Wikidata item won't be edited");
|
.d("Image location and nearby place location mismatched, so Wikidata item won't be edited");
|
||||||
|
|
@ -149,7 +149,8 @@ public class WikidataEditService {
|
||||||
|
|
||||||
public Long addImageAndMediaLegends(final WikidataItem wikidataItem, final String fileName,
|
public Long addImageAndMediaLegends(final WikidataItem wikidataItem, final String fileName,
|
||||||
final Map<String, String> captions) {
|
final Map<String, String> captions) {
|
||||||
final Snak_partial p18 = new Snak_partial("value", WikidataProperties.IMAGE.getPropertyName(),
|
final Snak_partial p18 = new Snak_partial("value",
|
||||||
|
WikidataProperties.IMAGE.getPropertyName(),
|
||||||
new ValueString(fileName.replace("File:", "")));
|
new ValueString(fileName.replace("File:", "")));
|
||||||
|
|
||||||
final List<Snak_partial> snaks = new ArrayList<>();
|
final List<Snak_partial> snaks = new ArrayList<>();
|
||||||
|
|
@ -179,10 +180,12 @@ public class WikidataEditService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable addDepictionsAndCaptions(final UploadResult uploadResult, final Contribution contribution) {
|
public Observable addDepictionsAndCaptions(final UploadResult uploadResult,
|
||||||
|
final Contribution contribution) {
|
||||||
return wikiBaseClient.getFileEntityId(uploadResult)
|
return wikiBaseClient.getFileEntityId(uploadResult)
|
||||||
.doOnError(throwable -> {
|
.doOnError(throwable -> {
|
||||||
Timber.e(throwable, "Error occurred while getting EntityID to set DEPICTS property");
|
Timber
|
||||||
|
.e(throwable, "Error occurred while getting EntityID to set DEPICTS property");
|
||||||
ViewUtil.showLongToast(context, context.getString(R.string.wikidata_edit_failure));
|
ViewUtil.showLongToast(context, context.getString(R.string.wikidata_edit_failure));
|
||||||
})
|
})
|
||||||
.switchMap(fileEntityId -> {
|
.switchMap(fileEntityId -> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue