Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itznotabug/houseads
A simple Android library to cross promote your apps, websites!
https://github.com/itznotabug/houseads
android-house-ads android-library cross-promote-apps-websites cross-promotion custom-ads
Last synced: about 1 month ago
JSON representation
A simple Android library to cross promote your apps, websites!
- Host: GitHub
- URL: https://github.com/itznotabug/houseads
- Owner: ItzNotABug
- License: apache-2.0
- Created: 2018-09-25T12:14:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T14:27:12.000Z (almost 4 years ago)
- Last Synced: 2024-10-03T02:22:36.570Z (about 2 months ago)
- Topics: android-house-ads, android-library, cross-promote-apps-websites, cross-promotion, custom-ads
- Language: Kotlin
- Homepage:
- Size: 3.18 MB
- Stars: 44
- Watchers: 5
- Forks: 28
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HouseAds
A simple Android library (currently in early stage) to cross promote your apps, sites!
Currently includes a Dialog, Interstitial & a Customizable Native Ad fetched from a json stored on a site/server.
The library internals in the `dev` branch have been refactored to use `Coroutines` for background tasks & `Coil` for image processing.![Screenshot](https://github.com/ItzNotABug/HouseAds/blob/master/screenshots/screenshot.png)
Check out the Sample from Google Play -Primary Goal:
To keep it Simple & including Ads support like AdMob's Ad (Native, Interstitial, Dialog)
No!, No Banners!## Add Library to Project
Adding HouseAds in your App -
#### Gradle
```gradle
dependencies {
implementation 'com.lazygeniouz:houseAds:1.6'
}
```#### Maven
```mavencom.lazygeniouz
houseAds
1.6
pom```
## Json Array Schema
Json Array Schema that you'll have to put on a server:
```json
{
"apps":[{
"app_title": "App Name (Dialog)",
"app_desc": "Your App's description",
"app_icon": "https:// URL to Icon",
"app_header_image": "https:// URL to Header Image",
"app_uri": "http:// URL or Package Name - com.package.name",
"app_rating": "4.5",
"app_cta_text": "Install",
"app_price": "Free",
"app_adType": "dialog"
},{
"app_interstitial_url": "IMAGE URL",
"app_uri": "http:// URL or Package Name - com.package.name",
"app_adType": "interstitial"
},
{
"app_title": "App Name 3 (Native Ad)",
"app_desc": "Your App's Description",
"app_icon": "https:// URL to Icon",
"app_header_image": "https:// URL to Header Image",
"app_uri": "http:// URL or Package Name - com.package.name",
"app_rating": "4.5",
"app_cta_text": "Install",
"app_price": "Free",
"app_adType": "native"
}]
}
```
Some of the Assets like App Title, App Description, Icons & call to Action Text & Package Name are necessary!
## HouseAdsDialog
HouseAdsDialog is a Beautifully Styled Dialog which shows your Ad Assets like Header Image, App Icon, App Title & Description, Call to Action Button, Star Ratings & Price of the App.
The library internally uses `Palette API` to color the CTA Button by fetching the `Dominant Color` from Icon or Header Bitmap, whichever available.
Following is an example of HouseAdsDialog -
```java
HouseAdsDialog houseAds = new HouseAdsDialog(MainActivity.this, adUrl); //Context & URL to Json File.
houseAds.hideIfAppInstalled(true); //An App's Ad won't be shown if it is Installed on the Device.
houseAds.setCardCorners(100); // Set CardView's corner radius.
houseAds.setCtaCorner(100); //Set CTA Button's background radius.
houseAds.setForceLoadFresh(false); //Fetch Json everytime loadAds() is called, true by default, if set to false, Json File's Response is kept untill App is closed!
houseAds.showHeaderIfAvailable(false); //Show Header Image if available, true by default
houseAds.loadAds();
```
You can check if the Ad is loaded via -
```java
houseAds.isAdLoaded();
//returns true if loaded, false otherwise!
```
You can also add a Listener to HouseAdsDialog,
```java
houseAds.setAdListener(new AdListener() {
@Override
public void onAdLoadFailed() {}
@Override
public void onAdLoaded() {
//Show AdDialog as soon as it is loaded.
houseAds.showAd();
}
@Override
public void onAdClosed() {}
@Override
public void onAdShown() {}
@Override
public void onApplicationLeft() {}
});
```**
NOTE: You cannot Customize the Dialog except for the CardView's Corner Radius & CTA Button's Background Radius!**
Use `HouseAdsNative` instead :)## HouseAdsInterstitial
HouseAds also supports Interstitial Ad support just like AdMob has one!
HouseAdsInterstitial shows an Image fetched from your Json & navigates the User to Google Play if you specified a Package Name or the Website otherwise.
Following is an example of HouseAdsInterstitial -
```java
final HouseAdsInterstitial interstitial = new HouseAdsInterstitial(MainActivity.this, adUrl);
interstitial.setAdListener(new AdListener() {
@Override
public void onAdLoadFailed() {}
@Override
public void onAdLoaded() {}
@Override
public void onAdClosed() {}
@Override
public void onAdShown() {}
@Override
public void onApplicationLeft() {}
});
interstitial.loadAd();
```
Just like the HouseAdsDialog, you can check if the Interstitial is Loaded in the same way - `interstitial.isAdLoaded();`And show Interstitial like - `interstitial.show();`
## HouseAdsNative
HouseAdsNative is the type of Ad where you can pass your own views which includes Ad Assets just like AdMob's `NativeAdvancedUnified`.
The `setNativeAdView()` method in `HouseAdsNative` accepts two types of object to specify your View containing Ad Assets.
* HouseAdsNativeAdView Object,
* View Object containing Ad Assets.#### HouseAdsNativeView
If you use a `HouseAdsNativeView`, you'll need to pass the ids of the Assets (Icon, Call to Action View, Header Image etc) in a `HouseAdsNativeView` in their respective setter methods
and then set that object to the HouseAdsNative's `setNativeView()` .
Following is an example of `HouseAdsNativeView` -
```java
final Relativelayout adLayout = findViewById(R.id.adLayout); //Ad Assets inside a ViewGroup
adlayout.setVisibility(View.GONE):
```
```java
HouseAdsNativeView nativeView = new HouseAdsNativeView();
nativeView.setTitleView((TextView) findViewById(R.id.appinstall_headline));
nativeView.setDescriptionView((TextView) findViewById(R.id.appinstall_body));
nativeView.setIconView((ImageView) findViewById(R.id.appinstall_app_icon));
nativeView.setHeaderImageView((ImageView) findViewById(R.id.large));
nativeView.setCallToActionView(findViewById(R.id.appinstall_call_to_action));
nativeView.setPriceView((TextView) findViewById(R.id.price));
nativeView.setRatingsView((RatingBar) findViewById(R.id.rating));
```### Passing a View object in HouseAdsNative
You can also pass a View in the `setNativeAdView()`, however there are some rules you'll need to follow!
You'll need to use the same `IDs` for your Ad Assets mentioned below -
Ad Assets
IDs
Header Image
houseAds_header_image
App Icon
houseAds_app_icon
Title
houseAds_title
Description
houseAds_description
Price
houseAds_price
RatingBar
houseAds_rating
#### Loading HouseAdsNative
```java
HouseAdsNative houseAdsNative = new HouseAdsNative(NativeAdActivity.this, adUrl);
houseAdsNative.setNativeAdView(nativeView); //HouseAdsNativeView Object
houseAdsNative.setNativeNativeView(adLayout); //View Object
houseAdsNative.setNativeAdListener(new NativeAdListener() {
@Override
public void onAdLoaded() {
adLayout.setVisibility(View.VISIBLE);
}@Override
public void onAdLoadFailed() {
Toast.makeText(NativeAdActivity.this, "Failed", Toast.LENGTH_SHORT).show();
}
});
houseAdsNative.loadAds();
```
Check if NativeAd is loaded - `houseAdsNative.isAdLoaded();`
Additionally, you can define your own 'Call to Action' Button's action by using a `CallToActionListener`, for e.g.
```java
houseAdsNative.setCallToActionListener(new NativeAdListener.CallToActionListener() {
@Override
public void onCallToActionClicked(View view) {
//Do your Stuff!
}
});
```
**Note: If you don't implement the CTAListener, default implementation is used which navigates the user to PlayStore or Website depending on the passed argument to the "app_uri" object in json, when clicked.**
### Support by Starring the Library 😁