4
0
mirror of https://github.com/QuasarApp/QtAndroidTools.git synced 2025-04-30 06:54:31 +00:00

Finished add new tool and updated documentation

This commit is contained in:
FalsinSoft 2019-06-18 22:18:23 +02:00
parent 4b911ae156
commit 04fca8dc7d
7 changed files with 116 additions and 7 deletions

Binary file not shown.

After

(image error) Size: 117 KiB

Binary file not shown.

After

(image error) Size: 44 KiB

@ -44,6 +44,7 @@
<li><a href="#AppPermissions">AppPermissions</a></li>
<li><a href="#AdMobBanner">AdMobBanner</a></li>
<li><a href="#AdMobInterstitial">AdMobInterstitial</a></li>
<li><a href="#AdMobRewardedVideo">AdMobRewardedVideo</a></li>
<li><a href="#ApkInfo">ApkInfo</a></li>
<li><a href="#Images">Images</a></li>
<li><a href="#Notification">Notification</a></li>
@ -77,6 +78,7 @@
QTAT_NOTIFICATION \
QTAT_ADMOB_BANNER \
QTAT_ADMOB_INTERSTITIAL \
QTAT_ADMOB_REWARDED_VIDEO \
QTAT_PLAY_STORE</pre>
</li>
<li>In the <i>main()</i> body insert the call for initialize the library<br />
@ -321,9 +323,59 @@ ERROR_NO_FILL</pre>
interstitial.show()</pre>
<p>The interstitial have to be loaded before show and since loading is not immediate you have to preload a bit in advance before the time to show. You can follow the loading status through the item signals. Once revecied the <i>onLoaded</i> signal this mean your new interstitial is ready to be showed.</p>
<img src="images/admobinterstitial1.png">
<p>This type of ad have a button allowing the user to close it than you just have to wait about the user choice. Relember also in this case the ad window will go over the QML window and you can not paint anithing on top of it.</p>
<p>This type of ad have a button allowing the user to close it than you just have to wait about the user choice. Remember also in this case the ad window will go over the QML window and you can not paint anithing on top of it.</p>
<img src="images/admobinterstitial2.png">
</div>
<div class="section-txt" id="AdMobRewardedVideo">
<h3>AdMobRewardedVideo</h3>
<p>This tool allow to show AdMob Rewarded Video inside QML app.</p>
<p><b>IMPORTANT NOTE:</b> The current implementation of Rewarded Video API have to be used with only a single instance of the tool cause only one video can be loaded at a time. However a new set of API allowing multiple video loaded at the same time is going to be released (currently are still in beta). This is the reasons current implementation of this tool allow multiple instances. When the new API set will be released this tool code will be updated and change will be totally transparent from application side.</p>
<p>Official documentation about AdMob Rewarded Video is <a href="https://developers.google.com/admob/android/rewarded-video" target="_blank">here</a>, please <u>read before continue</u> for understand the options exported by the tool. Remember for allow video to be loaded your app need the following permissions:</p>
<pre class="prettyprint">android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.WRITE_EXTERNAL_STORAGE</pre>
<p>In add of this you have to install the AdMob required packages through Android SDK Manager. The packages you have to install are the following:</p>
<ul>
<li>Google Repository</li>
<li>Google Play services</li>
<li>Support Repository </li>
</ul>
<p>Than you have to add the following dependencies into your app gradle file:</p>
<pre class="prettyprint">dependencies {
....
implementation 'com.google.android.gms:play-services-ads:16.+'
}</pre>
<p>Rewarded Video ad show on full screen but you have to define the AdMob <i>unitId</i> using the item as follow:</p>
<pre class="prettyprint">QtAndroidAdMobRewardedVideo {
id: rewardedVideo
unitId: "admob-rewarded-video-unit-id"
}</pre>
<p>The <i>unitId</i> is the string generated when you create a new ad unit inside the AdMob site. It's used to identify the ad connected to your app. Using this id you can know how much you earn from this ad unit.</p>
<p>This item generate the following signals informing regarding the ad status:</p>
<pre class="prettyprint">onRewarded
onLoadError
onLoading
onLoaded
onOpened
onClosed
onStarted
onCompleted
onLeftApplication</pre>
<p>The only two signals passing a param is onLoadError and onRewarded. The first is called in case of problem in loading ad. The param is <i>errorId</i> and possible values are:</p>
<pre class="prettyprint">ERROR_INTERNAL
ERROR_NETWORK
ERROR_INVALID_REQUEST
ERROR_NO_FILL</pre>
<p>The record is called for inform about the rewarded values. It have two params, <i>type</i> and <i>amount</i>. Check the official documentation for know the value meaning.
<p>Item have two function as follow:</p>
<pre class="prettyprint">rewardedVideo.load()
rewardedVideo.show()</pre>
<p>The video have to be loaded before show and since loading is not immediate you have to preload a bit in advance before the time to show. You can follow the loading status through the item signals. Once revecied the <i>onLoaded</i> signal this mean your new video is ready to be played.</p>
<img src="images/rewardedvideo1.png">
<p>This type of ad have a button allowing the user to close it than you just have to wait about the user choice. Remember also in this case the ad window will go over the QML window and you can not paint anithing on top of it.</p>
<img src="images/rewardedvideo2.png">
<p>After the user close the video you'll receive the rewarded info.</p>
</div>
<div class="section-txt" id="Images">
<h3>Images</h3>
<p>This tool allow to retrieve the device albums and images</p>

