Skip to content

Commit

Permalink
Switch to AdMob
Browse files Browse the repository at this point in the history
& also remove loading message

Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
  • Loading branch information
sunilpaulmathew committed Sep 2, 2020
1 parent 3bff11e commit af249f3
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.facebook.android:audience-network-sdk:5.8.0'
implementation "com.github.topjohnwu.libsu:core:3.0.2"
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
implementation 'com.google.android.gms:play-services-ads:19.3.0'
implementation 'com.google.android.material:material:1.3.0-alpha02'
implementation 'com.mattprecious.swirl:swirl:1.3.0'
implementation 'com.squareup.picasso:picasso:2.71828'
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
android:resource="@xml/shortcuts" />
</activity>

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

<activity
android:name=".activities.StartActivityMaterial" android:label="@string/smartpack"
android:enabled="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.facebook.ads.AudienceNetworkAds;
import com.google.android.gms.ads.MobileAds;

import com.smartpack.kernelmanager.BuildConfig;
import com.smartpack.kernelmanager.R;
import com.smartpack.kernelmanager.database.tools.profiles.Profiles;
Expand All @@ -38,10 +39,10 @@
import com.smartpack.kernelmanager.utils.Prefs;
import com.smartpack.kernelmanager.utils.Utils;
import com.smartpack.kernelmanager.utils.kernel.battery.Battery;
import com.smartpack.kernelmanager.utils.kernel.cpu.boost.CPUBoost;
import com.smartpack.kernelmanager.utils.kernel.cpu.CPUFreq;
import com.smartpack.kernelmanager.utils.kernel.cpu.MSMPerformance;
import com.smartpack.kernelmanager.utils.kernel.cpu.Temperature;
import com.smartpack.kernelmanager.utils.kernel.cpu.boost.CPUBoost;
import com.smartpack.kernelmanager.utils.kernel.cpuhotplug.Hotplug;
import com.smartpack.kernelmanager.utils.kernel.cpuhotplug.QcomBcl;
import com.smartpack.kernelmanager.utils.kernel.cpuvoltage.Voltage;
Expand Down Expand Up @@ -74,9 +75,9 @@ public class MainActivity extends BaseActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Initialize FaceBook Ads
// Initialize Google Ads
if (Prefs.getBoolean("allow_ads", true, this)) {
AudienceNetworkAds.initialize(this);
MobileAds.initialize(this, "ca-app-pub-7791710838910455~4931988555");
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.facebook.ads.AdSize;
import com.facebook.ads.AdView;
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.material.navigation.NavigationView;
import com.smartpack.kernelmanager.R;
import com.smartpack.kernelmanager.fragments.BaseFragment;
Expand Down Expand Up @@ -270,12 +268,16 @@ private void init(Bundle savedInstanceState) {

// Initialize Banner Ad
if (Prefs.getBoolean("allow_ads", true, this)) {
AppCompatTextView statusText = findViewById(R.id.ad_status_text);
AdView mAdView = new AdView(this, "1189034858133626_1189035694800209", AdSize.BANNER_HEIGHT_50);
LinearLayout adContainer = findViewById(R.id.banner_container);
adContainer.addView(mAdView);
mAdView.loadAd();
statusText.setVisibility(View.VISIBLE);
AdView mAdView = findViewById(R.id.adView);
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Utils.mAdLoaded = true;
}
});
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest);
}

if (savedInstanceState != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
mHandler = new Handler();

mRecyclerViewLayout = mRootView.findViewById(R.id.recyclerview_parent);
if (!Prefs.getBoolean("allow_ads", true, getActivity())) {
if (!Prefs.getBoolean("allow_ads", true, getActivity()) || !Utils.mAdLoaded) {
mRecyclerViewLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT));
RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) mRecyclerViewLayout.getLayoutParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
*/
public class Utils {

public static boolean mAdLoaded = false;
public static boolean mBattery = false;
public static boolean mCPU = false;
public static boolean mCPUTimes = false;
Expand Down
25 changes: 8 additions & 17 deletions app/src/main/res/layout/activity_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/ad_status_text"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_horizontal"
android:layout_gravity="bottom|center_horizontal"
android:textSize="12sp"
android:padding="12dp"
android:visibility="gone"
android:hint="@string/loading"
android:textColorHint="?attr/colorAccent" />

<LinearLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
<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:orientation="vertical"
android:gravity="center_horizontal"
android:layout_gravity="bottom|center_horizontal" />
android:layout_gravity="bottom|center_horizontal"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-7791710838910455/9992743545">
</com.google.android.gms.ads.AdView>
</FrameLayout>

<com.google.android.material.navigation.NavigationView
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<string name="no_root">No root</string>
<string name="no_busybox">No busybox</string>
<string name="open">Open %s</string>
<string name="loading">Loading…</string>

<!-- Security -->
<string name="password">Password</string>
Expand Down

0 comments on commit af249f3

Please sign in to comment.