New instance acad + matomo (acad flavor only)

This commit is contained in:
Thomas 2020-12-16 17:24:23 +01:00
parent 14cde8e625
commit 5eedadef47
8 changed files with 59 additions and 30 deletions

View File

@ -40,7 +40,7 @@ android {
}
//boolean full_instances if set to false means TubeAcad
productFlavors {
fdroid_acad {
fdroid_peertube_apps_educ {
applicationId "app.fedilab.fedilabtube"
resValue "string", "app_name", "TubeAcad"
resValue "string", "app_id", "app.fedilab.fedilabtube"
@ -51,7 +51,7 @@ android {
buildConfigField "boolean", "sepia_search", "false"
buildConfigField "boolean", "instance_switcher", "true"
}
google_acad {
google_peertube_apps_educ {
applicationId "app.fedilab.fedilabtube"
resValue "string", "app_name", "TubeAcad"
resValue "string", "app_id", "app.fedilab.fedilabtube"
@ -110,11 +110,11 @@ android {
}
sourceSets {
fdroid_acad {
fdroid_peertube_apps_educ {
res.srcDirs = ['src/main/res', 'src/acad/res']
java.srcDirs = ['src/main/java', 'src/acad/java']
}
google_acad {
google_peertube_apps_educ {
res.srcDirs = ['src/main/res', 'src/acad/res']
java.srcDirs = ['src/main/java', 'src/acad/java']
}
@ -196,8 +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'
fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
}

View File

@ -15,18 +15,21 @@ package app.fedilab.fedilabtube;
* see <http://www.gnu.org/licenses>. */
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));
mMatomoTracker = TrackerBuilder.createDefault("https://wa.phm.education.gouv.fr/snp/matomo.php", 11).build(Matomo.getInstance(this));
return mMatomoTracker;
}
}

View File

@ -17,6 +17,4 @@ package app.fedilab.fedilabtube;
public class FedilabTube extends BaseFedilabTube {
public void getTracker() {}
}

View File

@ -15,19 +15,27 @@ package app.fedilab.fedilabtube;
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.Context;
@SuppressWarnings({"unused", "RedundantSuppression"})
public class Matomo {
public static void sendScreen(Context _mcontext, String path, String title) {}
public static void sendScreen(Context _mcontext, String path, String title) {
//Do nothing
}
public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {}
public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {
//Do nothing
}
public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {}
public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {
//Do nothing
}
public static void trackInstall(Context _mcontext) {}
public static void trackInstall(Context _mcontext) {
//Do nothing
}
}

View File

@ -197,12 +197,15 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= item -> {
int itemId = item.getItemId();
String type = null;
if (itemId == R.id.navigation_discover) {
setTitleCustom(R.string.title_discover);
binding.viewpager.setCurrentItem(0);
type = HelperAcadInstance.DISCOVER;
} else if (itemId == R.id.navigation_subscription) {
binding.viewpager.setCurrentItem(1);
setTitleCustom(R.string.subscriptions);
type = HelperAcadInstance.SUBSCRIPTIONS;
} else if (itemId == R.id.navigation_trending) {
setTitleCustom(R.string.title_trending);
if (Helper.isLoggedIn(MainActivity.this)) {
@ -210,15 +213,22 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
} else {
binding.viewpager.setCurrentItem(1);
}
type = HelperAcadInstance.TRENDING;
} else if (itemId == R.id.navigation_most_liked) {
setTitleCustom(R.string.title_most_liked);
binding.viewpager.setCurrentItem(2);
type = HelperAcadInstance.MOSTLIKED;
} else if (itemId == R.id.navigation_recently_added) {
setTitleCustom(R.string.title_recently_added);
binding.viewpager.setCurrentItem(3);
type = HelperAcadInstance.RECENTLY_ADDED;
} else if (itemId == R.id.navigation_local) {
setTitleCustom(R.string.title_local);
binding.viewpager.setCurrentItem(4);
type = HelperAcadInstance.LOCAL;
}
if (type != null) {
Matomo.sendScreen(MainActivity.this, "TIMELINE", type);
}
return true;
};
@ -385,6 +395,8 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
}
binding.viewpager.setOffscreenPageLimit(5);
Matomo.sendEvent(MainActivity.this, "UTILISATEUR", "DEMARRAGE", HelperInstance.getLiveInstance(MainActivity.this), Helper.isLoggedIn(MainActivity.this) ? 1 : 0);
binding.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
@ -405,6 +417,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
});
toolbar.setOnClickListener(v -> {
if (binding.viewpager.getAdapter() == null) {
return;
@ -771,13 +784,16 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
@Override
public boolean onOptionsItemSelected(MenuItem item) {
String type = null;
String action = "TIMELINE";
if (item.getItemId() == R.id.action_change_instance) {
if (BuildConfig.full_instances) {
showRadioButtonDialogFullInstances(MainActivity.this, false);
} else {
showRadioButtonDialog();
}
return true;
action = "CHANGE_INSTANCE";
type = "";
} else if (item.getItemId() == R.id.action_settings) {
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
startActivity(intent);
@ -793,32 +809,30 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
}
startActivity(intent);
}
return true;
} else if (item.getItemId() == R.id.action_upload) {
Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class);
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_myvideos) {
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.MY_VIDEOS);
intent.putExtras(bundle);
startActivity(intent);
return true;
type = HelperAcadInstance.MYVIDEOS;
} else if (item.getItemId() == R.id.action_history) {
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.HISTORY);
intent.putExtras(bundle);
startActivity(intent);
return true;
type = HelperAcadInstance.HISTORY;
} else if (item.getItemId() == R.id.action_most_liked) {
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.MOST_LIKED);
intent.putExtras(bundle);
startActivity(intent);
return true;
type = HelperAcadInstance.MOSTLIKED;
} else if (item.getItemId() == R.id.action_playlist) {
Intent intent;
if (Helper.isLoggedIn(MainActivity.this)) {
@ -827,15 +841,12 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
intent = new Intent(MainActivity.this, AllLocalPlaylistsActivity.class);
}
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_sepia_search) {
Intent intent = new Intent(MainActivity.this, SepiaSearchActivity.class);
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_about) {
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_incognito) {
item.setChecked(!item.isChecked());
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
@ -854,8 +865,10 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
}).start();
return false;
}
return super.onOptionsItemSelected(item);
if (type != null) {
Matomo.sendScreen(MainActivity.this, action, type);
}
return true;
}

