com.gianlu.commonutils.analytics.AnalyticsApplication Java Examples

The following examples show how to use com.gianlu.commonutils.analytics.AnalyticsApplication. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestFragment.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.fragment_edit_profile_test, container, false);
    test = layout.findViewById(R.id.editProfile_test);
    test.setOnClickListener(v -> {
        if (listener != null) {
            AnalyticsApplication.sendAnalytics(Utils.ACTION_STARTED_TEST);

            MultiProfile.UserProfile profile = listener.getProfile();
            if (profile != null) startTest(profile);
        }
    });

    testResults = layout.findViewById(R.id.editProfile_testResults);

    return layout;
}
 
Example #2
Source File: MainActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onParticipatingGame(@NonNull GamePermalink game) {
    currentGame = game;

    if (isFinishing() || isDestroyed()) return;
    inflateNavigation(Layout.ONGOING);

    synchronized (fragmentsLock) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        ongoingGameFragment = OngoingGameFragment.getInstance(game);
        addOrReplace(transaction, ongoingGameFragment, Item.ONGOING_GAME);

        if (pyx.config().gameChatEnabled()) {
            gameChatFragment = ChatFragment.getGameInstance(game.gid);
            addOrReplace(transaction, gameChatFragment, Item.GAME_CHAT);
        }

        try {
            transaction.commitNow();
            navigation.setSelectedItem(Item.ONGOING_GAME);
        } catch (IllegalStateException ex) {
            AnalyticsApplication.crashlyticsLog(ex.getMessage() + " at #onParticipatingGame(GamePermalink)");
        }
    }
}
 
Example #3
Source File: NotificationService.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
private static void startInternal(@NonNull Context context, @NonNull StartedFrom startedFrom) {
    debug("Called start service, startedFrom=" + startedFrom);
    if (ProfilesManager.get(context).hasNotificationProfiles(context)) {
        new Handler(Looper.getMainLooper()).post(() -> {
            AnalyticsApplication.setCrashlyticsLong("notificationService_intentTime", System.currentTimeMillis());

            try {
                ContextCompat.startForegroundService(context, new Intent(context, NotificationService.class)
                        .setAction(ACTION_START).putExtra("startedFrom", startedFrom));
            } catch (SecurityException ex) {
                Log.e(TAG, "Cannot start notification service.", ex);
            }
        });
    } else {
        Log.d(TAG, "Tried to start notification service, but there are no candidates.");
    }
}
 
Example #4
Source File: AddMetalinkActivity.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public AddDownloadBundle createBundle() {
    AnalyticsApplication.sendAnalytics(Utils.ACTION_NEW_METALINK);

    String base64;
    try {
        base64 = base64Fragment.getBase64();
    } catch (Base64Fragment.NoFileException ex) {
        pager.setCurrentItem(0, true);
        return null;
    }

    String filename = base64Fragment.getFilenameOnDevice();
    Uri fileUri = base64Fragment.getFileUri();
    if (base64 == null || filename == null || fileUri == null) {
        pager.setCurrentItem(0, true);
        return null;
    }

    return new AddMetalinkBundle(base64, filename, fileUri, optionsFragment.getPosition(), optionsFragment.getOptions());
}
 
Example #5
Source File: AddTorrentActivity.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public AddDownloadBundle createBundle() {
    AnalyticsApplication.sendAnalytics(Utils.ACTION_NEW_TORRENT);

    String base64;
    try {
        base64 = base64Fragment.getBase64();
    } catch (Base64Fragment.NoFileException ex) {
        pager.setCurrentItem(0, true);
        return null;
    }

    String filename = base64Fragment.getFilenameOnDevice();
    Uri fileUri = base64Fragment.getFileUri();
    if (base64 == null || filename == null || fileUri == null) {
        pager.setCurrentItem(0, true);
        return null;
    }

    return new AddTorrentBundle(base64, filename, fileUri, urisFragment.getUris(), optionsFragment.getPosition(), optionsFragment.getOptions());
}
 
Example #6
Source File: AddUriActivity.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public AddDownloadBundle createBundle() {
    AnalyticsApplication.sendAnalytics(Utils.ACTION_NEW_URI);

    ArrayList<String> uris = urisFragment.getUris();
    if (uris == null || uris.isEmpty()) {
        Toaster.with(this).message(R.string.noUris).show();
        pager.setCurrentItem(0, true);
        return null;
    }

    OptionsMap options = optionsFragment.getOptions();
    String filename = optionsFragment.getFilename();
    if (filename != null) options.put("out", filename);
    return new AddUriBundle(uris, optionsFragment.getPosition(), options);
}
 
