<commit_before>/*
 * Copyright (c) 2015-2017 Snowplow Analytics Ltd. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */

package com.snowplowanalytics.snowplowtrackerdemo;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Button;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.text.method.ScrollingMovementMethod;
import android.support.customtabs.CustomTabsIntent;
import android.net.Uri;

import com.snowplowanalytics.snowplow.tracker.DevicePlatforms;
import com.snowplowanalytics.snowplow.tracker.Subject;
import com.snowplowanalytics.snowplow.tracker.emitter.HttpMethod;
import com.snowplowanalytics.snowplow.tracker.emitter.RequestCallback;
import com.snowplowanalytics.snowplow.tracker.emitter.RequestSecurity;
import com.snowplowanalytics.snowplow.tracker.Tracker;
import com.snowplowanalytics.snowplow.tracker.Emitter;
import com.snowplowanalytics.snowplow.tracker.utils.LogLevel;
import com.snowplowanalytics.snowplow.tracker.utils.Util;
import com.snowplowanalytics.snowplowtrackerdemo.utils.DemoUtils;
import com.snowplowanalytics.snowplowtrackerdemo.utils.TrackerEvents;

import java.util.concurrent.TimeUnit;

/**
 * Classic Demo Activity.
 */
@SuppressWarnings("FieldCanBeLocal")
public class Demo extends Activity {

    private Button _startButton, _tabButton;
    private EditText _uriField;
    private RadioGroup _type, _security, _collection;
    private RadioButton _radioGet, _radioHttp;
    private TextView _logOutput, _eventsCreated, _eventsSent, _emitterOnline, _emitterStatus,
            _databaseSize, _sessionIndex;

    private int eventsCreated = 0;
    private int eventsSent = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo);

        // Init Tracker
        initAndroidTracker();

        _startButton   = (Button)findViewById(R.id.btn_lite_start);
        _tabButton     = (Button)findViewById(R.id.btn_lite_tab);
        _uriField      = (EditText)findViewById(R.id.emitter_uri_field);
        _type          = (RadioGroup)findViewById(R.id.radio_send_type);
        _security      = (RadioGroup)findViewById(R.id.radio_send_security);
        _collection    = (RadioGroup)findViewById(R.id.radio_data_collection);
        _radioGet      = (RadioButton)findViewById(R.id.radio_get);
        _radioHttp     = (RadioButton)findViewById(R.id.radio_http);
        _logOutput     = (TextView)findViewById(R.id.log_output);
        _eventsCreated = (TextView)findViewById(R.id.created_events);
        _eventsSent    = (TextView)findViewById(R.id.sent_events);
        _emitterOnline = (TextView)findViewById(R.id.online_status);
        _emitterStatus = (TextView)findViewById(R.id.emitter_status);
        _databaseSize  = (TextView)findViewById(R.id.database_size);
        _sessionIndex  = (TextView)findViewById(R.id.session_index);

        _logOutput.setMovementMethod(new ScrollingMovementMethod());
        _logOutput.setText("");<commit_msg>Enforce strict mode for demo app (close #278)<commit_after>/*
 * Copyright (c) 2015-2017 Snowplow Analytics Ltd. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */

package com.snowplowanalytics.snowplowtrackerdemo;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.StrictMode;
import android.widget.EditText;
import android.widget.Button;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.text.method.ScrollingMovementMethod;
import android.support.customtabs.CustomTabsIntent;
import android.net.Uri;

import com.snowplowanalytics.snowplow.tracker.DevicePlatforms;
import com.snowplowanalytics.snowplow.tracker.Subject;
import com.snowplowanalytics.snowplow.tracker.emitter.HttpMethod;
import com.snowplowanalytics.snowplow.tracker.emitter.RequestCallback;
import com.snowplowanalytics.snowplow.tracker.emitter.RequestSecurity;
import com.snowplowanalytics.snowplow.tracker.Tracker;
import com.snowplowanalytics.snowplow.tracker.Emitter;
import com.snowplowanalytics.snowplow.tracker.utils.LogLevel;
import com.snowplowanalytics.snowplow.tracker.utils.Util;
import com.snowplowanalytics.snowplowtrackerdemo.utils.DemoUtils;
import com.snowplowanalytics.snowplowtrackerdemo.utils.TrackerEvents;

import java.util.concurrent.TimeUnit;

/**
 * Classic Demo Activity.
 */
@SuppressWarnings("FieldCanBeLocal")
public class Demo extends Activity {

    private Button _startButton, _tabButton;
    private EditText _uriField;
    private RadioGroup _type, _security, _collection;
    private RadioButton _radioGet, _radioHttp;
    private TextView _logOutput, _eventsCreated, _eventsSent, _emitterOnline, _emitterStatus,
            _databaseSize, _sessionIndex;

    private int eventsCreated = 0;
    private int eventsSent = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .penaltyDialog()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
                .penaltyLog()
                .build());
        setContentView(R.layout.activity_demo);

        // Init Tracker
        initAndroidTracker();

        _startButton   = (Button)findViewById(R.id.btn_lite_start);
        _tabButton     = (Button)findViewById(R.id.btn_lite_tab);
        _uriField      = (EditText)findViewById(R.id.emitter_uri_field);
        _type          = (RadioGroup)findViewById(R.id.radio_send_type);
        _security      = (RadioGroup)findViewById(R.id.radio_send_security);
        _collection    = (RadioGroup)findViewById(R.id.radio_data_collection);
        _radioGet      = (RadioButton)findViewById(R.id.radio_get);
        _radioHttp     = (RadioButton)findViewById(R.id.radio_http);
        _logOutput     = (TextView)findViewById(R.id.log_output);
        _eventsCreated = (TextView)findViewById(R.id.created_events);
        _eventsSent    = (TextView)findViewById(R.id.sent_events);
        _emitterOnline = (TextView)findViewById(R.id.online_status);
        _emitterStatus = (TextView)findViewById(R.id.emitter_status);
        _databaseSize  = (TextView)findViewById(R.id.database_size);
        _sessionIndex  = (TextView)findViewById(R.id.session_index);

        _logOutput.setMovementMethod(new ScrollingMovementMethod());
        _logOutput.setText("");
{'fraction_non_alphanumeric': 0.08904797789500125, 'fraction_numerical': 0.005903039437327305, 'mean_word_length': 4.154045307443366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6544869', 'n_tokens_mistral': 2413, 'n_tokens_neox': 2296, 'n_words': 494}