mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	* Integrate WLM - Show monuments in maps along with nearby * BugFix in Monuments 1. Single preference for monuments and campaigns 2. Expand collapse chips container in nearby 3. Typo fix in Monuments card in Nearby 4. If a nearby place is a monument as well - do not show them separately, show it as a monument instead 5. Bug fix, monument radius, use the same one as that of nearby * More bug fixes 1. Possible NPE in nearby 2. Added column location_address in BookmarkLocationDao 3. Bug Fix - Display Date in WLM card 4. WLM card on click takes to nearby * Use lowercase country code in WLM uploads * Bug-Fix, WLM Campaign Icon * 1. Updated monuments query to use any of the following properties for monuments - [P1435, P2186, P1459, P1460, P1216, P709, P718, P5694] 2. Append WikiData QID to descriptions template * Updated WLM Banner String, Handle NPE in contributions callback * Added nearby-monuments query log lines * Handle WLM Query exception : - if an exception is thrown in WLM query, continue showing the nearby items if that succeeds * Fix BookmarkLocationDaoTest * Added Column Address in BookmarkLocationDaoTest * Use fallback description as usual nearby pins even for WLM pins, instead of relying on P6375 * Test fix in BookmarkLocationDao * Updated template for WLM, removed redundant feilds * Fixed WLM template * Removed categories from WLM template * Fixed BookmarkControllerTest * Fixed BookmarkLocationFragmentUnitTest * fix ModelFunctions * Fixed BookmarksDaoLocationTest * Fixed WLM template
This commit is contained in:
		
							parent
							
								
									67f5b6c271
								
							
						
					
					
						commit
						6588a6fd0e
					
				
					 39 changed files with 2906 additions and 185 deletions
				
			
		|  | @ -2,14 +2,13 @@ package fr.free.nrw.commons.contributions; | |||
| 
 | ||||
| import static fr.free.nrw.commons.contributions.Contribution.STATE_FAILED; | ||||
| import static fr.free.nrw.commons.contributions.Contribution.STATE_PAUSED; | ||||
| import static fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.WLM_URL; | ||||
| import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween; | ||||
| 
 | ||||
| import android.Manifest; | ||||
| import android.annotation.SuppressLint; | ||||
| import android.content.ComponentName; | ||||
| import android.content.Context; | ||||
| import android.os.Bundle; | ||||
| import android.util.Log; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuInflater; | ||||
|  | @ -27,21 +26,21 @@ import androidx.fragment.app.Fragment; | |||
| import androidx.fragment.app.FragmentManager.OnBackStackChangedListener; | ||||
| import androidx.fragment.app.FragmentTransaction; | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
| import fr.free.nrw.commons.Utils; | ||||
| import fr.free.nrw.commons.auth.SessionManager; | ||||
| import fr.free.nrw.commons.notification.Notification; | ||||
| import fr.free.nrw.commons.notification.NotificationController; | ||||
| import fr.free.nrw.commons.theme.BaseActivity; | ||||
| import java.text.ParseException; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| import androidx.work.WorkInfo; | ||||
| import androidx.work.WorkManager; | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
| import fr.free.nrw.commons.Media; | ||||
| import fr.free.nrw.commons.R; | ||||
| import fr.free.nrw.commons.auth.SessionManager; | ||||
| import fr.free.nrw.commons.campaigns.Campaign; | ||||
| import fr.free.nrw.commons.campaigns.CampaignView; | ||||
| import fr.free.nrw.commons.campaigns.CampaignsPresenter; | ||||
|  | @ -59,10 +58,7 @@ import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient; | |||
| import fr.free.nrw.commons.nearby.NearbyController; | ||||
| import fr.free.nrw.commons.nearby.NearbyNotificationCardView; | ||||
| import fr.free.nrw.commons.nearby.Place; | ||||
| import fr.free.nrw.commons.notification.Notification; | ||||
| import fr.free.nrw.commons.notification.NotificationActivity; | ||||
| import fr.free.nrw.commons.notification.NotificationController; | ||||
| import fr.free.nrw.commons.theme.BaseActivity; | ||||
| import fr.free.nrw.commons.upload.worker.UploadWorker; | ||||
| import fr.free.nrw.commons.utils.ConfigUtils; | ||||
| import fr.free.nrw.commons.utils.DialogUtil; | ||||
|  | @ -73,9 +69,6 @@ import io.reactivex.Observable; | |||
| import io.reactivex.android.schedulers.AndroidSchedulers; | ||||
| import io.reactivex.disposables.CompositeDisposable; | ||||
| import io.reactivex.schedulers.Schedulers; | ||||
| import java.util.List; | ||||
| import javax.inject.Inject; | ||||
| import javax.inject.Named; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| public class ContributionsFragment | ||||
|  | @ -118,6 +111,8 @@ public class ContributionsFragment | |||
| 
 | ||||
