Fix for incorrect product id + GA now tracks more activities
This commit is contained in:
parent
13b2558620
commit
13fb8203ea
@ -71,7 +71,7 @@
|
|||||||
<activity android:label="@string/cpp_plot_function_settings" android:name=".plot.CalculatorPlotFunctionSettingsActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
<activity android:label="@string/cpp_plot_function_settings" android:name=".plot.CalculatorPlotFunctionSettingsActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
||||||
<activity android:label="@string/cpp_plot_range" android:name=".plot.CalculatorPlotRangeActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
<activity android:label="@string/cpp_plot_range" android:name=".plot.CalculatorPlotRangeActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
||||||
|
|
||||||
<activity android:label="@string/cpp_purchase_title" android:name=".preferences.CalculatorPurchaseDialogActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
<activity android:label="@string/cpp_purchase_title" android:name=".preferences.PurchaseDialogActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
||||||
|
|
||||||
<activity android:name=".CalculatorDialogActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
<activity android:name=".CalculatorDialogActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
||||||
|
|
||||||
|
@ -328,10 +328,18 @@ public class ActivityUi extends BaseUi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onStop(@Nonnull Activity activity) {
|
public void onStop(@Nonnull Activity activity) {
|
||||||
|
reportActivityStop(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reportActivityStop(@Nonnull Activity activity) {
|
||||||
App.getGa().getAnalytics().reportActivityStop(activity);
|
App.getGa().getAnalytics().reportActivityStop(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStart(@Nonnull Activity activity) {
|
public void onStart(@Nonnull Activity activity) {
|
||||||
|
reportActivityStart(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reportActivityStart(@Nonnull Activity activity) {
|
||||||
App.getGa().getAnalytics().reportActivityStart(activity);
|
App.getGa().getAnalytics().reportActivityStart(activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import org.solovyev.android.UiThreadExecutor;
|
import org.solovyev.android.UiThreadExecutor;
|
||||||
import org.solovyev.android.calculator.ga.Ga;
|
import org.solovyev.android.calculator.ga.Ga;
|
||||||
|
import org.solovyev.android.checkout.*;
|
||||||
import org.solovyev.common.listeners.JEvent;
|
import org.solovyev.common.listeners.JEvent;
|
||||||
import org.solovyev.common.listeners.JEventListener;
|
import org.solovyev.common.listeners.JEventListener;
|
||||||
import org.solovyev.common.listeners.JEventListeners;
|
import org.solovyev.common.listeners.JEventListeners;
|
||||||
@ -35,6 +36,8 @@ import org.solovyev.common.threads.DelayedExecutor;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -81,6 +84,12 @@ public final class App {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private static volatile Ga ga;
|
private static volatile Ga ga;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private static volatile Billing billing;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private static final Products products = Products.create().add(ProductTypes.IN_APP, Arrays.asList("ad_free"));
|
||||||
|
|
||||||
private App() {
|
private App() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
@ -111,6 +120,23 @@ public final class App {
|
|||||||
App.uiThreadExecutor = uiThreadExecutor;
|
App.uiThreadExecutor = uiThreadExecutor;
|
||||||
App.eventBus = eventBus;
|
App.eventBus = eventBus;
|
||||||
App.ga = new Ga(application, preferences, eventBus);
|
App.ga = new Ga(application, preferences, eventBus);
|
||||||
|
App.billing = new Billing(application, new Billing.DefaultConfiguration() {
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getPublicKey() {
|
||||||
|
return CalculatorSecurity.getPK();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Inventory getFallbackInventory(@Nonnull Checkout checkout, @Nonnull Executor onLoadExecutor) {
|
||||||
|
if (RobotmediaDatabase.exists(billing.getContext())) {
|
||||||
|
return new RobotmediaInventory(checkout, onLoadExecutor);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if (serviceLocator != null) {
|
if (serviceLocator != null) {
|
||||||
App.locator = serviceLocator;
|
App.locator = serviceLocator;
|
||||||
} else {
|
} else {
|
||||||
@ -178,4 +204,14 @@ public final class App {
|
|||||||
public static Ga getGa() {
|
public static Ga getGa() {
|
||||||
return ga;
|
return ga;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Billing getBilling() {
|
||||||
|
return billing;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Products getProducts() {
|
||||||
|
return products;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,25 +105,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private Typeface typeFace;
|
private Typeface typeFace;
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final Billing billing = new Billing(this, new Billing.DefaultConfiguration() {
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getPublicKey() {
|
|
||||||
return CalculatorSecurity.getPK();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Inventory getFallbackInventory(@Nonnull Checkout checkout, @Nonnull Executor onLoadExecutor) {
|
|
||||||
if (RobotmediaDatabase.exists(billing.getContext())) {
|
|
||||||
return new RobotmediaInventory(checkout, onLoadExecutor);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
*
|
||||||
@ -200,7 +181,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
|
|
||||||
Locator.getInstance().getCalculator().init();
|
Locator.getInstance().getCalculator().init();
|
||||||
|
|
||||||
billing.connect();
|
App.getBilling().connect();
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -265,11 +246,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
return typeFace;
|
return typeFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public Billing getBilling() {
|
|
||||||
return billing;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
*
|
||||||
|
@ -28,15 +28,15 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import org.solovyev.android.checkout.*;
|
import org.solovyev.android.checkout.ActivityCheckout;
|
||||||
|
import org.solovyev.android.checkout.Checkout;
|
||||||
|
import org.solovyev.android.checkout.Inventory;
|
||||||
|
import org.solovyev.android.checkout.ProductTypes;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
* Date: 9/26/12
|
* Date: 9/26/12
|
||||||
@ -91,7 +91,7 @@ public class FragmentUi extends BaseUi {
|
|||||||
public void onCreate(@Nonnull Fragment fragment) {
|
public void onCreate(@Nonnull Fragment fragment) {
|
||||||
final FragmentActivity activity = fragment.getActivity();
|
final FragmentActivity activity = fragment.getActivity();
|
||||||
super.onCreate(activity);
|
super.onCreate(activity);
|
||||||
checkout = Checkout.forActivity(activity, CalculatorApplication.getInstance().getBilling(), Products.create().add(ProductTypes.IN_APP, asList("ad_free")));
|
checkout = Checkout.forActivity(activity, App.getBilling(), App.getProducts());
|
||||||
|
|
||||||
if (listenersOnCreate) {
|
if (listenersOnCreate) {
|
||||||
if (fragment instanceof CalculatorEventListener) {
|
if (fragment instanceof CalculatorEventListener) {
|
||||||
|
@ -4,18 +4,20 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
||||||
|
import org.solovyev.android.calculator.ActivityUi;
|
||||||
import org.solovyev.android.calculator.AdView;
|
import org.solovyev.android.calculator.AdView;
|
||||||
import org.solovyev.android.calculator.CalculatorApplication;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.checkout.*;
|
import org.solovyev.android.checkout.ActivityCheckout;
|
||||||
|
import org.solovyev.android.checkout.Checkout;
|
||||||
|
import org.solovyev.android.checkout.Inventory;
|
||||||
|
import org.solovyev.android.checkout.ProductTypes;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
public abstract class BasePreferencesActivity extends SherlockPreferenceActivity {
|
public abstract class BasePreferencesActivity extends SherlockPreferenceActivity {
|
||||||
|
|
||||||
private final ActivityCheckout checkout = Checkout.forActivity(this, CalculatorApplication.getInstance().getBilling(), Products.create().add(ProductTypes.IN_APP, asList("ad_free")));
|
private final ActivityCheckout checkout = Checkout.forActivity(this, App.getBilling(), App.getProducts());
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private AdView adView;
|
private AdView adView;
|
||||||
|
|
||||||
@ -73,6 +75,18 @@ public abstract class BasePreferencesActivity extends SherlockPreferenceActivity
|
|||||||
inventory.whenLoaded(new InventoryListener());
|
inventory.whenLoaded(new InventoryListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
ActivityUi.reportActivityStart(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
ActivityUi.reportActivityStop(this);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
if (adView != null) {
|
if (adView != null) {
|
||||||
|
@ -91,7 +91,7 @@ public class PreferencesActivity extends BasePreferencesActivity implements Shar
|
|||||||
adFreePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
adFreePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
startActivity(new Intent(getApplicationContext(), CalculatorPurchaseDialogActivity.class));
|
startActivity(new Intent(getApplicationContext(), PurchaseDialogActivity.class));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,10 +29,7 @@ import android.text.method.ScrollingMovementMethod;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
import org.solovyev.android.calculator.CalculatorApplication;
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.calculator.CalculatorFragment;
|
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
|
||||||
import org.solovyev.android.calculator.R;
|
|
||||||
import org.solovyev.android.checkout.*;
|
import org.solovyev.android.checkout.*;
|
||||||
import org.solovyev.android.fragments.FragmentUtils;
|
import org.solovyev.android.fragments.FragmentUtils;
|
||||||
|
|
||||||
@ -44,10 +41,10 @@ import javax.annotation.Nullable;
|
|||||||
* Date: 1/20/13
|
* Date: 1/20/13
|
||||||
* Time: 2:36 PM
|
* Time: 2:36 PM
|
||||||
*/
|
*/
|
||||||
public class CalculatorPurchaseDialogActivity extends SherlockFragmentActivity {
|
public class PurchaseDialogActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final ActivityCheckout checkout = Checkout.forActivity(this, CalculatorApplication.getInstance().getBilling(), Products.create().add("ad_free"));
|
private final ActivityCheckout checkout = Checkout.forActivity(this, App.getBilling(), App.getProducts());
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final RequestListener<Purchase> purchaseListener = new RequestListener<Purchase>() {
|
private final RequestListener<Purchase> purchaseListener = new RequestListener<Purchase>() {
|
||||||
@ -90,13 +87,25 @@ public class CalculatorPurchaseDialogActivity extends SherlockFragmentActivity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
((CalculatorPurchaseDialogActivity) activity).purchase();
|
((PurchaseDialogActivity) activity).purchase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
ActivityUi.reportActivityStart(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
ActivityUi.reportActivityStop(this);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
private void purchase() {
|
private void purchase() {
|
||||||
checkout.whenReady(new Checkout.ListenerAdapter() {
|
checkout.whenReady(new Checkout.ListenerAdapter() {
|
||||||
@Override
|
@Override
|
@ -9,7 +9,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.preferences.CalculatorPurchaseDialogActivity;
|
import org.solovyev.android.calculator.preferences.PurchaseDialogActivity;
|
||||||
|
|
||||||
import static android.content.Intent.ACTION_VIEW;
|
import static android.content.Intent.ACTION_VIEW;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class FinalWizardStep extends Fragment {
|
|||||||
donateButton.setOnClickListener(new View.OnClickListener() {
|
donateButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startActivity(new Intent(getActivity(), CalculatorPurchaseDialogActivity.class));
|
startActivity(new Intent(getActivity(), PurchaseDialogActivity.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user