View File

@ -486,7 +486,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
return;
}
peertube = apiResponse.getPeertubes().get(0);
Matomo.sendScreen(PeertubeActivity.this, "video", peertube.getOriginUrl());
Matomo.sendScreen(PeertubeActivity.this, "VIDEO_REGARDEE", peertube.getUuid());
if (peertube.isNsfw()) {
binding.videoSensitive.setVisibility(View.VISIBLE);
} else {
@ -2021,8 +2021,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
} else if (peertube.isCommentsEnabled() && statusAction == REPLY) {
if (apiResponse.getComments() != null && apiResponse.getComments().size() > 0) {
commentsThread.add(position, apiResponse.getComments().get(0));
commentReplyListAdapter.notifyItemInserted(position);
commentsThread.add(position + 1, apiResponse.getComments().get(0));
commentReplyListAdapter.notifyItemInserted(position + 1);
}
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();

View File

@ -43,7 +43,6 @@ 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;
@ -129,7 +128,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
endDate = bundle.getString("endDate", null);
}
Matomo.sendScreen(getContext(), "timeline", String.valueOf(type));
if (channel != null) {
channelId = channel.getAcct();
} else if (account != null) {

View File

@ -23,6 +23,15 @@ public class HelperAcadInstance {
public static Map<String, String> instances_themes;
public static String LOCAL = "LOCALES";
public static String DISCOVER = "DECOUVRIR";
public static String MOSTLIKED = "PLUS_APPRECIEES";
public static String RECENTLY_ADDED = "AJOUTE_RECEMMENT";
public static String TRENDING = "TENDANCE";
public static String HISTORY = "HISTORIQUE";
public static String SUBSCRIPTIONS = "ABONNEMENTS";
public static String MYVIDEOS = "VIDEOS";
//List of available emails
public static String[] valideEmails = {
"ac-aix-marseille.fr",