Example #7
Source File: FilesFragment.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDownloadDirectory(@NonNull MultiProfile profile, @NonNull AriaDirectory dir) {
    if (dirSheet != null) {
        dirSheet.dismiss();
        dirSheet = null;
        dismissDialog();
    }

    AnalyticsApplication.sendAnalytics(Utils.ACTION_DOWNLOAD_DIRECTORY);

    if (Prefs.getBoolean(PK.DD_USE_EXTERNAL)) {
        AlertDialog.Builder builder = new MaterialAlertDialogBuilder(requireContext());
        builder.setTitle(R.string.cannotDownloadDirWithExternal)
                .setMessage(R.string.cannotDownloadDirWithExternal_message)
                .setPositiveButton(android.R.string.yes, (dialog, which) -> startDownloadInternal(profile, null, dir))
                .setNegativeButton(android.R.string.no, null);

        showDialog(builder);
    } else {
        startDownloadInternal(profile, null, dir);
    }
}
 
Example #8
Source File: FilesFragment.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
private void shouldDownload(@NonNull MultiProfile profile, @NonNull OptionsMap global, @NonNull AriaFile file, boolean share) {
    AnalyticsApplication.sendAnalytics(Utils.ACTION_DOWNLOAD_FILE);

    if (Prefs.getBoolean(PK.DD_USE_EXTERNAL) || share) {
        MultiProfile.DirectDownload dd = profile.getProfile(getContext()).directDownload;
        HttpUrl base;
        if (dd == null || (base = dd.getUrl()) == null) return;

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(file.getDownloadUrl(global, base).toString()));

        if (dd.auth) {
            Bundle headers = new Bundle();
            headers.putString("Authorization", dd.getAuthorizationHeader());
            intent.putExtra(Browser.EXTRA_HEADERS, headers);
        }

        startActivity(intent);
    } else {
        startDownloadInternal(profile, file, null);
    }
}
 
Example #9
Source File: SearchActivity.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onQueryTextSubmit(@NotNull String query) {
    message.setVisibility(View.GONE);
    rmv.startLoading();
    this.query = query;

    searchApi.search(query.trim(), SearchApi.RESULTS_PER_REQUEST, Prefs.getSet(PK.A2_SEARCH_ENGINES, null), null, this);

    AnalyticsApplication.sendAnalytics(Utils.ACTION_SEARCH);
    return true;
}
 
Example #10
Source File: WebViewActivity.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
private void interceptedDownload(@NonNull InterceptedRequest req) {
    AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
    builder.setTitle(R.string.isThisToDownload)
            .setMessage(getString(R.string.isThisToDownload_message, req.url()))
            .setPositiveButton(android.R.string.yes, (dialog, which) -> launchAddUri(req))
            .setNegativeButton(android.R.string.no, null);

    showDialog(builder);
    AnalyticsApplication.sendAnalytics(Utils.ACTION_INTERCEPTED_WEBVIEW);
}
 
Example #11
Source File: GamesFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void spectateGame(final int gid, @Nullable String password) {
    if (getContext() == null) return;

    DialogUtils.showDialog(getActivity(), DialogUtils.progressDialog(getContext(), R.string.loading));
    pyx.request(PyxRequests.spectateGame(gid, password), getActivity(), new Pyx.OnResult<GamePermalink>() {
        @Override
        public void onDone(@NonNull GamePermalink game) {
            if (handler != null) handler.onParticipatingGame(game);
            DialogUtils.dismissDialog(getActivity());

            AnalyticsApplication.sendAnalytics(Utils.ACTION_SPECTATE_GAME);
        }

        @Override
        public void onException(@NonNull Exception ex) {
            DialogUtils.dismissDialog(getActivity());
            Log.e(TAG, "Failed spectating game.", ex);

            if (ex instanceof PyxException) {
                switch (((PyxException) ex).errorCode) {
                    case "wp":
                        showToast(Toaster.build().message(R.string.wrongPassword));
                        return;
                    case "gf":
                        showToast(Toaster.build().message(R.string.gameFull));
                        return;
                }
            }

            showToast(Toaster.build().message(R.string.failedSpectating));
        }
    });
}
 
Example #12
Source File: GamesFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void joinGame(int gid, @Nullable String password) {
    if (getContext() == null) return;

    DialogUtils.showDialog(getActivity(), DialogUtils.progressDialog(getContext(), R.string.loading));
    pyx.request(PyxRequests.joinGame(gid, password), getActivity(), new Pyx.OnResult<GamePermalink>() {
        @Override
        public void onDone(@NonNull GamePermalink game) {
            if (handler != null) handler.onParticipatingGame(game);
            DialogUtils.dismissDialog(getActivity());

            AnalyticsApplication.sendAnalytics(Utils.ACTION_JOIN_GAME);
        }

        @Override
        public void onException(@NonNull Exception ex) {
            Log.e(TAG, "Failed joining game.", ex);
            DialogUtils.dismissDialog(getActivity());

            if (ex instanceof PyxException) {
                switch (((PyxException) ex).errorCode) {
                    case "wp":
                        showToast(Toaster.build().message(R.string.wrongPassword));
                        return;
                    case "gf":
                        showToast(Toaster.build().message(R.string.gameFull));
                        return;
                }
            }

            showToast(Toaster.build().message(R.string.failedJoining));
        }
    });
}
 
