Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Solve lint issues, reduce baseline #9627

Merged
merged 3 commits into from
Jul 28, 2017
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
2 changes: 1 addition & 1 deletion platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ android {
}

lintOptions {
baseline file("lint-baseline.xml")
baseline file("lint-baseline-local.xml")
checkAllWarnings true
warningsAsErrors true
}
Expand Down
37 changes: 37 additions & 0 deletions platform/android/MapboxGLAndroidSDK/lint-baseline-local.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="4" by="lint 2.3.1">

<issue
id="MissingTranslation"
message="&quot;`mapbox_attributionErrorNoBrowser`&quot; is not translated in &quot;ca&quot; (Catalan), &quot;es&quot; (Spanish), &quot;lt&quot; (Lithuanian), &quot;nl&quot; (Dutch), &quot;sv&quot; (Swedish), &quot;vi&quot; (Vietnamese)"
errorLine1=" &lt;string name=&quot;mapbox_attributionErrorNoBrowser&quot;>No web browser installed on device, can\&apos;t open web page.&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="13"
column="13"/>
</issue>

<issue
id="MissingTranslation"
message="&quot;`mapbox_telemetrySettings`&quot; is not translated in &quot;ca&quot; (Catalan), &quot;es&quot; (Spanish), &quot;lt&quot; (Lithuanian), &quot;nl&quot; (Dutch), &quot;sv&quot; (Swedish), &quot;vi&quot; (Vietnamese)"
errorLine1=" &lt;string name=&quot;mapbox_telemetrySettings&quot;>Telemetry Settings&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="15"
column="13"/>
</issue>

<issue
id="TypographyQuotes"
message="Replace straight quotes (&apos;&apos;) with directional quotes (‘’, &amp;#8216; and &amp;#8217;) ?"
errorLine1=" &lt;string name=&quot;mapbox_attributionTelemetryMessage&quot;>Estàs ajudant a millorar els mapes d\&apos;OpenStreetMap i de Mapbox aportant dades d\&apos;ús anònimes.&lt;/string>"
errorLine2=" ^">
<location
file="src/main/res/values-ca/strings.xml"
line="9"
column="55"/>
</issue>

</issues>
587 changes: 1 addition & 586 deletions platform/android/MapboxGLAndroidSDK/lint/lint-baseline-ci.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk;

