Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Misc: Added bottom banner ad
Browse files Browse the repository at this point in the history
Signed-off-by: sunilpaulmathew <[email protected]>
  • Loading branch information
sunilpaulmathew committed May 28, 2020
1 parent 17ff9a9 commit 3b6d9fc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ dependencies {
transitive = true
}
implementation "com.github.topjohnwu.libsu:core:2.5.1"
implementation 'com.google.android.gms:play-services-ads:19.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha06'
}
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
android:requestLegacyExternalStorage="true"
tools:targetApi="q" >

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-7791710838910455~2723633709" />

<activity android:name="com.smartpack.kernelprofiler.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import androidx.cardview.widget.CardView;
import androidx.viewpager.widget.ViewPager;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.smartpack.kernelprofiler.fragments.KPFragment;
import com.smartpack.kernelprofiler.utils.CreateConfigActivity;
import com.smartpack.kernelprofiler.utils.CreateProfileActivity;
Expand Down Expand Up @@ -54,8 +56,9 @@ public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
// Initialize App Theme
// Initialize App Theme & Google Ads
Utils.initializeAppTheme(this);
Utils.initializeGoogleAds(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Expand All @@ -75,6 +78,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
closeForeground();
});

if (Utils.isNotDonated(this)) {
AdView mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest);
}

mSettings = findViewById(R.id.settings_menu);
mViewPager = findViewById(R.id.viewPagerID);
AppCompatTextView textView = findViewById(R.id.unsupported_Text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import androidx.appcompat.app.AppCompatDelegate;

import com.google.android.gms.ads.MobileAds;
import com.google.android.material.snackbar.Snackbar;
import com.smartpack.kernelprofiler.BuildConfig;
import com.smartpack.kernelprofiler.utils.root.RootFile;
Expand Down Expand Up @@ -60,6 +61,11 @@ public static void initializeAppTheme(Context context) {
}
}

public static void initializeGoogleAds(Context context) {
if (!isNotDonated(context)) return;
MobileAds.initialize(context, "ca-app-pub-7791710838910455~2723633709");
}

static void startService(Context context, Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent);
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@
android:padding="12dp"
android:textColor="?android:attr/colorAccent"
android:background="@color/black" />

<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="wrap_content"
android:layout_gravity="bottom|center"
ads:adSize="BANNER"
android:background="@android:color/transparent"
ads:adUnitId="ca-app-pub-7791710838910455/5158225354" >
</com.google.android.gms.ads.AdView>
</FrameLayout>

<include layout="@layout/rv_foreground_view" />
Expand Down

0 comments on commit 3b6d9fc

Please sign in to comment.