Search in sources :

Example 1 with CustomEvent

use of com.crashlytics.android.answers.CustomEvent in project xDrip by NightscoutFoundation.

the class Telemetry method sendCaptureReport.

/*

    No personal information is sent.

    Only the level of success in receiving sensor data and
    the make/model/version/settings/type of phone and collector used.

    This is to try to find any patterns relating to successful combinations, for example
    G5 collection working better with Samsung devices or not.

     */
public static void sendCaptureReport() {
    try {
        if (JoH.ratelimit("capture-report", 50000)) {
            Log.d(TAG, "SEND EVENT START");
            if (Pref.getBooleanDefaultFalse("enable_crashlytics") && Pref.getBooleanDefaultFalse("enable_telemetry")) {
                final Sensor sensor = Sensor.currentSensor();
                if (sensor != null) {
                    if (JoH.msSince(sensor.started_at) > 86400000) {
                        final StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext()), true);
                        final int capture_percentage = statsResult.getCapturePercentage();
                        final int capture_set = (capture_percentage / 10) * 10;
                        if (capture_set > 60) {
                            final boolean use_transmiter_pl_bluetooth = Pref.getBooleanDefaultFalse("use_transmiter_pl_bluetooth");
                            final boolean use_rfduino_bluetooth = Pref.getBooleanDefaultFalse("use_rfduino_bluetooth");
                            final String subtype = (use_transmiter_pl_bluetooth ? "TR" : "") + (use_rfduino_bluetooth ? "RF" : "") + (Home.get_forced_wear() ? "W" : "") + (NFCReaderX.used_nfc_successfully ? "N" : "");
                            final String capture_id = DexCollectionType.getDexCollectionType().toString() + subtype + " Captured " + capture_set;
                            Log.d(TAG, "SEND CAPTURE EVENT PROCESS: " + capture_id);
                            String watch_model = "";
                            if (Home.get_forced_wear()) {
                                // anonymize watch model
                                final String wear_node = Pref.getStringDefaultBlank("node_wearG5");
                                if (wear_node.length() > 0) {
                                    final String[] wear_array = wear_node.split(" ");
                                    for (String ii : wear_array) {
                                        if (!ii.contains("|"))
                                            watch_model = watch_model + ii;
                                    }
                                }
                            }
                            if (watch_model.length() > 0) {
                                Answers.getInstance().logCustom(new CustomEvent(capture_id).putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE).putCustomAttribute("Manufacturer", Build.MANUFACTURER).putCustomAttribute("Version", Build.VERSION.RELEASE).putCustomAttribute("xDrip", getVersionDetails()).putCustomAttribute("Watch", watch_model).putCustomAttribute("Percentage", capture_percentage));
                            } else {
                                Answers.getInstance().logCustom(new CustomEvent(capture_id).putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE).putCustomAttribute("Manufacturer", Build.MANUFACTURER).putCustomAttribute("Version", Build.VERSION.RELEASE).putCustomAttribute("xDrip", getVersionDetails()).putCustomAttribute("Percentage", capture_percentage));
                            }
                        }
                    } else {
                        Log.d(TAG, "Sensor not running for more than 24 hours yet");
                    }
                } else {
                    Log.d(TAG, "No sensor active");
                }
                Log.d(TAG, "SEND EVENT DONE");
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Got exception sending Capture Report");
    }
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent) StatsResult(com.eveningoutpost.dexdrip.stats.StatsResult) Sensor(com.eveningoutpost.dexdrip.Models.Sensor)

Example 2 with CustomEvent

use of com.crashlytics.android.answers.CustomEvent in project VirtualXposed by android-hacker.

the class FlurryROMCollector method reportOffsetInfo.

private static void reportOffsetInfo(Map<String, Integer> info) {
    Map<String, String> toReport = new HashMap<>();
    CustomEvent methodOffset = new CustomEvent("methodOffset");
    for (String key : info.keySet()) {
        toReport.put(key, String.valueOf(info.get(key)));
    }
    addRomInfo(toReport);
    Answers.getInstance().logCustom(methodOffset);
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent) HashMap(java.util.HashMap)

Example 3 with CustomEvent

use of com.crashlytics.android.answers.CustomEvent in project quran_android by quran.

