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

Commit 3b6d9fc

Browse files
Misc: Added bottom banner ad
Signed-off-by: sunilpaulmathew <[email protected]>
1 parent 17ff9a9 commit 3b6d9fc

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ dependencies {
5252
transitive = true
5353
}
5454
implementation "com.github.topjohnwu.libsu:core:2.5.1"
55+
implementation 'com.google.android.gms:play-services-ads:19.1.0'
5556
implementation 'com.google.android.material:material:1.2.0-alpha06'
5657
}

app/src/main/AndroidManifest.xml

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
android:requestLegacyExternalStorage="true"
2222
tools:targetApi="q" >
2323

24+
<meta-data
25+
android:name="com.google.android.gms.ads.APPLICATION_ID"
26+
android:value="ca-app-pub-7791710838910455~2723633709" />
27+
2428
<activity android:name="com.smartpack.kernelprofiler.MainActivity">
2529
<intent-filter>
2630
<action android:name="android.intent.action.MAIN" />

app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import androidx.cardview.widget.CardView;
2020
import androidx.viewpager.widget.ViewPager;
2121

22+
import com.google.android.gms.ads.AdRequest;
23+
import com.google.android.gms.ads.AdView;
2224
import com.smartpack.kernelprofiler.fragments.KPFragment;
2325
import com.smartpack.kernelprofiler.utils.CreateConfigActivity;
2426
import com.smartpack.kernelprofiler.utils.CreateProfileActivity;
@@ -54,8 +56,9 @@ public class MainActivity extends AppCompatActivity {
5456

5557
@Override
5658
protected void onCreate(@Nullable Bundle savedInstanceState) {
57-
// Initialize App Theme
59+
// Initialize App Theme & Google Ads
5860
Utils.initializeAppTheme(this);
61+
Utils.initializeGoogleAds(this);
5962
super.onCreate(savedInstanceState);
6063
setContentView(R.layout.activity_main);
6164

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

81+
if (Utils.isNotDonated(this)) {
82+
AdView mAdView = findViewById(R.id.adView);
83+
AdRequest adRequest = new AdRequest.Builder()
84+
.build();
85+
mAdView.loadAd(adRequest);
86+
}
87+
7888
mSettings = findViewById(R.id.settings_menu);
7989
mViewPager = findViewById(R.id.viewPagerID);
8090
AppCompatTextView textView = findViewById(R.id.unsupported_Text);

app/src/main/java/com/smartpack/kernelprofiler/utils/Utils.java

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import androidx.appcompat.app.AppCompatDelegate;
1616

17+
import com.google.android.gms.ads.MobileAds;
1718
import com.google.android.material.snackbar.Snackbar;
1819
import com.smartpack.kernelprofiler.BuildConfig;
1920
import com.smartpack.kernelprofiler.utils.root.RootFile;
@@ -60,6 +61,11 @@ public static void initializeAppTheme(Context context) {
6061
}
6162
}
6263

64+
public static void initializeGoogleAds(Context context) {
65+
if (!isNotDonated(context)) return;
66+
MobileAds.initialize(context, "ca-app-pub-7791710838910455~2723633709");
67+
}
68+
6369
static void startService(Context context, Intent intent) {
6470
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
6571
context.startForegroundService(intent);

app/src/main/res/layout/activity_main.xml

+11
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@
9595
android:padding="12dp"
9696
android:textColor="?android:attr/colorAccent"
9797
android:background="@color/black" />
98+
99+
<com.google.android.gms.ads.AdView
100+
xmlns:ads="http://schemas.android.com/apk/res-auto"
101+
android:id="@+id/adView"
102+
android:layout_width="wrap_content"
103+
android:layout_height="wrap_content"
104+
android:layout_gravity="bottom|center"
105+
ads:adSize="BANNER"
106+
android:background="@android:color/transparent"
107+
ads:adUnitId="ca-app-pub-7791710838910455/5158225354" >
108+
</com.google.android.gms.ads.AdView>
98109
</FrameLayout>
99110

100111
<include layout="@layout/rv_foreground_view" />

0 commit comments

Comments
 (0)