@ -30,12 +30,21 @@
class QAndroidAdMobRewardedVideo : public QQuickItem
{
Q_PROPERTY(QString unitId READ getUnitId WRITE setUnitId)
Q_ENUMS(ERROR_TYPE)
Q_OBJECT
public:
QAndroidAdMobRewardedVideo(QQuickItem *parent = nullptr);
~QAndroidAdMobRewardedVideo();
enum ERROR_TYPE
{
ERROR_INTERNAL = 0,
ERROR_NETWORK,
ERROR_INVALID_REQUEST,
ERROR_NO_FILL
};
Q_INVOKABLE bool show();
Q_INVOKABLE bool load();

@ -70,7 +70,7 @@ public class AndroidAdMobRewardedVideo
public void show()
{
if(mRewardedVideoAd == null || mRewardedVideoAd.isLoaded() == false)
if(mRewardedVideoAd == null)
{
return;
}
@ -80,7 +80,10 @@ public class AndroidAdMobRewardedVideo
@Override
public void run()
{
mRewardedVideoAd.show();
if(mRewardedVideoAd.isLoaded() == true)
{
mRewardedVideoAd.show();
}
}
});
}
@ -207,9 +210,33 @@ public class AndroidAdMobRewardedVideo
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode)
{
int errorId = 0;
switch(errorCode)
{
case AdRequest.ERROR_CODE_INTERNAL_ERROR:
errorId = ERROR_INTERNAL;
break;
case AdRequest.ERROR_CODE_NETWORK_ERROR:
errorId = ERROR_NETWORK;
break;
case AdRequest.ERROR_CODE_INVALID_REQUEST:
errorId = ERROR_INVALID_REQUEST;
break;
case AdRequest.ERROR_CODE_NO_FILL:
errorId = ERROR_NO_FILL;
break;
}
rewardedVideoError(errorId);
}
}
private static final int ERROR_INTERNAL = 0;
private static final int ERROR_NETWORK = 1;
private static final int ERROR_INVALID_REQUEST = 2;
private static final int ERROR_NO_FILL = 3;
private static final int EVENT_LOADING = 0;
private static final int EVENT_LOADED = 1;
private static final int EVENT_OPENED = 2;

@ -11,9 +11,15 @@ Page {
QtAndroidAdMobRewardedVideo {
id: rewardedVideo
unitId: "ca-app-pub-3940256099942544/5224354917"
//onLoading: interstitialState.text = "Loading"
//onLoaded: interstitialState.text = "Loaded"
//onLoadError: interstitialState.text = "Error " + errorId
onRewarded: rewardedVideoResult.text = "Type: " + type + " - Amount: " + amount
onLoadError: rewardedVideoState.text = "Error " + errorId
onLoading: rewardedVideoState.text = "Loading"
onLoaded: rewardedVideoState.text = "Loaded"
onOpened: rewardedVideoState.text = "Opened"
onClosed: rewardedVideoState.text = "Closed"
onStarted: rewardedVideoState.text = "Started"
onCompleted: rewardedVideoState.text = "Completed"
onLeftApplication: rewardedVideoState.text = "LeftApplication"
}
Column {
@ -26,7 +32,7 @@ Page {
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
font.pixelSize: 15
text: "Rewarded video status"
text: "Rewarded Video status"
}
Label {
id: rewardedVideoState
@ -34,6 +40,18 @@ Page {
font.pixelSize: 13
text: "Not loaded"
}
Label {
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
font.pixelSize: 15
text: "Rewarded Video result"
}
Label {
id: rewardedVideoResult
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 13
text: "No reward yet"
}
Button {
anchors.horizontalCenter: parent.horizontalCenter

@ -19,6 +19,9 @@ Allow to show AdMob banner inside QML app
**AdMobInterstitial**
Allow to show AdMob interstitial inside QML app
**AdMobRewardedVideo**
Allow to show AdMob Rewarded Video inside QML app
**ApkInfo**
Return info about the apk containing the executed app