the class QuranImportActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    QuranApplication quranApp = ((QuranApplication) getApplication());
    quranApp.refreshLocale(this, false);
    super.onCreate(savedInstanceState);
    quranApp.getApplicationComponent().inject(this);
    Answers.getInstance().logCustom(new CustomEvent("importData"));
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent)

Example 4 with CustomEvent

use of com.crashlytics.android.answers.CustomEvent in project quran_android by quran.

the class QuranAdvancedSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.quran_advanced_preferences);
    final Context context = getActivity();
    appContext = context.getApplicationContext();
    // field injection
    ((QuranApplication) appContext).getApplicationComponent().inject(this);
    final Preference logsPref = findPreference(Constants.PREF_LOGS);
    if (BuildConfig.DEBUG || "beta".equals(BuildConfig.BUILD_TYPE)) {
        logsPref.setOnPreferenceClickListener(preference -> {
            if (logsSubscription == null) {
                logsSubscription = Observable.fromIterable(Timber.forest()).filter(tree -> tree instanceof RecordingLogTree).firstElement().map(tree -> ((RecordingLogTree) tree).getLogs()).map(logs -> QuranUtils.getDebugInfo(appContext, quranScreenInfo) + "\n\n" + logs).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableMaybeObserver<String>() {

                    @Override
                    public void onSuccess(String logs) {
                        Intent intent = new Intent(Intent.ACTION_SEND);
                        intent.setType("message/rfc822");
                        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { appContext.getString(R.string.logs_email) });
                        intent.putExtra(Intent.EXTRA_TEXT, logs);
                        intent.putExtra(Intent.EXTRA_SUBJECT, "Logs");
                        startActivity(Intent.createChooser(intent, appContext.getString(R.string.prefs_send_logs_title)));
                        logsSubscription = null;
                    }

                    @Override
                    public void onError(Throwable e) {
                    }

                    @Override
                    public void onComplete() {
                    }
                });
            }
            return true;
        });
    } else {
        removeAdvancePreference(logsPref);
    }
    final Preference importPref = findPreference(Constants.PREF_IMPORT);
    importPref.setOnPreferenceClickListener(preference -> {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            String[] mimeTypes = new String[] { "application/*", "text/*" };
            intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
        }
        startActivityForResult(intent, REQUEST_CODE_IMPORT);
        return true;
    });
    final Preference exportPref = findPreference(Constants.PREF_EXPORT);
    exportPref.setOnPreferenceClickListener(preference -> {
        if (exportSubscription == null) {
            exportSubscription = bookmarkImportExportModel.exportBookmarksObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSingleObserver<Uri>() {

                @Override
                public void onSuccess(Uri uri) {
                    Answers.getInstance().logCustom(new CustomEvent("exportData"));
                    Intent shareIntent = new Intent(Intent.ACTION_SEND);
                    shareIntent.setType("application/json");
                    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    List<ResolveInfo> intents = appContext.getPackageManager().queryIntentActivities(shareIntent, 0);
                    if (intents.size() > 1) {
                        // if only one, then that is likely Quran for Android itself, so don't show
                        // the chooser since it doesn't really make sense.
                        context.startActivity(Intent.createChooser(shareIntent, context.getString(R.string.prefs_export_title)));
                    } else {
                        File exportedPath = new File(appContext.getExternalFilesDir(null), "backups");
                        String exported = appContext.getString(R.string.exported_data, exportedPath.toString());
                        Toast.makeText(appContext, exported, Toast.LENGTH_LONG).show();
                    }
                }

                @Override
                public void onError(Throwable e) {
                    exportSubscription = null;
                    if (isAdded()) {
                        Toast.makeText(context, R.string.export_data_error, Toast.LENGTH_LONG).show();
                    }
                }
            });
        }
        return true;
    });
    internalSdcardLocation = Environment.getExternalStorageDirectory().getAbsolutePath();
    listStoragePref = (DataListPreference) findPreference(getString(R.string.prefs_app_location));
    listStoragePref.setEnabled(false);
    try {
        storageList = StorageUtils.getAllStorageLocations(context.getApplicationContext());
    } catch (Exception e) {
        Timber.d(e, "Exception while trying to get storage locations");
        storageList = new ArrayList<>();
    }
    // except for the normal Environment.getExternalStorageDirectory
    if (storageList == null || storageList.size() <= 1) {
        Timber.d("removing advanced settings from preferences");
        hideStorageListPref();
    } else {
        loadStorageOptionsTask = new LoadStorageOptionsTask(context, quranFileUtils);
        loadStorageOptionsTask.execute();
    }
}
Also used : Context(android.content.Context) Context(android.content.Context) QuranImportActivity(com.quran.labs.androidquran.QuranImportActivity) Bundle(android.os.Bundle) Environment(android.os.Environment) Constants(com.quran.labs.androidquran.data.Constants) Uri(android.net.Uri) DataListPreference(com.quran.labs.androidquran.ui.preference.DataListPreference) Intent(android.content.Intent) QuranUtils(com.quran.labs.androidquran.util.QuranUtils) HashMap(java.util.HashMap) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Toast(android.widget.Toast) R(com.quran.labs.androidquran.R) BuildConfig(com.quran.labs.androidquran.BuildConfig) QuranFileUtils(com.quran.labs.androidquran.util.QuranFileUtils) QuranSettings(com.quran.labs.androidquran.util.QuranSettings) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) Build(android.os.Build) AsyncTask(android.os.AsyncTask) QuranAdvancedPreferenceActivity(com.quran.labs.androidquran.QuranAdvancedPreferenceActivity) ProgressDialog(android.app.ProgressDialog) TextUtils(android.text.TextUtils) QuranApplication(com.quran.labs.androidquran.QuranApplication) PermissionUtil(com.quran.labs.androidquran.service.util.PermissionUtil) QuranScreenInfo(com.quran.labs.androidquran.util.QuranScreenInfo) File(java.io.File) Timber(timber.log.Timber) ResolveInfo(android.content.pm.ResolveInfo) CustomEvent(com.crashlytics.android.answers.CustomEvent) StorageUtils(com.quran.labs.androidquran.util.StorageUtils) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) PreferenceGroup(android.preference.PreferenceGroup) AlertDialog(android.support.v7.app.AlertDialog) BookmarkImportExportModel(com.quran.labs.androidquran.model.bookmark.BookmarkImportExportModel) DisposableMaybeObserver(io.reactivex.observers.DisposableMaybeObserver) Preference(android.preference.Preference) PreferenceFragment(android.preference.PreferenceFragment) Answers(com.crashlytics.android.answers.Answers) Activity(android.app.Activity) DisposableSingleObserver(io.reactivex.observers.DisposableSingleObserver) RecordingLogTree(com.quran.labs.androidquran.util.RecordingLogTree) CustomEvent(com.crashlytics.android.answers.CustomEvent) DisposableSingleObserver(io.reactivex.observers.DisposableSingleObserver) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Uri(android.net.Uri) ResolveInfo(android.content.pm.ResolveInfo) DataListPreference(com.quran.labs.androidquran.ui.preference.DataListPreference) Preference(android.preference.Preference) RecordingLogTree(com.quran.labs.androidquran.util.RecordingLogTree) DisposableMaybeObserver(io.reactivex.observers.DisposableMaybeObserver) File(java.io.File)