import android.annotation.SuppressLint;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
Expand All @@ -26,6 +27,7 @@
@UiThread
public final class Mapbox {

@SuppressLint("StaticFieldLeak")
private static Mapbox INSTANCE;
private Context context;
private String accessToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.annotations;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand Down Expand Up @@ -35,6 +36,7 @@ public final class IconFactory {
public static final String ICON_MARKERVIEW_ID = ICON_ID_PREFIX + "marker_view";

private Context context;
@SuppressLint("StaticFieldLeak")
private static IconFactory instance;
private Icon defaultMarker;
private Icon defaultMarkerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ public void cancel() {
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
Timber.v(String.format("[HTTP] Request was successful (code = %d).", response.code()));
Timber.v("[HTTP] Request was successful (code = %s).", response.code());
} else {
// We don't want to call this unsuccessful because a 304 isn't really an error
String message = !TextUtils.isEmpty(response.message()) ? response.message() : "No additional information";
Timber.d(String.format(
"[HTTP] Request with response code = %d: %s",
response.code(), message));
Timber.d("[HTTP] Request with response code = %s: %s", response.code(), message);
}

byte[] body;
Expand Down Expand Up @@ -160,15 +158,12 @@ private void onFailure(Exception e) {
String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request";

if (type == TEMPORARY_ERROR) {
Timber.d(String.format(MapboxConstants.MAPBOX_LOCALE,
"Request failed due to a temporary error: %s", errorMessage));
Timber.d("Request failed due to a temporary error: %s", errorMessage);
} else if (type == CONNECTION_ERROR) {
Timber.i(String.format(MapboxConstants.MAPBOX_LOCALE,
"Request failed due to a connection error: %s", errorMessage));
Timber.i("Request failed due to a connection error: %s", errorMessage);
} else {
// PERMANENT_ERROR
Timber.w(String.format(MapboxConstants.MAPBOX_LOCALE,
"Request failed due to a permanent error: %s", errorMessage));
Timber.w("Request failed due to a permanent error: %s", errorMessage);
}

mLock.lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ public void setPrefetchesTiles(boolean enable) {
* Check whether tile pre-fetching is enabled or not.
*
* @return true if enabled
*
* @see MapboxMap#setPrefetchesTiles(boolean)
*/
@UiThread
Expand Down Expand Up @@ -316,7 +315,7 @@ public <T extends Layer> T getLayerAs(@NonNull String layerId) {
// noinspection unchecked
return (T) nativeMapView.getLayer(layerId);
} catch (ClassCastException exception) {
Timber.e(String.format("Layer: %s is a different type: %s", layerId, exception));
Timber.e(exception, "Layer: %s is a different type: ", layerId);
return null;
}
}
Expand Down Expand Up @@ -437,7 +436,7 @@ public <T extends Source> T getSourceAs(@NonNull String sourceId) {
// noinspection unchecked
return (T) nativeMapView.getSource(sourceId);
} catch (ClassCastException exception) {
Timber.e(String.format("Source: %s is a different type: %s", sourceId, exception));
Timber.e(exception, "Source: %s is a different type: ", sourceId);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
Expand Down Expand Up @@ -84,9 +83,10 @@ public NativeMapView(MapView mapView) {

private boolean isDestroyedOn(String callingMethod) {
if (destroyed && !TextUtils.isEmpty(callingMethod)) {
Timber.e(String.format(MapboxConstants.MAPBOX_LOCALE,
Timber.e(
"You're calling `%s` after the `MapView` was destroyed, were you invoking it after `onDestroy()`?",
callingMethod));
callingMethod
);
}
return destroyed;
}
Expand Down Expand Up @@ -143,14 +143,14 @@ public void resizeView(int width, int height) {
if (width > 65535) {
// we have seen edge cases where devices return incorrect values #6111
Timber.e("Device returned an out of range width size, "
+ "capping value at 65535 instead of " + width);
+ "capping value at 65535 instead of %s", width);
width = 65535;
}

if (height > 65535) {
// we have seen edge cases where devices return incorrect values #6111
Timber.e("Device returned an out of range height size, "
+ "capping value at 65535 instead of " + height);
+ "capping value at 65535 instead of %s", height);
height = 65535;
}
nativeResizeView(width, height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public void onMapChanged(int change) {

void setMinZoom(double minZoom) {
if ((minZoom < MapboxConstants.MINIMUM_ZOOM) || (minZoom > MapboxConstants.MAXIMUM_ZOOM)) {
Timber.e("Not setting minZoomPreference, value is in unsupported range: " + minZoom);
Timber.e("Not setting minZoomPreference, value is in unsupported range: %s", minZoom);
return;
}
mapView.setMinZoom(minZoom);
Expand All @@ -358,7 +358,7 @@ void setMinZoom(double minZoom) {

void setMaxZoom(double maxZoom) {
if ((maxZoom < MapboxConstants.MINIMUM_ZOOM) || (maxZoom > MapboxConstants.MAXIMUM_ZOOM)) {
Timber.e("Not setting maxZoomPreference, value is in unsupported range: " + maxZoom);
Timber.e("Not setting maxZoomPreference, value is in unsupported range: %s", maxZoom);
return;
}
mapView.setMaxZoom(maxZoom);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.maps.widgets;

import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Camera;
import android.graphics.Canvas;
Expand Down Expand Up @@ -775,6 +776,7 @@ private static class GpsLocationListener implements LocationEngineListener {
locationSource = new WeakReference<>(locationEngine);
}

@SuppressLint("MissingPermission")
@Override
public void onConnected() {
MyLocationView locationView = userLocationView.get();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.net;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand All @@ -21,6 +22,7 @@
* Not public api.
*/
public class ConnectivityReceiver extends BroadcastReceiver {
@SuppressLint("StaticFieldLeak")
private static ConnectivityReceiver INSTANCE;

/**
Expand Down Expand Up @@ -82,7 +84,7 @@ public void deactivate() {
@Override
public void onReceive(Context context, Intent intent) {
boolean connected = isConnected(context);
Timber.v("Connected: " + connected);
Timber.v("Connected: %s", connected);

// Loop over listeners
for (ConnectivityListener listener : listeners) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.offline;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
Expand Down Expand Up @@ -40,6 +41,7 @@ public class OfflineManager {
private Handler handler;

// This object is implemented as a singleton
@SuppressLint("StaticFieldLeak")
private static OfflineManager instance;

// The application context
Expand Down Expand Up @@ -90,11 +92,11 @@ public interface CreateOfflineRegionCallback {
*/
private OfflineManager(Context context) {
this.context = context.getApplicationContext();
this.fileSource = FileSource.getInstance(context);
this.fileSource = FileSource.getInstance(this.context);
initialize(fileSource);

// Delete any existing previous ambient cache database
deleteAmbientDatabase(context);
deleteAmbientDatabase(this.context);
}

private void deleteAmbientDatabase(final Context context) {
Expand All @@ -107,10 +109,10 @@ public void run() {
File file = new File(path);
if (file.exists()) {
file.delete();
Timber.d("Old ambient cache database deleted to save space: " + path);
Timber.d("Old ambient cache database deleted to save space: %s", path);
}
} catch (Exception exception) {
Timber.e("Failed to delete old ambient cache database: ", exception);
Timber.e(exception, "Failed to delete old ambient cache database: ");
}
}
}).start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public static String getCachePath(Context context) {
MapboxConstants.KEY_META_DATA_SET_STORAGE_EXTERNAL,
MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL);
} catch (PackageManager.NameNotFoundException exception) {
Timber.e("Failed to read the package metadata: ", exception);
Timber.e(exception,"Failed to read the package metadata: ");
} catch (Exception exception) {
Timber.e("Failed to read the storage key: ", exception);
Timber.e(exception, "Failed to read the storage key: ");
}

String cachePath = null;
Expand All @@ -83,7 +83,7 @@ public static String getCachePath(Context context) {
// Try getting the external storage path
cachePath = context.getExternalFilesDir(null).getAbsolutePath();
} catch (NullPointerException exception) {
Timber.e("Failed to obtain the external storage path: ", exception);
Timber.e(exception, "Failed to obtain the external storage path: ");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public <S extends Stops> S getStopsAs() {
// noinspection unchecked
return (S) stops;
} catch (ClassCastException exception) {
Timber.e(String.format("Stops: %s is a different type: %s", stops.getClass(), exception));
Timber.e(exception, "Stops: %s is a different type: ", stops.getClass());
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@

<!-- Exposed styles -->
<public name="mapbox_style_mapbox_streets" type="string" />
<public name="mapbox_style_emerald" type="string" />
<public name="mapbox_style_outdoors" type="string" />
<public name="mapbox_style_light" type="string" />
<public name="mapbox_style_dark" type="string" />
<public name="mapbox_style_satellite" type="string" />
<public name="mapbox_style_satellite_streets" type="string" />
<public name="mapbox_style_traffic_day" type="string" />
<public name="mapbox_style_traffic_night" type="string" />

<!-- Exposed strings -->
<public name="mapbox_compassContentDescription" type="string" />
Expand Down

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:textAllCaps="true"
android:textIsSelectable="true"
android:textAppearance="?android:attr/textAppearanceButton"
android:textColor="@color/mapbox_blue"/>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textIsSelectable="true"
android:maxEms="17"
android:textColor="@android:color/black"
android:textSize="18sp"
Expand All @@ -34,13 +35,13 @@
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:textIsSelectable="true"
android:lineSpacingExtra="1dp"
android:maxEms="17"
android:textColor="@color/mapbox_gray"
android:textSize="14sp"/>

<TextView
android:id="@+id/infowindow_subdescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxEms="17"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"/>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
<color name="mapbox_gray">#7D7F80</color>
<color name="mapbox_gray_light">#EEEEEE</color>
<color name="mapbox_blue">#1E8CAB</color>
<color name="mapbox_my_location_ring">@color/mapbox_blue</color>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@
<resources>
<dimen name="mapbox_infowindow_tipview_width">8dp</dimen>
<dimen name="mapbox_infowindow_margin">8dp</dimen>
<dimen name="mapbox_infowindow_offset">-2dp</dimen>
<dimen name="mapbox_infowindow_line_width">1.5dp</dimen>
<dimen name="mapbox_attribution_icon_left_padding">@dimen/mapbox_two_dp</dimen>
<dimen name="mapbox_attribution_icon_top_padding">@dimen/mapbox_two_dp</dimen>
<dimen name="mapbox_attribution_icon_right_padding">@dimen/mapbox_two_dp</dimen>
<dimen name="mapbox_attribution_icon_bottom_padding">@dimen/mapbox_two_dp</dimen>
<dimen name="mapbox_two_dp">2dp</dimen>
<dimen name="mapbox_four_dp">4dp</dimen>
<dimen name="mapbox_eight_dp">8dp</dimen>
<dimen name="mapbox_ten_dp">10dp</dimen>
<dimen name="mapbox_sixteen_dp">16dp</dimen>
<dimen name="mapbox_ninety_two_dp">92dp</dimen>
<dimen name="mapbox_my_locationview_outer_circle">18dp</dimen>
</resources>
Loading