diff --git a/app/build.gradle b/app/build.gradle index 41714f2..e51d879 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,6 +38,7 @@ android { checkReleaseBuilds false abortOnError false } + //boolean full_instances if set to false means TubeAcad productFlavors { fdroid_acad { applicationId "app.fedilab.fedilabtube" @@ -111,21 +112,27 @@ android { sourceSets { fdroid_acad { res.srcDirs = ['src/main/res', 'src/acad/res'] + java.srcDirs = ['src/main/java', 'src/acad/java'] } google_acad { res.srcDirs = ['src/main/res', 'src/acad/res'] + java.srcDirs = ['src/main/java', 'src/acad/java'] } fdroid_full { res.srcDirs = ['src/main/res', 'src/full/res'] + java.srcDirs = ['src/main/java', 'src/full/java'] } google_full { res.srcDirs = ['src/main/res', 'src/full/res'] + java.srcDirs = ['src/main/java', 'src/full/java'] } queermotion { res.srcDirs = ['src/main/res', 'src/queermotion/res'] + java.srcDirs = ['src/main/java', 'src/full/java'] } bittube { res.srcDirs = ['src/main/res', 'src/bittube/res'] + java.srcDirs = ['src/main/java', 'src/full/java'] } } } @@ -189,4 +196,8 @@ dependencies { implementation 'org.slf4j:slf4j-simple:1.7.30' + fdroid_acadImplementation 'org.matomo.sdk:tracker:4.1.2' + google_acadImplementation 'org.matomo.sdk:tracker:4.1.2' + + } \ No newline at end of file diff --git a/app/src/acad/java/app/fedilab/fedilabtube/FedilabTube.java b/app/src/acad/java/app/fedilab/fedilabtube/FedilabTube.java new file mode 100644 index 0000000..5f199ee --- /dev/null +++ b/app/src/acad/java/app/fedilab/fedilabtube/FedilabTube.java @@ -0,0 +1,32 @@ +package app.fedilab.fedilabtube; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of TubeLab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with TubeLab; if not, + * see . */ + + +import org.matomo.sdk.Matomo; +import org.matomo.sdk.Tracker; +import org.matomo.sdk.TrackerBuilder; + + +public class FedilabTube extends BaseFedilabTube { + + private Tracker mMatomoTracker; + + public synchronized Tracker getTracker() { + if (mMatomoTracker != null) return mMatomoTracker; + mMatomoTracker = TrackerBuilder.createDefault("https://wa.phm.education.gouv.fr/snp/", 11).build(Matomo.getInstance(this)); + return mMatomoTracker; + } +} \ No newline at end of file diff --git a/app/src/acad/java/app/fedilab/fedilabtube/Matomo.java b/app/src/acad/java/app/fedilab/fedilabtube/Matomo.java new file mode 100644 index 0000000..b7f2391 --- /dev/null +++ b/app/src/acad/java/app/fedilab/fedilabtube/Matomo.java @@ -0,0 +1,47 @@ +package app.fedilab.fedilabtube; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of TubeLab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with TubeLab; if not, + * see . */ + + +import android.app.Activity; +import android.content.Context; + +import org.matomo.sdk.Tracker; +import org.matomo.sdk.extra.TrackHelper; + +public class Matomo { + + public static void sendScreen(Context _mcontext, String path, String title) { + Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker(); + TrackHelper.track().screen(path).title(title).with(tracker); + } + + public static void sendEvent(Context _mcontext, String category, String action, String label, float value) { + Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker(); + TrackHelper.track().event(category, action).name(label).value(value).with(tracker); + } + + + public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) { + Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker(); + TrackHelper.track().screen(path).dimension(index, dimensionValue).with(tracker); + } + + + public static void trackInstall(Context _mcontext) { + Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker(); + TrackHelper.track().download().with(tracker); + } +} diff --git a/app/src/full/java/app/fedilab/fedilabtube/FedilabTube.java b/app/src/full/java/app/fedilab/fedilabtube/FedilabTube.java new file mode 100644 index 0000000..8654bf8 --- /dev/null +++ b/app/src/full/java/app/fedilab/fedilabtube/FedilabTube.java @@ -0,0 +1,22 @@ +package app.fedilab.fedilabtube; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of TubeLab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with TubeLab; if not, + * see . */ + + + +public class FedilabTube extends BaseFedilabTube { + + public void getTracker() {} +} \ No newline at end of file diff --git a/app/src/full/java/app/fedilab/fedilabtube/Matomo.java b/app/src/full/java/app/fedilab/fedilabtube/Matomo.java new file mode 100644 index 0000000..1d42957 --- /dev/null +++ b/app/src/full/java/app/fedilab/fedilabtube/Matomo.java @@ -0,0 +1,33 @@ +package app.fedilab.fedilabtube; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of TubeLab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with TubeLab; if not, + * see . */ + + +import android.app.Activity; +import android.content.Context; + + +public class Matomo { + + public static void sendScreen(Context _mcontext, String path, String title) {} + + public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {} + + + public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {} + + + public static void trackInstall(Context _mcontext) {} +} diff --git a/app/src/main/java/app/fedilab/fedilabtube/FedilabTube.java b/app/src/main/java/app/fedilab/fedilabtube/BaseFedilabTube.java similarity index 92% rename from app/src/main/java/app/fedilab/fedilabtube/FedilabTube.java rename to app/src/main/java/app/fedilab/fedilabtube/BaseFedilabTube.java index 3c12f80..cd5bb4b 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/FedilabTube.java +++ b/app/src/main/java/app/fedilab/fedilabtube/BaseFedilabTube.java @@ -35,7 +35,7 @@ import app.fedilab.fedilabtube.helper.ThemeHelper; import app.fedilab.fedilabtube.services.GlobalUploadObserver; import app.fedilab.fedilabtube.worker.WorkHelper; -public class FedilabTube extends MultiDexApplication { +public class BaseFedilabTube extends MultiDexApplication { static String UPLOAD_CHANNEL_ID = "upload_info_peertube"; @@ -48,12 +48,12 @@ public class FedilabTube extends MultiDexApplication { Configuration myConfig = new Configuration.Builder() .setMinimumLoggingLevel(android.util.Log.INFO) .build(); - WorkManager.initialize(FedilabTube.this, myConfig); + WorkManager.initialize(BaseFedilabTube.this, myConfig); if (interval >= 15) { WorkHelper.fetchNotifications(this, interval); } createNotificationChannel(); - UploadServiceConfig.initialize(FedilabTube.this, UPLOAD_CHANNEL_ID, true); + UploadServiceConfig.initialize(BaseFedilabTube.this, UPLOAD_CHANNEL_ID, true); new GlobalRequestObserver(this, new GlobalUploadObserver()); } @@ -63,7 +63,7 @@ public class FedilabTube extends MultiDexApplication { protected void attachBaseContext(Context base) { super.attachBaseContext(base); - MultiDex.install(FedilabTube.this); + MultiDex.install(BaseFedilabTube.this); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); int themePref = sharedpreferences.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE); ThemeHelper.switchTo(themePref); diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 86dce98..9f0a600 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -486,6 +486,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd return; } peertube = apiResponse.getPeertubes().get(0); + Matomo.sendScreen(PeertubeActivity.this, "video", peertube.getOriginUrl()); if (peertube.isNsfw()) { binding.videoSensitive.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java index e4e7666..337a671 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java +++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java @@ -43,6 +43,7 @@ import java.util.Map; import app.fedilab.fedilabtube.BuildConfig; import app.fedilab.fedilabtube.MainActivity; +import app.fedilab.fedilabtube.Matomo; import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; @@ -127,6 +128,8 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta startDate = bundle.getString("startDate", null); endDate = bundle.getString("endDate", null); } + + Matomo.sendScreen(getContext(), "timeline", String.valueOf(type)); if (channel != null) { channelId = channel.getAcct(); } else if (account != null) {