remove google play dependencies and some jars

This commit is contained in:
Marcus Hoffmann 2020-03-12 16:57:54 +01:00
parent 22448df392
commit 6fa4bfb05f
17 changed files with 4 additions and 589 deletions

View File

@ -74,7 +74,7 @@ dependencies {
implementation "com.android.support:support-v4:${versions.supportLib}" implementation "com.android.support:support-v4:${versions.supportLib}"
implementation "com.android.support:appcompat-v7:${versions.supportLib}" implementation "com.android.support:appcompat-v7:${versions.supportLib}"
implementation "com.android.support:design:${versions.supportLib}" implementation "com.android.support:design:${versions.supportLib}"
implementation ':measure:' implementation "javax.measure:jsr-275:0.9.1"
implementation ':square-otto:1.3.9-SNAPSHOT' implementation ':square-otto:1.3.9-SNAPSHOT'
annotationProcessor ':square-otto:1.3.9-SNAPSHOT' annotationProcessor ':square-otto:1.3.9-SNAPSHOT'
annotationProcessor ':square-otto-compiler:1.3.9-SNAPSHOT' annotationProcessor ':square-otto-compiler:1.3.9-SNAPSHOT'
@ -85,9 +85,6 @@ dependencies {
} }
implementation 'org.solovyev.android:checkout:1.2.1' implementation 'org.solovyev.android:checkout:1.2.1'
implementation 'org.solovyev.android:material:0.1.4@aar' implementation 'org.solovyev.android:material:0.1.4@aar'
implementation "com.google.android.gms:play-services-ads:${versions.gpsLib}"
implementation "com.google.android.gms:play-services-base:${versions.gpsLib}"
implementation "com.google.android.gms:play-services-analytics:${versions.gpsLib}"
implementation(name: 'plotter', ext: 'aar') implementation(name: 'plotter', ext: 'aar')
implementation 'com.google.guava:guava:20.0' implementation 'com.google.guava:guava:20.0'
implementation('org.simpleframework:simple-xml:2.6.1') { implementation('org.simpleframework:simple-xml:2.6.1') {
@ -108,7 +105,6 @@ dependencies {
testImplementation 'org.robolectric:robolectric:3.5.1' testImplementation 'org.robolectric:robolectric:3.5.1'
testImplementation 'org.mockito:mockito-all:1.9.5' testImplementation 'org.mockito:mockito-all:1.9.5'
testImplementation 'org.skyscreamer:jsonassert:1.2.3' testImplementation 'org.skyscreamer:jsonassert:1.2.3'
testImplementation(name: 'org.apache.http.legacy', ext: 'jar')
androidTestImplementation "com.android.support:support-annotations:${versions.supportLib}" androidTestImplementation "com.android.support:support-annotations:${versions.supportLib}"
androidTestImplementation'com.android.support.test:runner:1.0.2' androidTestImplementation'com.android.support.test:runner:1.0.2'
@ -160,56 +156,3 @@ signing {
group = "org.solovyev.android" group = "org.solovyev.android"
version = android.defaultConfig.versionName version = android.defaultConfig.versionName
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
// for some reason Gradle :uploadArchives tries to upload null.txt.asc and null.map artifacts.
// As we don't want those let's filter them now (note that these files are not included in the
// list of project artifacts, so their origin is not clear)
def removeCond = { artifact -> return !artifact.classifier && (artifact.type == "map" || artifact.type == "txt.asc") }
deployment.artifacts.removeAll(removeCond)
deployment.attachedArtifacts.removeAll(removeCond)
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
artifactId = 'calculatorpp-app'
name 'Calculator++ Application'
packaging 'apk'
description 'Calculator for Android'
url 'https://github.com/serso/android-calculatorpp'
scm {
url 'https://github.com/serso/android-calculatorpp'
connection 'scm:https://serso@github.com/serso/android-calculatorpp.git'
developerConnection 'scm:git://github.com/serso/android-calculatorpp.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'se.solovyev'
name 'Sergey Solovyev'
email 'se.solovyev@gmail.com'
}
}
}
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -27,10 +27,6 @@
android:theme="@style/Cpp.Theme.Material" android:theme="@style/Cpp.Theme.Material"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"> tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity <activity
android:name=".CalculatorActivity" android:name=".CalculatorActivity"
android:clearTaskOnLaunch="true" android:clearTaskOnLaunch="true"

View File

@ -1,149 +0,0 @@
package org.solovyev.android.calculator;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
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.AdSize;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class AdView extends FrameLayout {
@Nullable
private com.google.android.gms.ads.AdView admobView;
@Nullable
private AdView.AdViewListener admobListener;
public AdView(Context context) {
super(context);
init();
}
public AdView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public AdView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
setVisibility(GONE);
setId(R.id.cpp_ad);
}
public void destroy() {
destroyAdmobView();
}
private void destroyAdmobView() {
if (admobView != null) {
admobView.destroy();
admobView.setAdListener(null);
admobView = null;
}
if (admobListener != null) {
admobListener.destroy();
admobListener = null;
}
}
public void pause() {
if (admobView != null) {
admobView.pause();
}
}
public void resume() {
if (admobView != null) {
admobView.resume();
}
}
public void show() {
if (admobView != null) {
return;
}
admobView = addAdmobView();
admobListener = new AdView.AdViewListener(this);
admobView.setAdListener(admobListener);
final AdRequest.Builder b = new AdRequest.Builder();
b.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
if (BuildConfig.DEBUG) {
// LG Nexus 5
b.addTestDevice("B80E676D60CE6FDBE1B84A55464E3FE1");
}
admobView.loadAd(b.build());
}
@Nonnull
private com.google.android.gms.ads.AdView addAdmobView() {
final com.google.android.gms.ads.AdView v = new com.google.android.gms.ads.AdView(getContext());
v.setVisibility(GONE);
v.setAdSize(AdSize.SMART_BANNER);
v.setAdUnitId(getResources().getString(R.string.admob));
final LayoutParams lp = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
lp.gravity = Gravity.CENTER;
addView(v, lp);
return v;
}
public void hide() {
if (admobView == null) {
return;
}
setVisibility(GONE);
admobView.setVisibility(View.GONE);
admobView.pause();
destroyAdmobView();
}
private static class AdViewListener extends AdListener {
@Nullable
private AdView adView;
public AdViewListener(@Nonnull AdView adView) {
this.adView = adView;
}
void destroy() {
adView = null;
}
@Override
public void onAdFailedToLoad(int errorCode) {
if (adView != null) {
adView.hide();
adView = null;
}
}
@Override
public void onAdLoaded() {
if (adView != null) {
final com.google.android.gms.ads.AdView admobView = adView.admobView;
if (admobView != null) {
admobView.setVisibility(View.VISIBLE);
}
adView.setVisibility(VISIBLE);
adView = null;
}
}
}
}

View File

@ -26,7 +26,6 @@ import android.view.Window;
import android.widget.TextView; import android.widget.TextView;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.ga.Ga;
import org.solovyev.android.calculator.language.Language; import org.solovyev.android.calculator.language.Language;
import org.solovyev.android.calculator.language.Languages; import org.solovyev.android.calculator.language.Languages;
import org.solovyev.android.calculator.view.Tabs; import org.solovyev.android.calculator.view.Tabs;
@ -55,8 +54,6 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
@Inject @Inject
Calculator calculator; Calculator calculator;
@Inject @Inject
Lazy<Ga> ga;
@Inject
Typeface typeface; Typeface typeface;
@BindView(R.id.main) @BindView(R.id.main)
ViewGroup mainView; ViewGroup mainView;
@ -84,14 +81,6 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
this.tabs = new Tabs(this); this.tabs = new Tabs(this);
} }
public void reportActivityStop(@Nonnull Activity activity) {
ga.get().getAnalytics().reportActivityStop(activity);
}
public void reportActivityStart(@Nonnull Activity activity) {
ga.get().getAnalytics().reportActivityStart(activity);
}
public static void setFont(@Nonnull View view, @Nonnull Typeface newTypeface) { public static void setFont(@Nonnull View view, @Nonnull Typeface newTypeface) {
if (view instanceof TextView) { if (view instanceof TextView) {
final TextView textView = (TextView) view; final TextView textView = (TextView) view;
@ -209,18 +198,6 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
protected void inject(@Nonnull AppComponent component) { protected void inject(@Nonnull AppComponent component) {
} }
@Override
protected void onStart() {
super.onStart();
reportActivityStart(this);
}
@Override
protected void onStop() {
reportActivityStop(this);
super.onStop();
}
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) { if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {

View File

@ -16,9 +16,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import org.solovyev.android.calculator.ga.Ga;
import javax.inject.Inject; import javax.inject.Inject;
@ -29,8 +26,6 @@ public abstract class BaseDialogFragment extends DialogFragment implements View.
@Inject @Inject
protected SharedPreferences preferences; protected SharedPreferences preferences;
@Inject @Inject
Ga ga;
@Inject
Typeface typeface; Typeface typeface;
@Nullable @Nullable
private Button positiveButton; private Button positiveButton;
@ -79,9 +74,6 @@ public abstract class BaseDialogFragment extends DialogFragment implements View.
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
final Tracker tracker = ga.getTracker();
tracker.setScreenName(getClass().getSimpleName());
tracker.send(new HitBuilders.ScreenViewBuilder().build());
} }
protected void onShowDialog(@NonNull AlertDialog dialog, boolean firstTime) { protected void onShowDialog(@NonNull AlertDialog dialog, boolean firstTime) {

View File

@ -8,7 +8,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.*; import android.view.*;
import org.solovyev.android.calculator.ads.AdUi;
import org.solovyev.android.plotter.Check; import org.solovyev.android.plotter.Check;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -21,8 +20,6 @@ public abstract class BaseFragment extends Fragment {
private final int layout; private final int layout;
@Inject @Inject
AdUi adUi;
@Inject
public Typeface typeface; public Typeface typeface;
protected BaseFragment(@LayoutRes int layout) { protected BaseFragment(@LayoutRes int layout) {
@ -31,13 +28,13 @@ public abstract class BaseFragment extends Fragment {
@Nonnull @Nonnull
public static MenuItem addMenu(@Nonnull ContextMenu menu, @StringRes int label, public static MenuItem addMenu(@Nonnull ContextMenu menu, @StringRes int label,
@Nonnull MenuItem.OnMenuItemClickListener listener) { @Nonnull MenuItem.OnMenuItemClickListener listener) {
return menu.add(NONE, label, NONE, label).setOnMenuItemClickListener(listener); return menu.add(NONE, label, NONE, label).setOnMenuItemClickListener(listener);
} }
@NonNull @NonNull
public static <P extends Parcelable> P getParcelable(@NonNull Bundle bundle, public static <P extends Parcelable> P getParcelable(@NonNull Bundle bundle,
@NonNull String key) { @NonNull String key) {
final P parcelable = bundle.getParcelable(key); final P parcelable = bundle.getParcelable(key);
Check.isNotNull(parcelable); Check.isNotNull(parcelable);
return parcelable; return parcelable;
@ -47,7 +44,6 @@ public abstract class BaseFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
inject(cast(getActivity().getApplication()).getComponent()); inject(cast(getActivity().getApplication()).getComponent());
adUi.onCreate();
} }
protected void inject(@Nonnull AppComponent component) { protected void inject(@Nonnull AppComponent component) {
@ -56,34 +52,9 @@ public abstract class BaseFragment extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
final View view = inflater.inflate(layout, container, false); final View view = inflater.inflate(layout, container, false);
adUi.onCreateView(view);
BaseActivity.fixFonts(view, typeface); BaseActivity.fixFonts(view, typeface);
return view; return view;
} }
@Override
public void onResume() {
super.onResume();
adUi.onResume();
}
@Override
public void onPause() {
adUi.onPause();
super.onPause();
}
@Override
public void onDestroyView() {
adUi.onDestroyView();
super.onDestroyView();
}
@Override
public void onDestroy() {
adUi.onDestroy();
super.onDestroy();
}
} }

View File

@ -33,7 +33,6 @@ import android.util.TimingLogger;
import com.squareup.otto.Bus; import com.squareup.otto.Bus;
import org.solovyev.android.calculator.floating.FloatingCalculatorActivity; import org.solovyev.android.calculator.floating.FloatingCalculatorActivity;
import org.solovyev.android.calculator.ga.Ga;
import org.solovyev.android.calculator.history.History; import org.solovyev.android.calculator.history.History;
import org.solovyev.android.calculator.language.Language; import org.solovyev.android.calculator.language.Language;
import org.solovyev.android.calculator.language.Languages; import org.solovyev.android.calculator.language.Languages;
@ -50,27 +49,6 @@ import jscl.MathEngine;
public class CalculatorApplication extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener { public class CalculatorApplication extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener {
// delayed GA reporting in order to avoid initialization of GA on the main
// application thread and to postpone it as much as possible
private class GaInitializer extends AsyncTask<Void, Void, Ga> {
@NonNull
private final SharedPreferences prefs;
GaInitializer(@NonNull SharedPreferences prefs) {
this.prefs = prefs;
}
@Override
protected Ga doInBackground(Void... params) {
return ga.get();
}
@Override
protected void onPostExecute(@NonNull Ga ga) {
ga.reportInitially(prefs);
}
}
@Inject @Inject
@Named(AppModule.THREAD_INIT) @Named(AppModule.THREAD_INIT)
Executor initThread; Executor initThread;
@ -114,9 +92,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
@Inject @Inject
ActivityLauncher launcher; ActivityLauncher launcher;
@Inject
Lazy<Ga> ga;
@Nonnull @Nonnull
private final TimingLogger timer = new TimingLogger("App", "onCreate"); private final TimingLogger timer = new TimingLogger("App", "onCreate");
@ -169,7 +144,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
warmUpEngine(); warmUpEngine();
} }
}); });
new GaInitializer(prefs).executeOnExecutor(initThread);
} }
private void warmUpEngine() { private void warmUpEngine() {

View File

@ -35,7 +35,6 @@ import com.squareup.otto.Subscribe;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.buttons.CppSpecialButton; import org.solovyev.android.calculator.buttons.CppSpecialButton;
import org.solovyev.android.calculator.ga.Ga;
import org.solovyev.android.calculator.history.History; import org.solovyev.android.calculator.history.History;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.memory.Memory; import org.solovyev.android.calculator.memory.Memory;
@ -70,8 +69,6 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe
@Inject @Inject
Engine engine; Engine engine;
@Inject @Inject
Lazy<Ga> ga;
@Inject
Lazy<Clipboard> clipboard; Lazy<Clipboard> clipboard;
@Inject @Inject
ActivityLauncher launcher; ActivityLauncher launcher;
@ -112,13 +109,11 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe
final char glyph = text.charAt(0); final char glyph = text.charAt(0);
final CppSpecialButton button = CppSpecialButton.getByGlyph(glyph); final CppSpecialButton button = CppSpecialButton.getByGlyph(glyph);
if (button != null) { if (button != null) {
ga.get().onButtonPressed(button.action);
handleSpecialAction(button); handleSpecialAction(button);
return true; return true;
} }
} }
ga.get().onButtonPressed(text);
if (!processSpecialAction(text)) { if (!processSpecialAction(text)) {
processText(prepareText(text)); processText(prepareText(text));
} }

View File

@ -1,116 +0,0 @@
package org.solovyev.android.calculator.ads;
import static org.solovyev.android.checkout.ProductTypes.IN_APP;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.view.View;
import org.solovyev.android.calculator.AdView;
import org.solovyev.android.calculator.R;
import org.solovyev.android.checkout.CppCheckout;
import org.solovyev.android.checkout.Inventory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
public class AdUi {
@NonNull
private final CppCheckout checkout;
@NonNull
private final Handler handler;
@Nullable
@BindView(R.id.cpp_ad)
AdView adView;
@Nullable
private Boolean adFree = null;
@Inject
public AdUi(@NonNull CppCheckout checkout, @NonNull Handler handler) {
this.checkout = checkout;
this.handler = handler;
}
public void onCreate() {
checkout.start();
}
public void onResume() {
if (adView == null) {
return;
}
adView.resume();
if (adFree != null) {
updateAdView();
} else {
checkout.loadInventory(Inventory.Request.create().loadAllPurchases(),
onMainThread(new Inventory.Callback() {
@Override
public void onLoaded(@Nonnull Inventory.Products products) {
adFree = products.get(IN_APP).isPurchased("ad_free");
updateAdView();
}
}));
}
}
private void updateAdView() {
if (adFree == null || adView == null) {
return;
}
if (adFree) {
adView.hide();
} else {
adView.show();
}
}
@Nonnull
private Inventory.Callback onMainThread(@Nonnull final Inventory.Callback callback) {
return new Inventory.Callback() {
@Override
public void onLoaded(@Nonnull final Inventory.Products products) {
if (handler.getLooper() == Looper.myLooper()) {
callback.onLoaded(products);
return;
}
handler.post(new Runnable() {
@Override
public void run() {
callback.onLoaded(products);
}
});
}
};
}
public void onCreateView(@NonNull View view) {
ButterKnife.bind(this, view);
}
public void onPause() {
adFree = null;
if (adView != null) {
adView.pause();
}
}
public void onDestroyView() {
if (adView == null) {
return;
}
adView.destroy();
adView = null;
}
public void onDestroy() {
checkout.stop();
}
}

View File

@ -36,7 +36,6 @@ import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.ga.Ga;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -59,8 +58,6 @@ public class FloatingCalculatorService extends Service implements FloatingViewLi
@Inject @Inject
Display display; Display display;
@Inject @Inject
Ga ga;
@Inject
SharedPreferences preferences; SharedPreferences preferences;
public static void show(@Nonnull Context context) { public static void show(@Nonnull Context context) {
@ -139,7 +136,6 @@ public class FloatingCalculatorService extends Service implements FloatingViewLi
if (isShowWindowIntent(intent)) { if (isShowWindowIntent(intent)) {
hideNotification(); hideNotification();
createView(); createView();
ga.onFloatingCalculatorOpened();
} else if (isShowNotificationIntent(intent)) { } else if (isShowNotificationIntent(intent)) {
showNotification(); showNotification();
} }

View File

@ -1,87 +0,0 @@
package org.solovyev.android.calculator.ga;
import android.app.Application;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public final class Ga implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final int LAYOUT = 1;
private static final int THEME = 2;
@Nonnull
private final GoogleAnalytics analytics;
@Nonnull
private final Tracker tracker;
@Inject
public Ga(@Nonnull Application application, @Nonnull SharedPreferences preferences) {
analytics = GoogleAnalytics.getInstance(application);
tracker = analytics.newTracker(R.xml.ga);
preferences.registerOnSharedPreferenceChangeListener(this);
}
private void reportLayout(@Nonnull Preferences.Gui.Mode mode) {
tracker.send(new HitBuilders.EventBuilder().setCustomDimension(LAYOUT, mode.name()).build());
}
private void reportTheme(@Nonnull Preferences.Gui.Theme theme) {
tracker.send(new HitBuilders.EventBuilder().setCustomDimension(THEME, theme.name()).build());
}
@Nonnull
public GoogleAnalytics getAnalytics() {
return analytics;
}
@Nonnull
public Tracker getTracker() {
return tracker;
}
public void onButtonPressed(@Nullable String text) {
if (TextUtils.isEmpty(text)) {
return;
}
final HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
b.setCategory("ui");
b.setAction("click");
b.setLabel(text);
tracker.send(b.build());
}
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (TextUtils.equals(key, Preferences.Gui.mode.getKey())) {
reportLayout(Preferences.Gui.mode.getPreferenceNoError(preferences));
} else if (TextUtils.equals(key, Preferences.Gui.theme.getKey())) {
reportTheme(Preferences.Gui.theme.getPreferenceNoError(preferences));
}
}
public void reportInitially(@Nonnull SharedPreferences preferences) {
reportLayout(Preferences.Gui.mode.getPreferenceNoError(preferences));
reportTheme(Preferences.Gui.theme.getPreferenceNoError(preferences));
}
public void onFloatingCalculatorOpened() {
final HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
b.setCategory("lifecycle");
b.setAction("floating_calculator");
b.setLabel("start");
tracker.send(b.build());
}
}

View File

@ -22,7 +22,6 @@ import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.solovyev.android.calculator.ActivityLauncher; import org.solovyev.android.calculator.ActivityLauncher;
import org.solovyev.android.calculator.AdView;
import org.solovyev.android.calculator.Engine; import org.solovyev.android.calculator.Engine;
import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.Preferences.Gui.Theme; import org.solovyev.android.calculator.Preferences.Gui.Theme;
@ -52,8 +51,6 @@ import jscl.NumeralBase;
public class PreferencesFragment extends org.solovyev.android.material.preferences.PreferencesFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public class PreferencesFragment extends org.solovyev.android.material.preferences.PreferencesFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private static boolean SUPPORT_HEADERS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; private static boolean SUPPORT_HEADERS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
@Nullable
private AdView adView;
@Inject @Inject
SharedPreferences preferences; SharedPreferences preferences;
@Inject @Inject
@ -133,12 +130,10 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
supportProject.setEnabled(!purchased); supportProject.setEnabled(!purchased);
supportProject.setSelectable(!purchased); supportProject.setSelectable(!purchased);
} }
onShowAd(!purchased);
} }
@Override @Override
public void onError(int i, @Nonnull Exception e) { public void onError(int i, @Nonnull Exception e) {
onShowAd(false);
} }
}); });
} }
@ -386,30 +381,6 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
prepareNumberFormatExamplesPreference(); prepareNumberFormatExamplesPreference();
} }
@Override
public void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}
}
@Override
public void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}
@Override
public void onDestroyView() {
if (adView != null) {
adView.destroy();
}
super.onDestroyView();
}
@Override @Override
public void onDestroy() { public void onDestroy() {
bus.unregister(this); bus.unregister(this);
@ -421,37 +392,4 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
return SUPPORT_HEADERS; return SUPPORT_HEADERS;
} }
protected void onShowAd(boolean show) {
if (!supportsHeaders()) {
return;
}
if (getView() == null) {
return;
}
final ListView listView = getListView();
if (show) {
if (adView != null) {
return;
}
adView = new AdView(getActivity());
adView.show();
try {
listView.addHeaderView(adView);
} catch (IllegalStateException e) {
// doesn't support header views
SUPPORT_HEADERS = false;
adView.hide();
adView = null;
}
} else {
if (adView == null) {
return;
}
listView.removeHeaderView(adView);
adView.hide();
adView = null;
}
}
} }

