Skip to content

Fixes #3766, Added OPENSTREET attribution #3889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
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;
import static fr.free.nrw.commons.nearby.Label.TEXT_TO_DESCRIPTION;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;

import android.Manifest;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
Expand All @@ -11,6 +19,8 @@
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
Expand All @@ -26,14 +36,15 @@
import android.widget.SearchView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;

import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
Expand All @@ -58,17 +69,6 @@
import com.mapbox.pluginscalebar.ScaleBarOptions;
import com.mapbox.pluginscalebar.ScaleBarPlugin;
import com.pedrogomez.renderers.RVRendererAdapter;

import fr.free.nrw.commons.utils.DialogUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

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

import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
Expand All @@ -92,6 +92,7 @@
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.utils.DialogUtil;
import fr.free.nrw.commons.utils.ExecutorUtils;
import fr.free.nrw.commons.utils.LayoutUtils;
import fr.free.nrw.commons.utils.LocationUtils;
Expand All @@ -105,16 +106,13 @@
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Named;
import timber.log.Timber;

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;
import static fr.free.nrw.commons.nearby.Label.TEXT_TO_DESCRIPTION;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;


public class NearbyParentFragment extends CommonsDaggerSupportFragment
implements NearbyParentFragmentContract.View,
Expand Down Expand Up @@ -154,6 +152,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
MapView mapView;
@BindView(R.id.rv_nearby_list)
RecyclerView rvNearbyList;
@BindView(R.id.tv_attribution)
AppCompatTextView tvAttribution;

@Inject LocationServiceManager locationManager;
@Inject NearbyController nearbyController;
Expand Down Expand Up @@ -236,8 +236,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
UiSettings uiSettings = mapBoxMap.getUiSettings();
uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT);
uiSettings.setCompassMargins(12, 0, 0, 24);
uiSettings.setLogoEnabled(true);
uiSettings.setAttributionEnabled(true);
uiSettings.setLogoEnabled(false);
uiSettings.setAttributionEnabled(false);
uiSettings.setRotateGesturesEnabled(false);
NearbyParentFragment.this.isMapBoxReady=true;
performMapReadyActions();
Expand All @@ -260,6 +260,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
scaleBarPlugin.create(scaleBarOptions);
});
});

tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution)));
tvAttribution.setMovementMethod(LinkMovementMethod.getInstance());
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/fr/free/nrw/commons/settings/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Prefs {
public static final String MANAGED_EXIF_TAGS = "managed_exif_tags";
public static final String KEY_LANGUAGE_VALUE = "languageDescription";
public static final String KEY_THEME_VALUE = "appThemePref";
public static final String TELEMETRY_PREFERENCE = "telemetryPref";

public static class Licenses {
public static final String CC_BY_SA_3 = "CC BY-SA 3.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.karumi.dexter.Dexter;
import com.karumi.dexter.listener.PermissionGrantedResponse;
import com.karumi.dexter.listener.single.BasePermissionListener;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.di.ApplicationlessInjection;
Expand Down Expand Up @@ -123,6 +125,24 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
findPreference("displayCampaignsCardView").setEnabled(false);
uploadLimit.setEnabled(false);
}

findPreference("telemetryOptOut").setOnPreferenceChangeListener(
(preference, newValue) -> {
telemetryOptInOut((boolean)newValue);
defaultKvStore.putBoolean(Prefs.TELEMETRY_PREFERENCE,(boolean)newValue);
return false;
});
}

/**
* Opt in or out of MapBox telemetry
* @param shouldOptIn
*/
private void telemetryOptInOut(boolean shouldOptIn){
TelemetryDefinition telemetry = Mapbox.getTelemetry();
if (telemetry != null) {
telemetry.setUserTelemetryRequestState(shouldOptIn);
}
}

/**
Expand Down
16 changes: 14 additions & 2 deletions app/src/main/res/layout/fragment_nearby_parent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<!-- I have done this intentionally, the mapview because of some elevation or something,
sometimes hangs over the drawer layout and sometimes draws its onPaused state over the contributions, this seems to be the probable fix -->
<FrameLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/nearby_filter">
Expand All @@ -40,7 +40,19 @@
android:layout_height="match_parent"
android:background="@android:color/transparent" />

</FrameLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_attribution"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/map_attribution"
android:textAlignment="center"
android:textSize="10sp" />

</RelativeLayout>


<Button
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,7 @@ Upload your first media by tapping on the add button.</string>
<string name="ask_to_turn_location_on">Turn on location?</string>
<string name="nearby_needs_location">Nearby needs location enabled to work properly</string>
<string name="use_location_from_similar_image">Did you shoot these two pictures at the same place? Do you want to use the latitude/longitude of the picture on the right?</string>

<string name="mapbox_telemetry">Telemetry Opt Out</string>
<string name="telemetry_opt_out_summary">Send anonymized location and usage data to Mapbox when using Nearby feature</string>
<string name="map_attribution" translatable="false"><![CDATA[&#169; <a href="https://www.mapbox.com/about/maps/">Mapbox</a> &#169; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> <a href="https://www.mapbox.com/map-feedback/">Improve this map</a>]]></string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
android:summary="@string/manage_exif_tags_summary"
android:title="@string/manage_exif_tags" />

<SwitchPreference
android:defaultValue="true"
android:key="telemetryOptOut"
app:singleLineTitle="false"
android:summary="@string/telemetry_opt_out_summary"
android:title="@string/mapbox_telemetry" />

</PreferenceCategory>

<!-- The key 'allowGps' was used before and has since been removed based on the discussion at #1599.
Expand Down