|     public TextView notificationCount; | ||||
| 
 | ||||
|     private Campaign wlmCampaign; | ||||
| 
 | ||||
|     @NonNull | ||||
|     public static ContributionsFragment newInstance() { | ||||
|         ContributionsFragment fragment = new ContributionsFragment(); | ||||
|  | @ -137,6 +132,7 @@ public class ContributionsFragment | |||
|     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||||
|         View view = inflater.inflate(R.layout.fragment_contributions, container, false); | ||||
|         ButterKnife.bind(this, view); | ||||
|         initWLMCampaign(); | ||||
|         presenter.onAttachView(this); | ||||
|         contributionsPresenter.onAttachView(this); | ||||
|         campaignView.setVisibility(View.GONE); | ||||
|  | @ -177,6 +173,15 @@ public class ContributionsFragment | |||
|         return view; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise the campaign object for WML | ||||
|      */ | ||||
|     private void initWLMCampaign() { | ||||
|         wlmCampaign = new Campaign(getString(R.string.wlm_campaign_title), | ||||
|             getString(R.string.wlm_campaign_description), Utils.getWLMStartDate().toString(), | ||||
|             Utils.getWLMEndDate().toString(), WLM_URL, true); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) { | ||||
|         inflater.inflate(R.menu.contribution_activity_notification_menu, menu); | ||||
|  | @ -518,13 +523,17 @@ public class ContributionsFragment | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * ask the presenter to fetch the campaigns only if user has not manually disabled it | ||||
|      * As the home screen has limited space, we have choosen to show either campaigns or WLM card. | ||||
|      * The WLM Card gets the priority over monuments, so if the WLM is going on we show that instead | ||||
|      * of campaigns on the campaigns card | ||||
|      */ | ||||
|     private void fetchCampaigns() { | ||||
|         if (store.getBoolean("displayCampaignsCardView", true)) { | ||||
|         if (Utils.isMonumentsEnabled(new Date(), store)) { | ||||
|             campaignView.setCampaign(wlmCampaign); | ||||
|             campaignView.setVisibility(View.VISIBLE); | ||||
|         } else if (store.getBoolean(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE, true)) { | ||||
|             presenter.getCampaigns(); | ||||
|         } | ||||
|         else{ | ||||
|         } else { | ||||
|             campaignView.setVisibility(View.GONE); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -90,7 +90,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl | |||
| 
 | ||||
|     private ContributionsListAdapter adapter; | ||||
| 
 | ||||
|     private Callback callback; | ||||
|     @Nullable private Callback callback; | ||||
| 
 | ||||
|     private final int SPAN_COUNT_LANDSCAPE = 3; | ||||
|     private final int SPAN_COUNT_PORTRAIT = 1; | ||||
|  | @ -150,7 +150,9 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl | |||
|         contributionsListPresenter.contributionList.observe(this.getViewLifecycleOwner(), list -> { | ||||
|             contributionsSize = list.size(); | ||||
|             adapter.submitList(list); | ||||
|             callback.notifyDataSetChanged(); | ||||
|             if (callback != null) { | ||||
|                 callback.notifyDataSetChanged(); | ||||
|             } | ||||
|         }); | ||||
|         rvContributionsList.setAdapter(adapter); | ||||
|         adapter.registerAdapterDataObserver(new AdapterDataObserver() { | ||||
|  | @ -172,7 +174,9 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl | |||
|             @Override | ||||
|             public void onItemRangeChanged(final int positionStart, final int itemCount) { | ||||
|                 super.onItemRangeChanged(positionStart, itemCount); | ||||
|                 callback.viewPagerNotifyDataSetChanged(); | ||||
|                 if (callback != null) { | ||||
|                     callback.viewPagerNotifyDataSetChanged(); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -373,6 +373,13 @@ public class MainActivity  extends BaseActivity | |||
|         super.onDestroy(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Public method to show nearby from the reference of this. | ||||
|      */ | ||||
|     public void showNearby() { | ||||
|         tabLayout.setSelectedItemId(NavTab.NEARBY.code()); | ||||
|     } | ||||
| 
 | ||||
|     public enum ActiveFragment { | ||||
|         CONTRIBUTIONS, | ||||
|         NEARBY, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ashish
						Ashish