View File

@ -36,7 +36,6 @@ import android.support.v7.app.AppCompatActivity;
import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.BaseDialogFragment; import org.solovyev.android.calculator.BaseDialogFragment;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.ga.Ga;
import org.solovyev.android.checkout.ActivityCheckout; import org.solovyev.android.checkout.ActivityCheckout;
import org.solovyev.android.checkout.Billing; import org.solovyev.android.checkout.Billing;
import org.solovyev.android.checkout.BillingRequests; import org.solovyev.android.checkout.BillingRequests;
@ -53,8 +52,6 @@ public class PurchaseDialogActivity extends AppCompatActivity implements Request
@Inject @Inject
Billing billing; Billing billing;
@Inject
Ga ga;
ActivityCheckout checkout; ActivityCheckout checkout;
@Override @Override
@ -72,18 +69,6 @@ public class PurchaseDialogActivity extends AppCompatActivity implements Request
checkout.createPurchaseFlow(this); checkout.createPurchaseFlow(this);
} }
@Override
protected void onStart() {
super.onStart();
ga.getAnalytics().reportActivityStart(this);
}
@Override
protected void onStop() {
ga.getAnalytics().reportActivityStop(this);
super.onStop();
}
private void purchase() { private void purchase() {
checkout.whenReady(new Checkout.EmptyListener() { checkout.whenReady(new Checkout.EmptyListener() {
@Override @Override