Add fragments to GA

This commit is contained in:
serso 2016-04-06 17:54:25 +02:00
parent 5571ff9c8a
commit 1090ba856f
2 changed files with 20 additions and 9 deletions

View File

@ -1,7 +1,5 @@
package org.solovyev.android.calculator;
import static org.solovyev.android.calculator.App.cast;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
@ -17,13 +15,20 @@ 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;
import static org.solovyev.android.calculator.App.cast;
public abstract class BaseDialogFragment extends DialogFragment implements View.OnClickListener, DialogInterface.OnClickListener {
@Inject
protected SharedPreferences preferences;
@Inject
Ga ga;
@Nullable
private Button positiveButton;
@Nullable
@ -67,6 +72,14 @@ public abstract class BaseDialogFragment extends DialogFragment implements View.
return dialog;
}
@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) {
}

View File

@ -46,6 +46,11 @@ public final class Ga implements SharedPreferences.OnSharedPreferenceChangeListe
return analytics;
}
@Nonnull
public Tracker getTracker() {
return tracker;
}
public void onButtonPressed(@Nullable String text) {
if (TextUtils.isEmpty(text)) {
return;
@ -72,13 +77,6 @@ public final class Ga implements SharedPreferences.OnSharedPreferenceChangeListe
reportTheme(Preferences.Gui.theme.getPreferenceNoError(preferences));
}
public void onBootStart() {
final HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
b.setCategory("lifecycle");
b.setAction("boot");
tracker.send(b.build());
}
public void onFloatingCalculatorOpened() {
final HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
b.setCategory("lifecycle");