<commit_before>package it.tiwiz.whatsong.utils;

import android.content.Context;
import android.content.Intent;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.android.gms.appinvite.AppInviteInvitation;

import java.util.Map;

import it.tiwiz.whatsong.R;
import it.tiwiz.whatsong.WhatSongApp;

/**
 * This preference will make the users invite their friends to use WhatSong
 */
public class InvitationPreference extends Preference{

    private final Intent invitationIntent;
    private final Tracker trackerInstance;
    private final Map<String, String> eventData;

    public InvitationPreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setUpUiData();
        invitationIntent = createInvitationIntent();
        trackerInstance = getTrackerInstance();
        eventData = getEventData();
    }

    public InvitationPreference(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public InvitationPreference(Context context) {
        super(context);
        setUpUiData();
        invitationIntent = createInvitationIntent();
        trackerInstance = getTrackerInstance();
        eventData = getEventData();
    }

    private void setUpUiData() {
        setSummary(R.string.invite_friends_summary);
    }

    private Tracker getTrackerInstance() {
        return ((WhatSongApp) WhatSongApp.getInstance()).getDefaultTracker();
    }

    private Map<String, String> getEventData() {
        return new HitBuilders.EventBuilder()
                .setCategory("AppInvitation")
                .setAction("Send")
                .build();
    }

    private Intent createInvitationIntent() {
        final String invitationTitle = getContext().getString(R.string.invite_invitation_title);
        final String invitationMessage = getContext().getString(R.string.invite_invitation_message);

        return new AppInviteInvitation.IntentBuilder(invitationTitle)
                .setMessage(invitationMessage)
                .build();
    }

    @Override
    protected void onClick() {
        super.onClick();

        getContext().startActivity(invitationIntent);
        trackerInstance.send(eventData);
    }
}<commit_msg>Removes specific Analytics logic from AppInvites to use embedded one from Google<commit_after>package it.tiwiz.whatsong.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;

import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.android.gms.appinvite.AppInviteInvitation;

import java.util.Map;

import it.tiwiz.whatsong.BuildConfig;
import it.tiwiz.whatsong.R;
import it.tiwiz.whatsong.WhatSongApp;

/**
 * This preference will make the users invite their friends to use WhatSong
 */
public class InvitationPreference extends Preference{

    private final Intent invitationIntent;

    public InvitationPreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setUpUiData();
        invitationIntent = createInvitationIntent();
    }

    public InvitationPreference(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public InvitationPreference(Context context) {
        super(context);
        setUpUiData();
        invitationIntent = createInvitationIntent();
    }

    private void setUpUiData() {
        setSummary(R.string.invite_friends_summary);
    }

    private Tracker getTrackerInstance() {
        return ((WhatSongApp) WhatSongApp.getInstance()).getDefaultTracker();
    }

    private Map<String, String> getEventData() {
        return new HitBuilders.EventBuilder()
                .setCategory("AppInvitation")
                .setAction("Send")
                .build();
    }

    private Intent createInvitationIntent() {
        final String invitationTitle = getContext().getString(R.string.invite_invitation_title);
        final String invitationMessage = getContext().getString(R.string.invite_invitation_message);

        return new AppInviteInvitation.IntentBuilder(invitationTitle)
                .setMessage(invitationMessage)
                .setGoogleAnalyticsTrackingId(BuildConfig.ANALYTICS_USERID)
                .build();
    }

    @Override
    protected void onClick() {
        super.onClick();

        getContext().startActivity(invitationIntent);
    }
}
{'fraction_non_alphanumeric': 0.09136948723359359, 'fraction_numerical': 0.00042202996412745304, 'mean_word_length': 3.3686635944700463, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1373216', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1260, 'n_words': 266}