diff --git a/app/build.gradle b/app/build.gradle index ac7bba35..61ef2719 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -74,7 +74,7 @@ dependencies { implementation "com.android.support:support-v4:${versions.supportLib}" implementation "com.android.support:appcompat-v7:${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' annotationProcessor ':square-otto: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: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 'com.google.guava:guava:20.0' implementation('org.simpleframework:simple-xml:2.6.1') { @@ -108,7 +105,6 @@ dependencies { testImplementation 'org.robolectric:robolectric:3.5.1' testImplementation 'org.mockito:mockito-all:1.9.5' 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.test:runner:1.0.2' @@ -160,56 +156,3 @@ signing { group = "org.solovyev.android" 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' - } - } - } - } - } -} diff --git a/app/misc/libs/measure.jar b/app/misc/libs/measure.jar deleted file mode 100644 index bc0dc6d9..00000000 Binary files a/app/misc/libs/measure.jar and /dev/null differ diff --git a/app/misc/libs/org.apache.http.legacy.jar b/app/misc/libs/org.apache.http.legacy.jar deleted file mode 100644 index 3705bf1a..00000000 Binary files a/app/misc/libs/org.apache.http.legacy.jar and /dev/null differ diff --git a/app/misc/src/achartengine-0.7.0.jar b/app/misc/src/achartengine-0.7.0.jar deleted file mode 100644 index aec45ffc..00000000 Binary files a/app/misc/src/achartengine-0.7.0.jar and /dev/null differ diff --git a/app/misc/src/bsh.jar b/app/misc/src/bsh.jar deleted file mode 100644 index 4428cfaf..00000000 Binary files a/app/misc/src/bsh.jar and /dev/null differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9147c4f9..0ce390a3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,10 +27,6 @@ android:theme="@style/Cpp.Theme.Material" tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"> - - ga; - @Inject Typeface typeface; @BindView(R.id.main) ViewGroup mainView; @@ -84,14 +81,6 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr 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) { if (view instanceof TextView) { final TextView textView = (TextView) view; @@ -209,18 +198,6 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr protected void inject(@Nonnull AppComponent component) { } - @Override - protected void onStart() { - super.onStart(); - reportActivityStart(this); - } - - @Override - protected void onStop() { - reportActivityStop(this); - super.onStop(); - } - @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) { diff --git a/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java b/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java index afe8f280..1a1a8deb 100644 --- a/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java @@ -16,9 +16,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.inputmethod.InputMethodManager; 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; @@ -29,8 +26,6 @@ public abstract class BaseDialogFragment extends DialogFragment implements View. @Inject protected SharedPreferences preferences; @Inject - Ga ga; - @Inject Typeface typeface; @Nullable private Button positiveButton; @@ -79,9 +74,6 @@ public abstract class BaseDialogFragment extends DialogFragment implements View. @Override public void 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) { diff --git a/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java b/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java index ac09fc8c..01853c47 100644 --- a/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/BaseFragment.java @@ -8,7 +8,6 @@ import android.support.annotation.NonNull; import android.support.annotation.StringRes; import android.support.v4.app.Fragment; import android.view.*; -import org.solovyev.android.calculator.ads.AdUi; import org.solovyev.android.plotter.Check; import javax.annotation.Nonnull; @@ -21,8 +20,6 @@ public abstract class BaseFragment extends Fragment { private final int layout; @Inject - AdUi adUi; - @Inject public Typeface typeface; protected BaseFragment(@LayoutRes int layout) { @@ -31,13 +28,13 @@ public abstract class BaseFragment extends Fragment { @Nonnull 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); } @NonNull public static

P getParcelable(@NonNull Bundle bundle, - @NonNull String key) { + @NonNull String key) { final P parcelable = bundle.getParcelable(key); Check.isNotNull(parcelable); return parcelable; @@ -47,7 +44,6 @@ public abstract class BaseFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); inject(cast(getActivity().getApplication()).getComponent()); - adUi.onCreate(); } protected void inject(@Nonnull AppComponent component) { @@ -56,34 +52,9 @@ public abstract class BaseFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { final View view = inflater.inflate(layout, container, false); - adUi.onCreateView(view); BaseActivity.fixFonts(view, typeface); 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(); - } } diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index 5b5c36a1..2350fd64 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -33,7 +33,6 @@ import android.util.TimingLogger; import com.squareup.otto.Bus; 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.language.Language; import org.solovyev.android.calculator.language.Languages; @@ -50,27 +49,6 @@ import jscl.MathEngine; 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 { - @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 @Named(AppModule.THREAD_INIT) Executor initThread; @@ -114,9 +92,6 @@ public class CalculatorApplication extends android.app.Application implements Sh @Inject ActivityLauncher launcher; - @Inject - Lazy ga; - @Nonnull private final TimingLogger timer = new TimingLogger("App", "onCreate"); @@ -169,7 +144,6 @@ public class CalculatorApplication extends android.app.Application implements Sh warmUpEngine(); } }); - new GaInitializer(prefs).executeOnExecutor(initThread); } private void warmUpEngine() { diff --git a/app/src/main/java/org/solovyev/android/calculator/Keyboard.java b/app/src/main/java/org/solovyev/android/calculator/Keyboard.java index 2e23ef19..feaeaef7 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Keyboard.java +++ b/app/src/main/java/org/solovyev/android/calculator/Keyboard.java @@ -35,7 +35,6 @@ import com.squareup.otto.Subscribe; import org.solovyev.android.Check; 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.math.MathType; import org.solovyev.android.calculator.memory.Memory; @@ -70,8 +69,6 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe @Inject Engine engine; @Inject - Lazy ga; - @Inject Lazy clipboard; @Inject ActivityLauncher launcher; @@ -112,13 +109,11 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe final char glyph = text.charAt(0); final CppSpecialButton button = CppSpecialButton.getByGlyph(glyph); if (button != null) { - ga.get().onButtonPressed(button.action); handleSpecialAction(button); return true; } } - ga.get().onButtonPressed(text); if (!processSpecialAction(text)) { processText(prepareText(text)); } diff --git a/app/src/main/java/org/solovyev/android/calculator/ads/AdUi.java b/app/src/main/java/org/solovyev/android/calculator/ads/AdUi.java deleted file mode 100644 index a0961827..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/ads/AdUi.java +++ /dev/null @@ -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(); - } -} diff --git a/app/src/main/java/org/solovyev/android/calculator/floating/FloatingCalculatorService.java b/app/src/main/java/org/solovyev/android/calculator/floating/FloatingCalculatorService.java index 1bdd644d..4a4fc719 100644 --- a/app/src/main/java/org/solovyev/android/calculator/floating/FloatingCalculatorService.java +++ b/app/src/main/java/org/solovyev/android/calculator/floating/FloatingCalculatorService.java @@ -36,7 +36,6 @@ import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import org.solovyev.android.Check; import org.solovyev.android.calculator.*; -import org.solovyev.android.calculator.ga.Ga; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -59,8 +58,6 @@ public class FloatingCalculatorService extends Service implements FloatingViewLi @Inject Display display; @Inject - Ga ga; - @Inject SharedPreferences preferences; public static void show(@Nonnull Context context) { @@ -139,7 +136,6 @@ public class FloatingCalculatorService extends Service implements FloatingViewLi if (isShowWindowIntent(intent)) { hideNotification(); createView(); - ga.onFloatingCalculatorOpened(); } else if (isShowNotificationIntent(intent)) { showNotification(); } diff --git a/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java b/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java deleted file mode 100644 index 2af7b76c..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java +++ /dev/null @@ -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()); - } -} diff --git a/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java b/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java index f231cad9..9697e166 100644 --- a/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java @@ -22,7 +22,6 @@ import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import org.solovyev.android.calculator.ActivityLauncher; -import org.solovyev.android.calculator.AdView; import org.solovyev.android.calculator.Engine; import org.solovyev.android.calculator.Preferences; 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 { private static boolean SUPPORT_HEADERS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - @Nullable - private AdView adView; @Inject SharedPreferences preferences; @Inject @@ -133,12 +130,10 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc supportProject.setEnabled(!purchased); supportProject.setSelectable(!purchased); } - onShowAd(!purchased); } @Override public void onError(int i, @Nonnull Exception e) { - onShowAd(false); } }); } @@ -386,30 +381,6 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc 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 public void onDestroy() { bus.unregister(this); @@ -421,37 +392,4 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc 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; - } - } - } diff --git a/app/src/main/java/org/solovyev/android/calculator/preferences/PurchaseDialogActivity.java b/app/src/main/java/org/solovyev/android/calculator/preferences/PurchaseDialogActivity.java index 2c9c4781..3ba25894 100644 --- a/app/src/main/java/org/solovyev/android/calculator/preferences/PurchaseDialogActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/preferences/PurchaseDialogActivity.java @@ -36,7 +36,6 @@ import android.support.v7.app.AppCompatActivity; import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.BaseDialogFragment; import org.solovyev.android.calculator.R; -import org.solovyev.android.calculator.ga.Ga; import org.solovyev.android.checkout.ActivityCheckout; import org.solovyev.android.checkout.Billing; import org.solovyev.android.checkout.BillingRequests; @@ -53,8 +52,6 @@ public class PurchaseDialogActivity extends AppCompatActivity implements Request @Inject Billing billing; - @Inject - Ga ga; ActivityCheckout checkout; @Override @@ -72,18 +69,6 @@ public class PurchaseDialogActivity extends AppCompatActivity implements Request 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() { checkout.whenReady(new Checkout.EmptyListener() { @Override