From 0c89a3506049e918566f449198a5c607c7dbdc4c Mon Sep 17 00:00:00 2001 From: Boris Timofeev Date: Tue, 17 Jan 2017 16:07:54 +0300 Subject: [PATCH] Remove ads from the app --- app/build.gradle | 1 - .../emunix/unipatcher/ad/AdMobController.java | 97 ------------------- .../emunix/unipatcher/ad/AdsController.java | 31 ------ .../ui/activity/FilePickerActivity.java | 40 -------- .../unipatcher/ui/activity/MainActivity.java | 43 -------- .../main/res/layout/activity_file_picker.xml | 11 --- app/src/main/res/layout/activity_main.xml | 32 +++++- .../main/res/layout/activity_main_content.xml | 51 ---------- 8 files changed, 29 insertions(+), 277 deletions(-) delete mode 100644 app/src/main/java/org/emunix/unipatcher/ad/AdMobController.java delete mode 100644 app/src/main/java/org/emunix/unipatcher/ad/AdsController.java delete mode 100644 app/src/main/res/layout/activity_main_content.xml diff --git a/app/build.gradle b/app/build.gradle index ec97f24..af89d0c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,6 @@ dependencies { compile 'com.android.support:preference-v14:25.1.0' compile 'com.android.support:recyclerview-v7:25.1.0' compile 'com.android.support:design:25.1.0' - compile 'com.google.firebase:firebase-ads:10.0.1' compile 'com.google.firebase:firebase-core:10.0.1' compile 'com.google.firebase:firebase-crash:10.0.1' compile 'com.anjlab.android.iab.v3:library:1.0.38' diff --git a/app/src/main/java/org/emunix/unipatcher/ad/AdMobController.java b/app/src/main/java/org/emunix/unipatcher/ad/AdMobController.java deleted file mode 100644 index 0abc8f9..0000000 --- a/app/src/main/java/org/emunix/unipatcher/ad/AdMobController.java +++ /dev/null @@ -1,97 +0,0 @@ -/* -Copyright (C) 2014 Boris Timofeev - -This file is part of UniPatcher. - -UniPatcher is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -UniPatcher is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with UniPatcher. If not, see . -*/ - -package org.emunix.unipatcher.ad; - -import android.content.Context; -import android.view.View; -import android.widget.FrameLayout; - -import com.google.android.gms.ads.AdListener; -import com.google.android.gms.ads.AdRequest; -import com.google.android.gms.ads.AdView; - -import org.emunix.unipatcher.Globals; - -public class AdMobController implements AdsController { - - private static final String ADMOB_ID = "ca-app-pub-2445378722408015/8831379284"; - private AdView adView; - private final Context context; - - public AdMobController(Context c, FrameLayout layout) { - context = c; - createView(layout); - } - - public void createView(FrameLayout layout) { - adView = new AdView(context); - adView.setAdSize(com.google.android.gms.ads.AdSize.SMART_BANNER); - adView.setAdUnitId(ADMOB_ID); - AdRequest adRequest = new AdRequest.Builder() - .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) - .addTestDevice("018B7216B142ABE97F9BFCD880C02EBC") // htc one v - .addTestDevice("64F8D0EE579BA448E833172DB2D91CBB") // lg nexus 5 - .build(); - adView.setAdListener(new AdListener() { - @Override - public void onAdLoaded() { - super.onAdLoaded(); - if (Globals.isFullVersion()) { - adView.setVisibility(View.GONE); - } - } - @Override - public void onAdOpened() { - } - }); - adView.loadAd(adRequest); - layout.addView(adView); - } - - public void show(boolean show) { - if (adView != null) { - if (!show) { - adView.setVisibility(View.GONE); - } else if (!Globals.isFullVersion()) { - adView.setVisibility(View.VISIBLE); - } - } - } - - public void pause() { - if (adView != null) { - adView.pause(); - } - } - - public void resume() { - if (adView != null) { - adView.resume(); - } - } - - public void start() {} - - public void destroy() { - if (adView != null) { - adView.destroy(); - } - } -} diff --git a/app/src/main/java/org/emunix/unipatcher/ad/AdsController.java b/app/src/main/java/org/emunix/unipatcher/ad/AdsController.java deleted file mode 100644 index ff690a3..0000000 --- a/app/src/main/java/org/emunix/unipatcher/ad/AdsController.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright (C) 2014 Boris Timofeev - -This file is part of UniPatcher. - -UniPatcher is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -UniPatcher is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with UniPatcher. If not, see . -*/ - -package org.emunix.unipatcher.ad; - -import android.widget.FrameLayout; - -interface AdsController { - void createView(FrameLayout layout); - void show(boolean show); - void start(); - void destroy(); - void resume(); - void pause(); -} diff --git a/app/src/main/java/org/emunix/unipatcher/ui/activity/FilePickerActivity.java b/app/src/main/java/org/emunix/unipatcher/ui/activity/FilePickerActivity.java index 85835c1..56d524b 100644 --- a/app/src/main/java/org/emunix/unipatcher/ui/activity/FilePickerActivity.java +++ b/app/src/main/java/org/emunix/unipatcher/ui/activity/FilePickerActivity.java @@ -34,7 +34,6 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; -import android.widget.FrameLayout; import android.widget.TextView; import android.widget.Toast; @@ -42,10 +41,8 @@ import com.afollestad.materialdialogs.MaterialDialog; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; -import org.emunix.unipatcher.Globals; import org.emunix.unipatcher.R; import org.emunix.unipatcher.Utils; -import org.emunix.unipatcher.ad.AdMobController; import org.emunix.unipatcher.ui.adapter.FilePickerAdapter; import java.io.File; @@ -63,7 +60,6 @@ import java.util.zip.CRC32; public class FilePickerActivity extends AppCompatActivity implements FilePickerAdapter.OnItemClickListener { - private AdMobController ad; private RecyclerView list; private FilePickerAdapter listAdapter; private TextView permissionErrorText; @@ -118,14 +114,6 @@ public class FilePickerActivity extends AppCompatActivity implements FilePickerA listAdapter.setOnItemClickListener(this); requestStoragePermission(); - - // Load ads - if (!Globals.isFullVersion()) { - FrameLayout adView = (FrameLayout) findViewById(R.id.adView); - ad = new AdMobController(this, adView); - if (!Utils.isOnline(this)) - ad.show(false); - } } @Override @@ -259,30 +247,6 @@ public class FilePickerActivity extends AppCompatActivity implements FilePickerA savedInstanceState.putString("currentDirectory", currentDir.getAbsolutePath()); } - @Override - public void onPause() { - if (ad != null) { - ad.pause(); - } - super.onPause(); - } - - @Override - public void onResume() { - super.onResume(); - if (ad != null) { - ad.resume(); - } - } - - @Override - public void onDestroy() { - if (ad != null) { - ad.destroy(); - } - super.onDestroy(); - } - private void requestStoragePermission() { if (!Utils.hasStoragePermission(this)) { ActivityCompat.requestPermissions(this, @@ -311,13 +275,9 @@ public class FilePickerActivity extends AppCompatActivity implements FilePickerA private void showPermissionError(boolean on) { if (on) { list.setVisibility(View.GONE); - if (ad != null) - ad.show(false); permissionErrorText.setVisibility(View.VISIBLE); } else { permissionErrorText.setVisibility(View.GONE); - if (ad != null) - ad.show(true); list.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java b/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java index 50cf5a0..8c2ef59 100644 --- a/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java +++ b/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java @@ -19,11 +19,9 @@ along with UniPatcher. If not, see . package org.emunix.unipatcher.ui.activity; -import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; -import android.os.Handler; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.NavigationView; import android.support.v4.app.Fragment; @@ -39,7 +37,6 @@ import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.view.View; -import android.widget.FrameLayout; import android.widget.Toast; import com.anjlab.android.iab.v3.BillingProcessor; @@ -49,8 +46,6 @@ import com.google.firebase.analytics.FirebaseAnalytics; import org.emunix.unipatcher.BuildConfig; import org.emunix.unipatcher.Globals; import org.emunix.unipatcher.R; -import org.emunix.unipatcher.Utils; -import org.emunix.unipatcher.ad.AdMobController; import org.emunix.unipatcher.ui.dialog.RateThisApp; import org.emunix.unipatcher.ui.fragment.ActionFragment; import org.emunix.unipatcher.ui.fragment.PatchingFragment; @@ -69,15 +64,12 @@ public class MainActivity extends AppCompatActivity private static final String SKU_REMOVE_ADS = "ad"; private boolean readyToPurchase = false; private BillingProcessor bp; - private AdMobController ad; private FirebaseAnalytics firebaseAnalytics; - private Context context; @Override protected void onCreate(Bundle savedInstanceState) { setTheme(); super.onCreate(savedInstanceState); - context = this; setContentView(R.layout.activity_main); firebaseAnalytics = FirebaseAnalytics.getInstance(this); @@ -145,20 +137,6 @@ public class MainActivity extends AppCompatActivity } }); RateThisApp.launch(this); - - // Load ads - if (!Globals.isFullVersion()) { - Handler adHandler = new Handler(); - adHandler.postDelayed(new Runnable() { - @Override - public void run() { - FrameLayout adView = (FrameLayout) findViewById(R.id.adView); - ad = new AdMobController(context, adView); - if (!Utils.isOnline(context)) - ad.show(false); - } - }, 1000); - } } private void setTheme() { @@ -257,8 +235,6 @@ public class MainActivity extends AppCompatActivity private void setFullVersion() { Globals.setFullVersion(); - if (ad != null) - ad.show(false); } private void complain(String message) { @@ -266,30 +242,11 @@ public class MainActivity extends AppCompatActivity Toast.makeText(this, message, Toast.LENGTH_LONG).show(); } - @Override - public void onPause() { - if (ad != null) { - ad.pause(); - } - super.onPause(); - } - - @Override - public void onResume() { - super.onResume(); - if (ad != null) { - ad.resume(); - } - } - @Override public void onDestroy() { if (bp != null) { bp.release(); } - if (ad != null) { - ad.destroy(); - } super.onDestroy(); } } diff --git a/app/src/main/res/layout/activity_file_picker.xml b/app/src/main/res/layout/activity_file_picker.xml index 1be3403..6ddd0fb 100644 --- a/app/src/main/res/layout/activity_file_picker.xml +++ b/app/src/main/res/layout/activity_file_picker.xml @@ -10,15 +10,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index de8725a..7cc3f55 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -9,10 +9,36 @@ android:fitsSystemWindows="true" tools:openDrawer="start"> - + android:layout_height="match_parent" + android:fitsSystemWindows="true"> + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - -