Ad admob ads
This commit is contained in:
parent
004d3c94ca
commit
45f1c54eb1
7 changed files with 64 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion '28.0.2'
|
buildToolsVersion '28.0.3'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
|
|
|
@ -44,10 +44,14 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
resValue "string", "adbmob_ad_unit_id", "ca-app-pub-3940256099942544/6300978111"
|
||||||
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
|
resValue "string", "adbmob_ad_unit_id", "ca-app-pub-3319579963502409/4464724664"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flavorDimensions "platform"
|
flavorDimensions "platform"
|
||||||
|
@ -98,5 +102,10 @@ dependencies {
|
||||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
|
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
|
||||||
implementation "ch.acra:acra-http:$acraVersion"
|
implementation "ch.acra:acra-http:$acraVersion"
|
||||||
|
implementation 'com.google.firebase:firebase-core:16.0.7'
|
||||||
|
implementation 'com.google.firebase:firebase-ads:17.1.3'
|
||||||
|
implementation 'com.android.billingclient:billing:1.2'
|
||||||
samsungImplementation project(":IAP5Helper")
|
samsungImplementation project(":IAP5Helper")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
tools:ignore="AllowBackup"
|
tools:ignore="AllowBackup"
|
||||||
tools:targetApi="n">
|
tools:targetApi="n">
|
||||||
|
<meta-data
|
||||||
|
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||||
|
android:value="@string/admob_app_id" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".view.activity.SplashActivity"
|
android:name=".view.activity.SplashActivity"
|
||||||
android:theme="@style/AppTheme.Splash"
|
android:theme="@style/AppTheme.Splash"
|
||||||
|
|
|
@ -16,6 +16,11 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.ads.mediation.admob.AdMobAdapter;
|
||||||
|
import com.google.android.gms.ads.AdListener;
|
||||||
|
import com.google.android.gms.ads.AdRequest;
|
||||||
|
import com.google.android.gms.ads.AdView;
|
||||||
|
import com.google.android.gms.ads.MobileAds;
|
||||||
import com.wbrawner.simplemarkdown.MarkdownApplication;
|
import com.wbrawner.simplemarkdown.MarkdownApplication;
|
||||||
import com.wbrawner.simplemarkdown.R;
|
import com.wbrawner.simplemarkdown.R;
|
||||||
import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter;
|
import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter;
|
||||||
|
@ -44,6 +49,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
DisableableViewPager pager;
|
DisableableViewPager pager;
|
||||||
@BindView(R.id.layout_tab)
|
@BindView(R.id.layout_tab)
|
||||||
TabLayout tabLayout;
|
TabLayout tabLayout;
|
||||||
|
@BindView(R.id.adView)
|
||||||
|
AdView adView;
|
||||||
|
|
||||||
private boolean shouldAutoSave = true;
|
private boolean shouldAutoSave = true;
|
||||||
private NewFileHandler newFileHandler;
|
private NewFileHandler newFileHandler;
|
||||||
|
@ -68,6 +75,25 @@ public class MainActivity extends AppCompatActivity
|
||||||
if (getIntent().getBooleanExtra(Constants.EXTRA_EXPLORER, false)) {
|
if (getIntent().getBooleanExtra(Constants.EXTRA_EXPLORER, false)) {
|
||||||
requestFileOp(Constants.REQUEST_OPEN_FILE);
|
requestFileOp(Constants.REQUEST_OPEN_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Change this to only load for users who haven't paid to remove ads
|
||||||
|
if (true) {
|
||||||
|
MobileAds.initialize(this, getString(R.string.admob_app_id));
|
||||||
|
Bundle extras = new Bundle();
|
||||||
|
extras.putString("npa", "1");
|
||||||
|
AdRequest adRequest = new AdRequest.Builder()
|
||||||
|
.addTestDevice("7045AFE2F8D6C6386983BAF3D2A2377E")
|
||||||
|
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
|
||||||
|
.build();
|
||||||
|
adView.setAdListener(new AdListener() {
|
||||||
|
@Override
|
||||||
|
public void onAdFailedToLoad(int i) {
|
||||||
|
super.onAdFailedToLoad(i);
|
||||||
|
ACRA.getErrorReporter().handleException(new RuntimeException("Failed to load ads: " + i), false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
adView.loadAd(adRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<com.wbrawner.simplemarkdown.view.DisableableViewPager
|
<com.wbrawner.simplemarkdown.view.DisableableViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/adView">
|
||||||
<android.support.design.widget.TabLayout
|
<android.support.design.widget.TabLayout
|
||||||
android:id="@+id/layout_tab"
|
android:id="@+id/layout_tab"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -26,4 +30,15 @@
|
||||||
</android.support.design.widget.TabLayout>
|
</android.support.design.widget.TabLayout>
|
||||||
</com.wbrawner.simplemarkdown.view.DisableableViewPager>
|
</com.wbrawner.simplemarkdown.view.DisableableViewPager>
|
||||||
|
|
||||||
</LinearLayout>
|
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/adView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
ads:adSize="SMART_BANNER"
|
||||||
|
ads:adUnitId="@string/adbmob_ad_unit_id"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/pager"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"></com.google.android.gms.ads.AdView>
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||||
<string name="app_name">Simple Markdown</string>
|
<string name="app_name">Simple Markdown</string>
|
||||||
<string name="app_name_short">Markdown</string>
|
<string name="app_name_short">Markdown</string>
|
||||||
|
|
||||||
|
<string name="admob_app_id">ca-app-pub-3319579963502409~4576405307</string>
|
||||||
|
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="action_help">Help</string>
|
<string name="action_help">Help</string>
|
||||||
<string name="action_edit">Edit</string>
|
<string name="action_edit">Edit</string>
|
||||||
|
|
|
@ -7,8 +7,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
classpath 'com.android.tools.build:gradle:3.3.1'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
classpath 'com.google.gms:google-services:4.2.0'
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue