Skip to content

Commit

Permalink
merge release 0.2.1 to master
Browse files Browse the repository at this point in the history
Next release:0.2.1
  • Loading branch information
ammarahm-ed authored Apr 21, 2020
2 parents 1f88fbb + eb66a98 commit 84e9403
Show file tree
Hide file tree
Showing 19 changed files with 291 additions and 186 deletions.
61 changes: 55 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ src="https://i.imgur.com/yX5GKhN.png"
/>
</div>


<div align="center">
<h2> 💫 Features</h2>
</div>
Expand Down Expand Up @@ -265,8 +264,8 @@ Setting this to true will load a placeholder ad (Not from Admob server) incase y

Time in ms after which a new ad should be requested from the server.

| Type | Required | Default | Platform |
| -------- | -------- | -------- | -------- |
| Type | Required | Default | Platform |
| -------- | -------- | ------------------- | -------- |
| `number` | no | 60000 ms (1 minute) | All |

#
Expand Down Expand Up @@ -308,7 +307,8 @@ User impression has been recorded
User has clicked on the ad.

## Children Views
The children views render different data recieved in the Ad from the server. All the values etc are assigned automatically, all you need to do is style the according to your design.

The children views render different data recieved in the Ad from the server. All the values etc are assigned automatically, all you need to do is style the according to your design.

**Note:** Do not set `nativeID` and `onLayout` prop on any of the Children views as these are used to register the views on Native iOS and Android.

Expand Down Expand Up @@ -506,11 +506,60 @@ import { MediaView } from "react-native-admob-native-ads";
}}
/>;
```
### props

#### `style:ViewStyle`

Style the outer `MediaView` Component.

## CallToActionView

Renders a CallToAction Button

```jsx
import { CallToActionView } from "react-native-admob-native-ads";

<CallToActionView
style={{
height: 45,
paddingHorizontal: 12,
backgroundColor: "purple",
justifyContent: "center",
alignItems: "center",
borderRadius: 5,
elevation: 10,
}}
textStyle={{ color: "white", fontSize: 14 }}
/>;
```
### props

#### `allCaps`

| Type | Required | Platform |
| --------- | -------- | -------- |
| `boolean` | no | All |

Whether all text should be in capital letters

### props

`style:ViewStyle`
style your media view.
#### `style:ViewStyle`

Style the outer `View` Component.

#### `textStyle:TextStyle`

Style the inner `Text` Component

#### `allCaps`

| Type | Required | Platform |
| --------- | -------- | -------- |
| `boolean` | no | All |

Whether all text should be in capital letters


## Contact & Support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import android.view.View;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableNativeArray;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.util.ReactFindViewUtil;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.RequestConfiguration;

Expand All @@ -31,12 +34,22 @@ public class RNAdMobNativeViewManager extends ViewGroupManager<RNNativeAdWrapper
public static final String EVENT_AD_LOADED = "onAdLoaded";
public static final String EVENT_AD_LEFT_APPLICATION = "onAdLeftApplication";
public static final String EVENT_UNIFIED_NATIVE_AD_LOADED = "onUnifiedNativeAdLoaded";

public static final String PROP_DELAY_AD_LOAD = "delayAdLoad";
public static final String PROP_TEST_DEVICES = "testDevices";
public static final String PROP_AD_UNIT_ID = "adUnitID";
public static final String PROP_MEDIA_VIEW = "mediaview";
public static final String PROP_REFRESH_INTERVAL = "refreshInterval";

public static final String PROP_HEADLINE_VIEW = "headline";
public static final String PROP_TAGLINE_VIEW = "tagline";
public static final String PROP_ADVERTISER_VIEW = "advertiser";
public static final String PROP_STORE_VIEW = "store";
public static final String PROP_IMAGE_VIEW = "image";
public static final String PROP_CALL_TO_ACTION_VIEW = "callToAction";
public static final String PROP_PRICE_VIEW = "price";
public static final String PROP_ICON_VIEW = "icon";
public static final String PROP_STAR_RATING_VIEW = "starrating";


@javax.annotation.Nullable
@Override
Expand Down Expand Up @@ -77,20 +90,108 @@ public void addView(RNNativeAdWrapper parent, View child, int index) {

}


@ReactProp(name = PROP_REFRESH_INTERVAL)
public void setRefreshInterval(final RNNativeAdWrapper view, final int interval) {

nativeAdView.setAdRefreshInterval(interval);
}

@ReactProp(name = PROP_DELAY_AD_LOAD)
public void setPropDelayAdLoad(final RNNativeAdWrapper view, final int delay) {

nativeAdView.setLoadWithDelay(delay);

}

@ReactProp(name = PROP_MEDIA_VIEW)
public void setMediaView(final RNNativeAdWrapper view, final int mediaViewId) {
public void setMediaView(final RNNativeAdWrapper view, final int id) {

nativeAdView.addMediaView(id);

}

@ReactProp(name = PROP_HEADLINE_VIEW)
public void setHeadlineView(final RNNativeAdWrapper v, final int id) {

nativeAdView.addMediaView(mediaViewId);
View view = nativeAdView.findViewById(id);
if (view != null)
nativeAdView.nativeAdView.setHeadlineView(view);

}

@ReactProp(name = PROP_TAGLINE_VIEW)
public void setPropTaglineView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setBodyView(view);

}

@ReactProp(name = PROP_ADVERTISER_VIEW)
public void setPropAdvertiserView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setAdvertiserView(view);

}

@ReactProp(name = PROP_IMAGE_VIEW)
public void setPropImageView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setImageView(view);

}

@ReactProp(name = PROP_ICON_VIEW)
public void setPropIconView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setIconView(view);

}

@ReactProp(name = PROP_STORE_VIEW)
public void setPropStoreView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setAdvertiserView(view);

}

@ReactProp(name = PROP_PRICE_VIEW)
public void setPropPriceView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setAdvertiserView(view);

}

@ReactProp(name = PROP_STAR_RATING_VIEW)
public void setPropStarRatingView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setAdvertiserView(view);

}

@ReactProp(name = PROP_CALL_TO_ACTION_VIEW)
public void setPropCallToActionView(final RNNativeAdWrapper v, final int id) {

View view = nativeAdView.findViewById(id);
if (view != null && nativeAdView.nativeAdView != null)
nativeAdView.nativeAdView.setAdvertiserView(view);

}


@ReactProp(name = PROP_TEST_DEVICES)
public void setPropTestDevices(final RNNativeAdWrapper view, final ReadableArray testDevices) {
ReadableNativeArray nativeArray = (ReadableNativeArray) testDevices;
Expand All @@ -103,11 +204,16 @@ public void setPropTestDevices(final RNNativeAdWrapper view, final ReadableArray
}



@ReactProp(name = PROP_AD_UNIT_ID)
public void setPropAdUnitId(final RNNativeAdWrapper view, final String adUnitId) {

nativeAdView.setAdUnitId(adUnitId);

}

@Override
public void onDropViewInstance(@NonNull RNNativeAdWrapper view) {
super.onDropViewInstance(view);
nativeAdView.removeHandler();
}
}
Loading

0 comments on commit 84e9403

Please sign in to comment.