Search in sources :

Example 1 with GoogleAnalytics

use of com.google.analytics.tracking.android.GoogleAnalytics in project fqrouter by fqrouter.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    setTitle("fqrouter " + LaunchService.getMyVersion(this));
    LaunchedIntent.register(this);
    LaunchingIntent.register(this);
    UpdateFoundIntent.register(this);
    ExitedIntent.register(this);
    DownloadingIntent.register(this);
    DownloadedIntent.register(this);
    DownloadFailedIntent.register(this);
    HandleFatalErrorIntent.register(this);
    DnsPollutedIntent.register(this);
    HandleAlertIntent.register(this);
    ExitingIntent.register(this);
    SocksVpnConnectedIntent.register(this);
    gestureDetector = new GestureDetectorCompat(this, new MyGestureDetector());
    Button fullPowerButton = (Button) findViewById(R.id.fullPowerButton);
    GoogleAnalytics gaInstance = GoogleAnalytics.getInstance(MainActivity.this);
    gaTracker = gaInstance.getTracker("UA-37740383-2");
    CookieSyncManager.createInstance(this);
    fullPowerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            gaTracker.sendEvent("more-power", "click", "", new Long(0));
            if (Build.VERSION.SDK_INT < 14) {
                Uri uri = Uri.parse("http://127.0.0.1:" + ConfigUtils.getHttpManagerPort());
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            } else {
                showWebView();
            }
        }
    });
    if (isReady) {
        onReady();
        showWebView();
    } else {
        LaunchService.execute(this);
    }
}
Also used : GoogleAnalytics(com.google.analytics.tracking.android.GoogleAnalytics) Button(android.widget.Button) Intent(android.content.Intent) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) WebView(android.webkit.WebView) TextView(android.widget.TextView) Uri(android.net.Uri)

Example 2 with GoogleAnalytics

use of com.google.analytics.tracking.android.GoogleAnalytics in project fqrouter by fqrouter.

the class ExitService method exit.

private void exit() {
    try {
        MainActivity.displayNotification(this, getResources().getString(R.string.status_exiting));
        sendBroadcast(new ExitingIntent());
        long elapsedTime = StartedAtFlag.delete();
        if (elapsedTime > 0) {
            GoogleAnalytics gaInstance = GoogleAnalytics.getInstance(this);
            Tracker gaTracker = gaInstance.getTracker("UA-37740383-2");
            gaTracker.setCustomDimension(1, Build.MODEL);
            gaTracker.setCustomDimension(2, String.valueOf(ShellUtils.isRooted()));
            gaTracker.sendTiming("engagement", elapsedTime, "session", "session");
        }
        LogUtils.i("Exiting, session life " + elapsedTime + "...");
        new Thread(new Runnable() {

            @Override
            public void run() {
                stopService(new Intent(ExitService.this, DownloadService.class));
                stopService(new Intent(ExitService.this, AcquireWifiLockService.class));
                if (ShellUtils.isRooted()) {
                    for (File file : new File[] { IOUtils.ETC_DIR, IOUtils.LOG_DIR, IOUtils.VAR_DIR }) {
                        if (file.listFiles().length > 0) {
                            try {
                                ShellUtils.sudo(ShellUtils.BUSYBOX_FILE + " chmod 666 " + file + "/*");
                            } catch (Exception e) {
                                LogUtils.e("failed to chmod files to non-root", e);
                            }
                        }
                    }
                }
            }
        }).start();
        try {
            ManagerProcess.kill();
        } catch (Exception e) {
            LogUtils.e("failed to kill manager process", e);
        }
        sendBroadcast(new ExitedIntent());
        MainActivity.clearNotification(this);
    } finally {
        MainActivity.isReady = false;
    }
}
Also used : GoogleAnalytics(com.google.analytics.tracking.android.GoogleAnalytics) Tracker(com.google.analytics.tracking.android.Tracker) AcquireWifiLockService(fq.router2.wifi_repeater.AcquireWifiLockService) Intent(android.content.Intent) File(java.io.File) DownloadService(fq.router2.feedback.DownloadService)

Aggregations

Intent (android.content.Intent)2 GoogleAnalytics (com.google.analytics.tracking.android.GoogleAnalytics)2 Uri (android.net.Uri)1 GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)1 WebView (android.webkit.WebView)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 Tracker (com.google.analytics.tracking.android.Tracker)1 DownloadService (fq.router2.feedback.DownloadService)1 AcquireWifiLockService (fq.router2.wifi_repeater.AcquireWifiLockService)1 File (java.io.File)1