diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java | 151 |
1 files changed, 61 insertions, 90 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java index 324aea16ca..91e8c0f6f3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java @@ -1,86 +1,85 @@ package com.mapbox.mapboxsdk.module.telemetry; -import android.content.Context; +import android.annotation.SuppressLint; import android.os.Parcel; -import android.os.Parcelable; -import com.google.gson.annotations.SerializedName; import com.mapbox.android.telemetry.Event; -import com.mapbox.android.telemetry.TelemetryUtils; -class MapClickEvent extends Event implements Parcelable { - private static final String MAP_CLICK = "map.click"; - - @SerializedName("event") - private final String event; - @SerializedName("created") - private String created; - @SerializedName("gesture") +/** + * Event that represents users' gestures on map, for the details of gestures, + * please refer to {@link com.mapbox.mapboxsdk.constants.TelemetryConstants} + */ +@SuppressLint("ParcelCreator") +class MapClickEvent extends Event { + private final String event = "map.click"; + private final String created; private final String gesture; - @SerializedName("lat") - private double latitude; - @SerializedName("lng") - private double longitude; - @SerializedName("zoom") - private double zoom; - @SerializedName("orientation") - private String orientation = null; - @SerializedName("batteryLevel") - private Integer batteryLevel; - @SerializedName("pluggedIn") - private Boolean pluggedIn; - @SerializedName("carrier") - private String carrier = null; - @SerializedName("cellularNetworkType") - private String cellularNetworkType; - @SerializedName("wifi") - private Boolean wifi = null; - - MapClickEvent(MapState mapState) { - this.event = MAP_CLICK; + private final String cellularNetworkType; + private final String carrier; + private final String orientation; + private final double latitude; + private final double longitude; + private final double zoom; + private final int batteryLevel; + private final boolean pluggedIn; + private final boolean wifi; + + MapClickEvent(PhoneState phoneState, MapState mapState) { this.gesture = mapState.getGesture(); this.latitude = mapState.getLatitude(); this.longitude = mapState.getLongitude(); this.zoom = mapState.getZoom(); - this.created = TelemetryUtils.obtainCurrentDate(); - this.batteryLevel = 0; - this.pluggedIn = false; - this.cellularNetworkType = ""; + this.created = phoneState.getCreated(); + this.batteryLevel = phoneState.getBatteryLevel(); + this.pluggedIn = phoneState.isPluggedIn(); + this.cellularNetworkType = phoneState.getCellularNetworkType(); + this.orientation = phoneState.getOrientation(); + this.carrier = phoneState.getCarrier(); + this.wifi = phoneState.isWifi(); + } + + String getCreated() { + return created; + } + + String getGesture() { + return gesture; + } + + String getCellularNetworkType() { + return cellularNetworkType; } - MapClickEvent setDeviceInfo(Context context) { - this.batteryLevel = TelemetryUtils.obtainBatteryLevel(context); - this.pluggedIn = TelemetryUtils.isPluggedIn(context); - this.cellularNetworkType = TelemetryUtils.obtainCellularNetworkType(context); - return this; + String getCarrier() { + return carrier; } - void setOrientation(String orientation) { - this.orientation = orientation; + String getOrientation() { + return orientation; } - void setCarrier(String carrier) { - this.carrier = carrier; + double getLatitude() { + return latitude; } - void setWifi(boolean wifi) { - this.wifi = wifi; + double getLongitude() { + return longitude; } - private MapClickEvent(Parcel in) { - event = in.readString(); - created = in.readString(); - gesture = in.readString(); - latitude = in.readDouble(); - longitude = in.readDouble(); - zoom = in.readDouble(); - orientation = in.readString(); - batteryLevel = in.readInt(); - pluggedIn = in.readByte() != 0x00; - carrier = in.readString(); - cellularNetworkType = in.readString(); - byte wifiVal = in.readByte(); - wifi = wifiVal == 0x02 ? null : wifiVal != 0x00; + double getZoom() { + return zoom; + } + + int getBatteryLevel() { + return batteryLevel; + } + + boolean isPluggedIn() { + return pluggedIn; + } + + boolean isWifi() { + return wifi; } @Override @@ -90,33 +89,5 @@ class MapClickEvent extends Event implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeString(event); - dest.writeString(created); - dest.writeString(gesture); - dest.writeDouble(latitude); - dest.writeDouble(longitude); - dest.writeDouble(zoom); - dest.writeString(orientation); - dest.writeInt(batteryLevel); - dest.writeByte((byte) (pluggedIn ? 0x01 : 0x00)); - dest.writeString(carrier); - dest.writeString(cellularNetworkType); - if (wifi == null) { - dest.writeByte((byte) (0x02)); - } else { - dest.writeByte((byte) (wifi ? 0x01 : 0x00)); - } } - - public static final Creator<MapClickEvent> CREATOR = new Creator<MapClickEvent>() { - @Override - public MapClickEvent createFromParcel(Parcel in) { - return new MapClickEvent(in); - } - - @Override - public MapClickEvent[] newArray(int size) { - return new MapClickEvent[size]; - } - }; } |