Fixes #2843 New main screen UI in v3.0 (#3891)

* Add additional classes from 2019 hackathon implementation

* Make first tab work

* Make explore tab work

* Handle back button for contrib and nearby

* Fix framelayout and nav bar allignment

* Fix nav bar tint

* Fix nearby card layout

* Make contributions number visible

* Change menu icon according to fragment

* Make notification icon work and remove drawer

* Make favourites accessible from nav bar

* Turn bookmark and explore activities into fragments

* Use bottom sheet instead of more fragment

* Add actions

* Remove unused classes

* Fix indentation

* remove more fragment title

* Fix explore fragment indentation

* Make toolbar settings as we wanted

* Set card view styles

* Make colors for explore actiivty

* Remove drawer from achievements activity

* Add back button to achievements activity

* remove drawer from review activity

* Remove drawer from settings activity

* Remove drawer from about activity

* Fix dagger injection of fragment

* Implement skip login version

* Add theme missing colors

* Add style to moresheet

* refactor name

* call login with button

* Remove all old bookmarks activity dependency

* Make explore tab items clickable

* Do nothing if same tab is selected

* Fix notification icon color for dark theme

* Fix wrong drawable colors

* Handle back button after media details is visible from contrib and explore fragments

* make favourites open media details

* Fix profile icon

* Make user name visible instead

* Move user back to contrib fragment

* Remove NavigationBaseAvticity

* Fix typo in bookmark fragment

* Fix menu button colors

* Remove explore activity

* remove drawer and dependencies

* Make bookmark media details visible

* Cleanup code

* Code cleanup

* Remove unused layout

* Make contriblist UI look like in mockups

* Change limited connecton toggle

* Move list menu item to nearby fragment

* Fix search button crash

* Make media detail appear

* Back button added

* Fix back button npe

* Change bookmark list view

* Fix always the firs item displayed issue

* Allign contrib list bottom line to simple drawee bottom

* fix fragment string

* Fix back button for mobile uploads

* Make lists appear

* Make fav item selected

* Make favourites clickable

* Add back button to media details

* Add toolbar of notification activity

* Change contributions icon

* Fix card UI

* Fix back button in explore

* Make card views look similar to mockups

* Solve campaign bug visible issue

* Make borders a little softer
This commit is contained in:
neslihanturan 2020-11-06 19:04:04 +03:00 committed by GitHub
parent 5d82629109
commit 71d200ee41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
110 changed files with 2225 additions and 1629 deletions

View file

@ -14,18 +14,15 @@ import androidx.annotation.Nullable;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.MainActivity;
import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment;
import fr.free.nrw.commons.utils.SwipableCardView;
import fr.free.nrw.commons.utils.ViewUtil;
import timber.log.Timber;
import static fr.free.nrw.commons.contributions.MainActivity.NEARBY_TAB_POSITION;
/**
* Custom card view for nearby notification card view on main screen, above contributions list
*/
public class NearbyNotificationCardView extends SwipableCardView {
private Button permissionRequestButton;
public Button permissionRequestButton;
private LinearLayout contentLayout;
private TextView notificationTitle;
private TextView notificationDistance;
@ -77,22 +74,16 @@ public class NearbyNotificationCardView extends SwipableCardView {
super.onAttachedToWindow();
// If you don't setVisibility after getting layout params, then you will se an empty space in place of nearby NotificationCardView
if (((MainActivity)getContext()).defaultKvStore.getBoolean("displayNearbyCardView", true) && this.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
this.setVisibility(VISIBLE);
setVisibility(VISIBLE);
} else {
this.setVisibility(GONE);
setVisibility(GONE);
}
}
private void setActionListeners(Place place) {
this.setOnClickListener(view -> {
MainActivity m = (MainActivity) getContext();
// Change to nearby tab
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);
// Center the map to the place
((NearbyParentFragment) m.contributionsActivityPagerAdapter.getItem(NEARBY_TAB_POSITION)).centerMapToPlace(place);
((MainActivity) getContext()).centerMapToPlace(place);
});
}

View file