Example #13
Source File: ChatFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void send(@NonNull String msg, boolean emote, boolean wall, @NonNull Pyx.OnSuccess listener) {
    if (gid == -1) {
        pyx.request(PyxRequests.sendMessage(msg, emote, wall), getActivity(), listener);
        AnalyticsApplication.sendAnalytics(Utils.ACTION_SENT_MSG);
    } else {
        pyx.request(PyxRequests.sendGameMessage(gid, msg, emote), getActivity(), listener);
        AnalyticsApplication.sendAnalytics(Utils.ACTION_SENT_GAME_MSG);
    }
}
 
Example #14
Source File: GameLayout.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCardAction(@NonNull GameCardView.Action action, @NonNull CardsGroup group, @NonNull BaseCard card) {
    if (action == GameCardView.Action.SELECT) {
        if (listener != null) listener.onCardSelected(card);
    } else if (action == GameCardView.Action.TOGGLE_STAR) {
        AnalyticsApplication.sendAnalytics(Utils.ACTION_STARRED_CARD_ADD);

        BaseCard bc = blackCard();
        if (bc != null && starredCards.addCard(new StarredCardsManager.StarredCard(bc, group)))
            Toaster.with(getContext()).message(R.string.addedCardToStarred).show();
    } else if (action == GameCardView.Action.SELECT_IMG) {
        listener.showDialog(CardImageZoomDialog.get(card));
    }
}
 
Example #15
Source File: RegisteredPyx.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
RegisteredPyx(Server server, LifecycleAwareHandler handler, OkHttpClient client, FirstLoadAndConfig firstLoad, User user) {
    super(server, handler, client, firstLoad);
    this.user = user;
    this.pollingThread = new PollingThread();
    this.pollingThread.start();

    Prefs.putString(PK.LAST_JSESSIONID, user.sessionId);
    AnalyticsApplication.setCrashlyticsString("server", server.url.toString());
}
 
Example #16
Source File: EditProfileActivity.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
private void deleteProfile() {
    if (editProfile == null) return;

    AnalyticsApplication.sendAnalytics(Utils.ACTION_DELETE_PROFILE);

    ProfilesManager.get(this).delete(editProfile);
    onBackPressed();
}
 
Example #17
Source File: MainActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onLeftGame() {
    currentGame = null;
    ongoingGameFragment = null;
    gameChatFragment = null;
    AnalyticsApplication.sendAnalytics(Utils.ACTION_LEFT_GAME);

    inflateNavigation(Layout.LOBBY);
    navigation.setSelectedItem(Item.GAMES);

    synchronized (fragmentsLock) {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();

        try {
            Fragment ongoingGame = manager.findFragmentByTag(Item.ONGOING_GAME.tag);
            if (ongoingGame != null) transaction.remove(ongoingGame);

            Fragment gameChat = manager.findFragmentByTag(Item.GAME_CHAT.tag);
            if (gameChat != null) transaction.remove(gameChat);

            transaction.commit();
        } catch (IllegalStateException ex) {
            Log.d(TAG, "Failed fragments transaction on left game.", ex);
        }
    }
}
 
Example #18
Source File: FilesFragment.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDownloadFile(@NonNull MultiProfile profile, @NonNull AriaFile file, boolean share) {
    if (fileSheet != null) {
        fileSheet.dismiss();
        fileSheet = null;
        dismissDialog();
    }

    showProgress(R.string.gathering_information);
    getHelper().request(AriaRequests.getGlobalOptions(), new AbstractClient.OnResult<OptionsMap>() {
        @Override
        public void onResult(@NonNull OptionsMap result) {
            dismissDialog();

            String mime = file.getMimeType();
            if (mime != null && Utils.isStreamable(mime) && getContext() != null) {
                Intent intent = Utils.getStreamIntent(profile.getProfile(getContext()), result, file);
                if (intent != null && Utils.canHandleIntent(requireContext(), intent)) {
                    AlertDialog.Builder builder = new MaterialAlertDialogBuilder(requireContext());
                    builder.setTitle(R.string.couldStreamVideo)
                            .setMessage(R.string.couldStreamVideo_message)
                            .setNeutralButton(android.R.string.cancel, null)
                            .setPositiveButton(R.string.stream, (dialog, which) -> {
                                startActivity(intent);
                                AnalyticsApplication.sendAnalytics(Utils.ACTION_PLAY_VIDEO);
                            })
                            .setNegativeButton(R.string.download, (dialog, which) -> shouldDownload(profile, result, file, share));

                    showDialog(builder);
                    return;
                }
            }

            shouldDownload(profile, result, file, share);
        }

        @Override
        public void onException(@NonNull Exception ex) {
            dismissDialog();
            Log.e(TAG, "Failed getting global options.", ex);
            showToast(Toaster.build().message(R.string.failedDownloadingFile));
        }
    });
}
 
Example #19
Source File: TutorialActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onSkipPressed(Fragment currentFragment) {
    AnalyticsApplication.sendAnalytics(Utils.ACTION_SKIP_TUTORIAL);
    done();
}
 
Example #20
Source File: TutorialActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDonePressed(Fragment currentFragment) {
    AnalyticsApplication.sendAnalytics(Utils.ACTION_DONE_TUTORIAL);
    done();
}