Example 5 with CustomEvent

use of com.crashlytics.android.answers.CustomEvent in project quran_android by quran.

the class BookmarkPresenter method toggleGroupByTags.

public void toggleGroupByTags() {
    groupByTags = !groupByTags;
    quranSettings.setBookmarksGroupedByTags(groupByTags);
    requestData(false);
    Answers.getInstance().logCustom(new CustomEvent(groupByTags ? "groupByTags" : "doNotGroupByTags"));
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent)

Aggregations

CustomEvent (com.crashlytics.android.answers.CustomEvent)28 Intent (android.content.Intent)6 Bundle (android.os.Bundle)3 HashMap (java.util.HashMap)3 Activity (android.app.Activity)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Context (android.content.Context)2 Uri (android.net.Uri)2 AsyncTask (android.os.AsyncTask)2 AlertDialog (android.support.v7.app.AlertDialog)2 TextUtils (android.text.TextUtils)2 Toast (android.widget.Toast)2 Answers (com.crashlytics.android.answers.Answers)2 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)2 StatsResult (com.eveningoutpost.dexdrip.stats.StatsResult)2 PermissionUtil (com.quran.labs.androidquran.service.util.PermissionUtil)2 QuranFileUtils (com.quran.labs.androidquran.util.QuranFileUtils)2 QuranScreenInfo (com.quran.labs.androidquran.util.QuranScreenInfo)2 QuranSettings (com.quran.labs.androidquran.util.QuranSettings)2 File (java.io.File)2