@ -13,7 +13,7 @@ import fr.free.nrw.commons.auth.LoginActivity
import fr.free.nrw.commons.contributions.ContributionController
import fr.free.nrw.commons.kvstore.JsonKvStore
import fr.free.nrw.commons.nearby.Place
import fr.free.nrw.commons.theme.NavigationBaseActivity
import fr.free.nrw.commons.utils.ActivityUtils
import fr.free.nrw.commons.wikidata.WikidataConstants
import timber.log.Timber
import javax.inject.Inject
@ -85,7 +85,7 @@ class CommonPlaceClickActions @Inject constructor(
AlertDialog.Builder(activity)
.setMessage(R.string.login_alert_message)
.setPositiveButton(R.string.login) { dialog, which ->
NavigationBaseActivity.startActivityWithFlags(
ActivityUtils.startActivityWithFlags(
activity,
LoginActivity::class.java,
Intent.FLAG_ACTIVITY_CLEAR_TOP,

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.nearby.fragments;
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SLIGHTLY_CHANGED;
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.MAP_UPDATED;
@ -24,6 +23,10 @@ import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
@ -77,11 +80,13 @@ import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.LoginActivity;
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
import fr.free.nrw.commons.contributions.ContributionController;
import fr.free.nrw.commons.contributions.ContributionsFragment;
import fr.free.nrw.commons.contributions.MainActivity;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.location.LocationUpdateListener;
import fr.free.nrw.commons.navtab.NavTab;
import fr.free.nrw.commons.nearby.CheckBoxTriStates;
import fr.free.nrw.commons.nearby.Label;
import fr.free.nrw.commons.nearby.MarkerPlaceGroup;
@ -93,6 +98,7 @@ import fr.free.nrw.commons.nearby.NearbyMarker;
import fr.free.nrw.commons.nearby.Place;
import fr.free.nrw.commons.nearby.contract.NearbyParentFragmentContract;
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter;
import fr.free.nrw.commons.notification.NotificationActivity;
import fr.free.nrw.commons.utils.DialogUtil;
import fr.free.nrw.commons.utils.ExecutorUtils;
import fr.free.nrw.commons.utils.LayoutUtils;
@ -208,6 +214,13 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
private LatLngBounds latLngBounds;
private PlaceAdapter adapter;
@NonNull
public static NearbyParentFragment newInstance() {
NearbyParentFragment fragment = new NearbyParentFragment();
fragment.setRetainInstance(true);
return fragment;
}
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
@ -215,11 +228,25 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
ButterKnife.bind(this, view);
initNetworkBroadCastReceiver();
presenter=new NearbyParentFragmentPresenter(bookmarkLocationDao);
setHasOptionsMenu(true);
// Inflate the layout for this fragment
return view;
}
@Override
public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) {
inflater.inflate(R.menu.nearby_fragment_menu, menu);
MenuItem listMenu = menu.findItem(R.id.list_sheet);
listMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
listOptionMenuItemClicked();
return false;
}
});
}
@Override
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
@ -306,7 +333,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
}
private void performMapReadyActions() {
if (isVisible() && isVisibleToUser && isMapBoxReady) {
if (isVisible() && isMapBoxReady) {
checkPermissionsAndPerformAction(() -> {
lastKnownLocation = locationManager.getLastLocation();
fr.free.nrw.commons.location.LatLng target=lastFocusLocation;
@ -615,6 +642,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
* Centers the map in nearby fragment to a given place
* @param place is new center of the map
*/
@Override
public void centerMapToPlace(final Place place) {
Timber.d("Map is centered to place");
final double cameraShift;
@ -852,6 +880,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
@Override
public void setTabItemContributions() {
((MainActivity)getActivity()).viewPager.setCurrentItem(0);
// TODO
}
@Override
@ -860,7 +889,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
PermissionUtils.checkPermissionsAndPerformAction(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION,
runnable,
() -> ((MainActivity) getActivity()).viewPager.setCurrentItem(CONTRIBUTIONS_TAB_POSITION),
() -> ((MainActivity) getActivity()).setSelectedItemId(NavTab.CONTRIBUTIONS.code()),
R.string.location_permission_title,
R.string.location_permission_rationale_nearby);
}