Skip to content

Commit

Permalink
Deprecate ShadowLocation for future removal.
Browse files Browse the repository at this point in the history
Shadows.shadowOf() is marked @deprecated for deprecated shadow classes.
  • Loading branch information
xian committed Jan 11, 2017
1 parent fbf415e commit 67aca2f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Expand Up @@ -99,6 +99,7 @@ void generate(String shadowPackage, PrintWriter writer) {
writer.println();

for (Map.Entry<TypeElement, TypeElement> entry : model.getShadowOfMap().entrySet()) {
final TypeElement shadowType = entry.getKey();
final TypeElement actualType = entry.getValue();
if (!actualType.getModifiers().contains(Modifier.PUBLIC)) {
continue;
Expand Down Expand Up @@ -132,7 +133,10 @@ void generate(String shadowPackage, PrintWriter writer) {
paramUseStr = paramUse.append('>').toString();
}
final String actual = model.getReferentFor(actualType) + paramUseStr;
final String shadow = model.getReferentFor(entry.getKey()) + paramUseStr;
final String shadow = model.getReferentFor(shadowType) + paramUseStr;
if (shadowType.getAnnotation(Deprecated.class) != null) {
writer.println(" @Deprecated");
}
writer.println(" public static " + paramDefStr + shadow + " shadowOf(" + actual + " actual) {");
writer.println(" return (" + shadow + ") ShadowExtractor.extract(actual);");
writer.println(" }");
Expand Down
Expand Up @@ -8,10 +8,14 @@
import org.robolectric.internal.ShadowExtractor;

/**
* Shadow for {@link android.location.Location}.
* Shadow for {@link Location}.
*
* @deprecated Use methods directly on {@link Location} instead. This class will be removed
* after Robolectric 3.2.
*/
@SuppressWarnings({"UnusedDeclaration"})
@Implements(Location.class)
@Deprecated
public class ShadowLocation {
private long time;
private String provider;
Expand Down Expand Up @@ -48,6 +52,7 @@ public void __constructor__(String provider) {
time = System.currentTimeMillis();
}

@Deprecated
@Implementation
public void set(Location l) {
time = l.getTime();
Expand All @@ -65,135 +70,160 @@ public void set(Location l) {
hasSpeed = l.hasSpeed();
}

@Deprecated
@Implementation
public String getProvider() {
return provider;
}

@Deprecated
@Implementation
public void setProvider(String provider) {
this.provider = provider;
}

@Deprecated
@Implementation
public long getTime() {
return time;
}

@Deprecated
@Implementation
public void setTime(long time) {
this.time = time;
}

@Deprecated
@Implementation
public float getAccuracy() {
return accuracy;
}

@Deprecated
@Implementation
public void setAccuracy(float accuracy) {
this.accuracy = accuracy;
this.hasAccuracy = true;
}

@Deprecated
@Implementation
public void removeAccuracy() {
this.accuracy = 0.0f;
this.hasAccuracy = false;
}

@Deprecated
@Implementation
public boolean hasAccuracy() {
return hasAccuracy;
}

@Deprecated
@Implementation
public double getAltitude() {
return altitude;
}

@Deprecated
@Implementation
public void setAltitude(double altitude) {
this.altitude = altitude;
this.hasAltitude = true;
}

@Deprecated
@Implementation
public void removeAltitude() {
this.altitude = 0.0d;
this.hasAltitude = false;
}

@Deprecated
@Implementation
public boolean hasAltitude() {
return hasAltitude;
}

@Deprecated
@Implementation
public float getBearing() {
return bearing;
}

@Deprecated
@Implementation
public void setBearing(float bearing) {
this.bearing = bearing;
this.hasBearing = true;
}

@Deprecated
@Implementation
public void removeBearing() {
this.bearing = 0.0f;
this.hasBearing = false;
}

@Deprecated
@Implementation
public boolean hasBearing() {
return hasBearing;
}


@Deprecated
@Implementation
public double getLatitude() {
return latitude;
}

@Deprecated
@Implementation
public void setLatitude(double latitude) {
this.latitude = latitude;
}

@Deprecated
@Implementation
public double getLongitude() {
return longitude;
}

@Deprecated
@Implementation
public void setLongitude(double longitude) {
this.longitude = longitude;
}

@Deprecated
@Implementation
public float getSpeed() {
return speed;
}

@Deprecated
@Implementation
public void setSpeed(float speed) {
this.speed = speed;
this.hasSpeed = true;
}

@Deprecated
@Implementation
public void removeSpeed() {
this.hasSpeed = false;
this.speed = 0.0f;
}

@Deprecated
@Implementation
public boolean hasSpeed() {
return hasSpeed;
}

@Deprecated
@Override @Implementation
public boolean equals(Object o) {
if (o == null) return false;
Expand All @@ -212,6 +242,7 @@ public boolean equals(Object o) {
return true;
}

@Deprecated
@Override @Implementation
public int hashCode() {
int result;
Expand All @@ -227,6 +258,7 @@ public int hashCode() {
return result;
}

@Deprecated
@Override @Implementation
public String toString() {
return "Location{" +
Expand All @@ -238,6 +270,7 @@ public String toString() {
'}';
}

@Deprecated
@HiddenApi @Implementation
public static void computeDistanceAndBearing(double lat1, double lon1,
double lat2, double lon2, float[] results) {
Expand Down Expand Up @@ -342,6 +375,7 @@ public static void computeDistanceAndBearing(double lat1, double lon1,

private static float[] distanceBetween;

@Deprecated
public static void setDistanceBetween(float[] distanceBetween) {
ShadowLocation.distanceBetween = distanceBetween;
}
Expand All @@ -366,6 +400,7 @@ public static void setDistanceBetween(float[] distanceBetween) {
*
* @throws IllegalArgumentException if results is null or has length &lt; 1
*/
@Deprecated
@Implementation
public static void distanceBetween(double startLatitude, double startLongitude,
double endLatitude, double endLongitude, float[] results) {
Expand All @@ -389,6 +424,7 @@ public static void distanceBetween(double startLatitude, double startLongitude,
* @param dest the destination location
* @return the approximate distance in meters
*/
@Deprecated
@Implementation
public float distanceTo(Location dest) {
// See if we already have the result
Expand Down Expand Up @@ -418,6 +454,7 @@ public float distanceTo(Location dest) {
* @param dest the destination location
* @return the initial bearing in degrees
*/
@Deprecated
@Implementation
public float bearingTo(Location dest) {
synchronized (mResults) {
Expand All @@ -437,11 +474,13 @@ public float bearingTo(Location dest) {
}
}

@Deprecated
@Implementation
public Bundle getExtras() {
return extras;
}

@Deprecated
@Implementation
public void setExtras(Bundle extras) {
this.extras = extras;
Expand Down

0 comments on commit 67aca2f

Please sign in to comment.