Skip to content

Commit

Permalink
General code health improvement for release (#1070)
Browse files Browse the repository at this point in the history
* Addressed issue of Dart conventions and Static analysis

* Suppressed deprecation warnings
  • Loading branch information
LTPhantom authored May 7, 2024
1 parent 43888a0 commit f051424
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/google_mobile_ads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ use [github's issue tracker](https://github.com/googleads/googleads-mobile-flutt

## License

[Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html)
[Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* Encodes and decodes values by reading from a ByteBuffer and writing to a ByteArrayOutputStream.
*/
class AdMessageCodec extends StandardMessageCodec {

// The type values below must be consistent for each platform.
private static final byte VALUE_AD_SIZE = (byte) 128;
private static final byte VALUE_AD_REQUEST = (byte) 129;
Expand Down Expand Up @@ -71,7 +70,11 @@ class AdMessageCodec extends StandardMessageCodec {

@NonNull Context context;
@NonNull final FlutterAdSize.AdSizeFactory adSizeFactory;
@Nullable private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@SuppressWarnings("deprecation")
@Nullable
private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@NonNull private final FlutterRequestAgentProvider requestAgentProvider;

AdMessageCodec(
Expand All @@ -95,6 +98,7 @@ void setContext(@NonNull Context context) {
this.context = context;
}

@SuppressWarnings("deprecation")
void setMediationNetworkExtrasProvider(
@Nullable MediationNetworkExtrasProvider mediationNetworkExtrasProvider) {
this.mediationNetworkExtrasProvider = mediationNetworkExtrasProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ FlutterAdManagerAdRequest build() {
}
}

@SuppressWarnings("deprecation")
private FlutterAdManagerAdRequest(
@Nullable List<String> keywords,
@Nullable String contentUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class FlutterAdRequest {
@Nullable private final List<String> neighboringContentUrls;
@Nullable private final Integer httpTimeoutMillis;
@Nullable private final String mediationExtrasIdentifier;
@Nullable private final MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@SuppressWarnings("deprecation")
@Nullable
private final MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@Nullable private final Map<String, String> adMobExtras;
@NonNull private final String requestAgent;
@Nullable private final List<FlutterMediationExtras> mediationExtras;
Expand All @@ -48,7 +52,11 @@ protected static class Builder {
@Nullable private List<String> neighboringContentUrls;
@Nullable private Integer httpTimeoutMillis;
@Nullable private String mediationExtrasIdentifier;
@Nullable private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@SuppressWarnings("deprecation")
@Nullable
private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@Nullable private Map<String, String> adMobExtras;
@NonNull private String requestAgent;

Expand Down Expand Up @@ -97,6 +105,7 @@ Builder setMediationNetworkExtrasIdentifier(@Nullable String mediationExtrasIden
}

@CanIgnoreReturnValue
@SuppressWarnings("deprecation")
Builder setMediationNetworkExtrasProvider(
@Nullable MediationNetworkExtrasProvider mediationNetworkExtrasProvider) {
this.mediationNetworkExtrasProvider = mediationNetworkExtrasProvider;
Expand Down Expand Up @@ -145,6 +154,7 @@ protected String getMediationExtrasIdentifier() {
return mediationExtrasIdentifier;
}

@SuppressWarnings("deprecation")
@Nullable
protected MediationNetworkExtrasProvider getMediationNetworkExtrasProvider() {
return mediationNetworkExtrasProvider;
Expand Down Expand Up @@ -180,6 +190,7 @@ FlutterAdRequest build() {
}
}

@SuppressWarnings("deprecation")
protected FlutterAdRequest(
@Nullable List<String> keywords,
@Nullable String contentUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ private static <T> T requireNonNull(T obj) {
@Nullable private AppStateNotifier appStateNotifier;
@Nullable private UserMessagingPlatformManager userMessagingPlatformManager;
private final Map<String, NativeAdFactory> nativeAdFactories = new HashMap<>();
@Nullable private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

@SuppressWarnings("deprecation")
@Nullable
private MediationNetworkExtrasProvider mediationNetworkExtrasProvider;

private final FlutterMobileAdsWrapper flutterMobileAds;
/**
* Public constructor for the plugin. Dependency initialization is handled in lifecycle methods
Expand Down
40 changes: 38 additions & 2 deletions packages/google_mobile_ads/lib/src/ad_containers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ class AdRequest {
this.neighboringContentUrls,
this.nonPersonalizedAds,
this.httpTimeoutMillis,
@deprecated this.mediationExtrasIdentifier,
@Deprecated('Use mediationExtras instead.')
this.mediationExtrasIdentifier,
this.extras,
this.mediationExtras});

Expand Down Expand Up @@ -230,7 +231,7 @@ class AdRequest {
/// to the ad request. This identifier will get passed to your platform-side
/// mediation extras factory class, allowing for additional customization
/// of network extras.
@deprecated
@Deprecated('Use mediationExtras instead.')
final String? mediationExtrasIdentifier;

/// Extras to pass to the AdMob adapter.
Expand All @@ -252,6 +253,18 @@ class AdRequest {
mapEquals<String, String>(extras, other.extras) &&
mediationExtras == other.mediationExtras;
}

@override
int get hashCode => Object.hash(
keywords,
contentUrl,
nonPersonalizedAds,
neighboringContentUrls,
httpTimeoutMillis,
//ignore: deprecated_member_use_from_same_package
mediationExtrasIdentifier,
extras,
mediationExtras);
}

/// Targeting info per the Ad Manager API.
Expand Down Expand Up @@ -303,6 +316,10 @@ class AdManagerAdRequest extends AdRequest {
other.customTargetingLists.toString() &&
publisherProvidedId == other.publisherProvidedId;
}

@override
int get hashCode =>
Object.hash(customTargeting, customTargetingLists, publisherProvidedId);
}

/// An [AdSize] with the given width and a Google-optimized height to create a banner ad.
Expand Down Expand Up @@ -554,6 +571,9 @@ class AdSize {
bool operator ==(Object other) {
return other is AdSize && width == other.width && height == other.height;
}

@override
int get hashCode => Object.hash(width, height);
}

/// The base class for all ads.
Expand Down Expand Up @@ -1353,6 +1373,9 @@ class ServerSideVerificationOptions {
userId == other.userId &&
customData == other.customData;
}

@override
int get hashCode => Object.hash(userId, customData);
}

/// A full-screen app open ad for the Google Mobile Ads Plugin.
Expand Down Expand Up @@ -1505,6 +1528,15 @@ class NativeAdOptions {
shouldRequestMultipleImages == other.shouldRequestMultipleImages &&
shouldReturnUrlsForImageAssets == other.shouldReturnUrlsForImageAssets;
}

@override
int get hashCode => Object.hash(
adChoicesPlacement,
mediaAspectRatio,
videoOptions,
requestCustomMuteThisAd,
shouldRequestMultipleImages,
shouldReturnUrlsForImageAssets);
}

/// Options for controlling video playback in supported ad formats.
Expand Down Expand Up @@ -1539,4 +1571,8 @@ class VideoOptions {
customControlsRequested == other.customControlsRequested &&
startMuted == other.startMuted;
}

@override
int get hashCode =>
Object.hash(clickToExpandRequested, customControlsRequested, startMuted);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ class AdMessageCodec extends StandardMessageCodec {
writeValue(buffer, value.orientationValue);
} else if (value is AnchoredAdaptiveBannerAdSize) {
buffer.putUint8(_valueAnchoredAdaptiveBannerAdSize);
var orientationValue;
String? orientationValue;
if (value.orientation != null) {
orientationValue = (value.orientation as Orientation).name;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/google_mobile_ads/lib/src/ump/consent_form_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ class ConsentFormImpl extends ConsentForm {
bool operator ==(Object other) {
return other is ConsentFormImpl && platformHash == other.platformHash;
}

@override
int get hashCode => platformHash.hashCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ConsentRequestParameters {
tagForUnderAgeOfConsent == other.tagForUnderAgeOfConsent &&
consentDebugSettings == other.consentDebugSettings;
}

@override
int get hashCode =>
Object.hash(tagForUnderAgeOfConsent, consentDebugSettings);
}

/// Debug settings to hardcode in test requests.
Expand All @@ -55,6 +59,9 @@ class ConsentDebugSettings {
debugGeography == other.debugGeography &&
listEquals(testIdentifiers, other.testIdentifiers);
}

@override
int get hashCode => Object.hash(debugGeography, testIdentifiers);
}

/// Debug values for testing geography.
Expand Down
3 changes: 3 additions & 0 deletions packages/google_mobile_ads/lib/src/ump/form_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ class FormError {
errorCode == other.errorCode &&
message == other.message;
}

@override
int get hashCode => Object.hash(errorCode, message);
}

0 comments on commit f051424

Please sign in to comment.