Skip to content

Commit

Permalink
Merge pull request #8 from maxcanna/analytics
Browse files Browse the repository at this point in the history
Track usage
  • Loading branch information
maxcanna authored Mar 27, 2021
2 parents 4fdd485 + 5b63c7a commit 4cbc884
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 52 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Get google-services.json
run: echo ${{ secrets.GOOGLE_SERVICES_JSON }} | base64 -d > MuzeiWebcam/google-services.json
- name: Build
run: |
./gradlew assembleDebug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
./gradlew getVersionNumber
echo VERSION_NUMBER=$(cat MuzeiWebcam/versionNumber) >> $GITHUB_ENV
echo APK_NAME=$(cat MuzeiWebcam/versionNumber | cut -c 1-5) >> $GITHUB_ENV
echo APK_NAME=$(cat MuzeiWebcam/versionNumber | cut -c 2-6) >> $GITHUB_ENV
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
git log --reverse --no-merges --format='- %s' $(git log --merges --format='%H' -n 2)..HEAD -- >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
/MuzeiWebcam/build/
*.iml
com_crashlytics_export_strings.xml
/MuzeiWebcam/src/main/assets/crashlytics-build.properties
MuzeiWebcam/src/main/assets/crashlytics-build.properties
MuzeiWebcam/versionNumber
MuzeiWebcam/google-services.json
4 changes: 3 additions & 1 deletion MuzeiWebcam/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

def versionMajor = 2
def versionMinor = 2
def versionMinor = 3
def versionPatch = 0
def versionBuild = 0

Expand All @@ -24,4 +25,5 @@ task getVersionNumber{
dependencies {
implementation 'com.google.android.apps.muzei:muzei-api:3.4.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.google.firebase:firebase-analytics:18.0.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;

import com.google.android.apps.muzei.api.provider.Artwork;
import com.google.android.apps.muzei.api.provider.MuzeiArtProvider;
import com.google.firebase.analytics.FirebaseAnalytics;

import net.luxteam.muzeiwebcam.R;
import net.luxteam.muzeiwebcam.utils.Utils;
Expand All @@ -34,6 +36,8 @@ public void onLoadRequested(boolean firstTime) {
}

Context ctx = this.getContext();
final FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(ctx);

String subtitle = SimpleDateFormat.getInstance().format(now);
String title = Utils.getStringValue(ctx, ctx.getString(R.string.preference_key_name), ctx.getString(R.string.app_name));
String url = Utils.getStringValue(ctx, ctx.getString(R.string.preference_key_url));
Expand All @@ -53,6 +57,12 @@ public void onLoadRequested(boolean firstTime) {
.persistentUri(Uri.parse(url))
.build();
setArtwork(artwork);

final Bundle bundle = new Bundle();
bundle.putString("title", title);
bundle.putString("url", url);
bundle.putString(FirebaseAnalytics.Param.SCREEN_CLASS, getClass().getSimpleName());
mFirebaseAnalytics.logEvent("set_artwork", bundle);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// Copyright (c) 2014 Muzei Webcam. All rights reserved.
//

import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
Expand All @@ -17,22 +15,28 @@
import android.widget.ImageView;
import android.widget.TextView;

import com.google.firebase.analytics.FirebaseAnalytics;

import net.luxteam.muzeiwebcam.BuildConfig;
import net.luxteam.muzeiwebcam.R;

import androidx.appcompat.app.AppCompatActivity;

public class AboutActivity extends AppCompatActivity {
private FirebaseAnalytics mFirebaseAnalytics;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

TextView mVersionTextView = (TextView) findViewById(R.id.about_version);
TextView mCreditsTextView = (TextView) findViewById(R.id.about_credits);
ImageView mTwitterImageView = (ImageView) findViewById(R.id.about_twitter);
ImageView mFacebookImageView = (ImageView) findViewById(R.id.about_facebook);
ImageView mGplayImageView = (ImageView) findViewById(R.id.about_gplay);
ImageView mGithubImageView = (ImageView) findViewById(R.id.about_github);
TextView mVersionTextView = findViewById(R.id.about_version);
TextView mCreditsTextView = findViewById(R.id.about_credits);
ImageView mTwitterImageView = findViewById(R.id.about_twitter);
ImageView mFacebookImageView = findViewById(R.id.about_facebook);
ImageView mGplayImageView = findViewById(R.id.about_gplay);
ImageView mGithubImageView = findViewById(R.id.about_github);
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

mVersionTextView.setText(BuildConfig.VERSION_NAME);
mCreditsTextView.setText(Html.fromHtml(getString(R.string.about_credits)));
Expand All @@ -42,6 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_contacts_twitter)));
startActivity(browserIntent);
trackContactEvent("twitter");
}
});

Expand All @@ -50,6 +55,7 @@ public void onClick(View view) {
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_contacts_facebook)));
startActivity(browserIntent);
trackContactEvent("facebook");
}
});

Expand All @@ -58,6 +64,7 @@ public void onClick(View view) {
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_contacts_gplay)));
startActivity(browserIntent);
trackContactEvent("play");
}
});

Expand All @@ -66,7 +73,14 @@ public void onClick(View view) {
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_contacts_github)));
startActivity(browserIntent);
trackContactEvent("gh");
}
});
}

private void trackContactEvent(String contactName) {
final Bundle bundle = new Bundle();
bundle.putString("contact", contactName);
mFirebaseAnalytics.logEvent("open_contact", bundle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
// Copyright (c) 2014 Muzei Webcam. All rights reserved.
//

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.google.firebase.analytics.FirebaseAnalytics;

import net.luxteam.muzeiwebcam.ui.fragment.MWPreferenceFragment;

import androidx.fragment.app.FragmentActivity;
Expand All @@ -22,12 +23,17 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

MWPreferenceFragment f = new MWPreferenceFragment();
final FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

String s = getIntent().getStringExtra(Intent.EXTRA_TEXT);
if(s != null){
Bundle b = new Bundle();
b.putString(MWPreferenceFragment.EXTRA_URL, s);
f.setArguments(b);

final Bundle bundle = new Bundle();
bundle.putString("url", s);
mFirebaseAnalytics.logEvent("grab_url", bundle);
}

getSupportFragmentManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;

import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;

import android.text.TextUtils;
import android.util.Patterns;
import android.view.View;
Expand All @@ -29,6 +23,7 @@
import com.google.android.apps.muzei.api.provider.Artwork;
import com.google.android.apps.muzei.api.provider.ProviderClient;
import com.google.android.apps.muzei.api.provider.ProviderContract;
import com.google.firebase.analytics.FirebaseAnalytics;

import net.luxteam.muzeiwebcam.BuildConfig;
import net.luxteam.muzeiwebcam.R;
Expand All @@ -40,6 +35,11 @@
import java.text.SimpleDateFormat;
import java.util.Date;

import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;

public class MWPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {

public static final String EXTRA_URL = "extraUrl";
Expand Down Expand Up @@ -93,9 +93,13 @@ public void onClick(View view) {
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {

final Activity a = getActivity();
final FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(a);
final Bundle bundle = new Bundle();
bundle.putString("preference_name", s);

if(s.equals(a.getString(R.string.preference_key_grab_url))){
boolean active = Utils.getBooleanValue(a, s);
bundle.putString("preference_value", String.valueOf(active));

PackageManager pm = a.getPackageManager();

Expand All @@ -104,8 +108,13 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
active ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
);
} else if(s.equals(a.getString(R.string.preference_key_name))){
String name = Utils.getStringValue(a, s);
bundle.putString("preference_value", name);
} else if(s.equals(a.getString(R.string.preference_key_url))){
String url = Utils.getStringValue(a, s);
bundle.putString("preference_value", url);

if(TextUtils.isEmpty(url) || !Patterns.WEB_URL.matcher(url).matches()){
Utils.showToast(a, R.string.error_invalid_url);
Utils.storeValue(a, s, null);
Expand All @@ -115,6 +124,8 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}

updateSubtitles();

mFirebaseAnalytics.logEvent("preference_changed", bundle);
}

private void refresh(Context c) {
Expand All @@ -124,6 +135,7 @@ private void refresh(Context c) {
final String title = Utils.getStringValue(c, c.getString(R.string.preference_key_name), c.getString(R.string.app_name));
final String url = Utils.getStringValue(c, c.getString(R.string.preference_key_url), c.getString(R.string.source_default_url));
final Uri uri = Uri.parse(url);
final FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(c);

providerClient.setArtwork(new Artwork.Builder()
.title(title)
Expand All @@ -132,6 +144,11 @@ private void refresh(Context c) {
.token(String.valueOf(now.getTime()))
.persistentUri(uri)
.build());

final Bundle bundle = new Bundle();
bundle.putString("title", title);
bundle.putString("url", url);
mFirebaseAnalytics.logEvent("set_artwork", bundle);
}

private void updateSubtitles() {
Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 0 additions & 4 deletions MuzeiWebcam/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<string name="source_description">Verwenden sie Webcam-Bilder</string>
<string name="source_default_subtitle">Stellen sie eine bild-URL zu starten</string>
<string name="error_invalid_url">Ungültige URL</string>
<string name="command_refresh">Aktualisieren</string>
<string name="preference_title_url">URL</string>
<string name="preference_title_name">Name</string>
<string name="preference_title_wifi_only">Nur WiFi</string>
<string name="preference_title_grab_url">Schnappen URL</string>
<string name="preference_title_interval">Aktualisierungsintervall (minuten)</string>
<string name="preference_summary_wifi_only">Laden sie neue bilder nur über WiFi</string>
<string name="preference_summary_grab_url">Teilen sie eine URL als quelle verwenden</string>
<string name="about_credits"><![CDATA[<b>Standardbild</b> von <em>mich</em><br />https://www.flickr.com/photos/maxcanna<br /><br /><b>Muzei</b> von <em>Ian Lake</em><br />https://github.com/muzei/muzei]]></string>
<string name="about_credits_title">Verdienst</string>
Expand Down
4 changes: 0 additions & 4 deletions MuzeiWebcam/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<string name="source_description">Usar imágenes de webcam</string>
<string name="source_default_subtitle">Configurar una URL de imagen para comenzar</string>
<string name="error_invalid_url">URL no válida</string>
<string name="command_refresh">Actualizar</string>
<string name="preference_title_url">URL</string>
<string name="preference_title_name">Nombre</string>
<string name="preference_title_wifi_only">Sólo WiFi</string>
<string name="preference_title_grab_url">Agarra URL</string>
<string name="preference_title_interval">Intervalo de actualización (minutos)</string>
<string name="preference_summary_wifi_only">Descarga nuevas imágenes sólo en WiFi</string>
<string name="preference_summary_grab_url">Comparta una URL para usarla como origen</string>
<string name="about_credits"><![CDATA[<b>Imagen predeterminadae</b> por <em>me</em><br />https://www.flickr.com/photos/maxcanna/<br /><br /><b>Muzei</b> por <em>Roman Nurik</em><br />https://github.com/romannurik/muzei<br /><br /><b>Calligraphy</b> por <em>Christopher Jenkins</em><br />https://github.com/chrisjenx/Calligraphy]]></string>
<string name="about_credits_title">Crédito</string>
Expand Down
4 changes: 0 additions & 4 deletions MuzeiWebcam/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<string name="source_description">Utiliser des images de webcam</string>
<string name="source_default_subtitle">Choisissez une image pour commencer</string>
<string name="error_invalid_url">URL invalide</string>
<string name="command_refresh">Actualiser</string>
<string name="preference_title_url">URL</string>
<string name="preference_title_name">Nom</string>
<string name="preference_title_wifi_only">WiFi seulement</string>
<string name="preference_title_grab_url">Attraper URL</string>
<string name="preference_title_interval">Intervalle d\'actualisation (minutes)</string>
<string name="preference_summary_wifi_only">Télécharger de nouvelles images uniquement en WiFi</string>
<string name="preference_summary_grab_url">Partagez une URL pour l\'utiliser</string>
<string name="about_credits"><![CDATA[<b>Image par défaut</b> par <em>me</em><br />https://www.flickr.com/photos/maxcanna<br /><br /><b>Muzei</b> par <em>Ian Lake</em><br />https://github.com/muzei/muzei]]></string>
<string name="about_credits_title">Reconnaissances</string>
Expand Down
4 changes: 0 additions & 4 deletions MuzeiWebcam/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<string name="source_description">Usa le immagini di una webcam</string>
<string name="source_default_subtitle">Imposta un\'URL per iniziare</string>
<string name="error_invalid_url">URL invalida</string>
<string name="command_refresh">Aggiorna</string>
<string name="preference_title_url">URL</string>
<string name="preference_title_name">Nome</string>
<string name="preference_title_wifi_only">Solo WiFi</string>
<string name="preference_title_grab_url">Cattura URL</string>
<string name="preference_title_interval">Intervallo aggiornamento (minuti)</string>
<string name="preference_summary_wifi_only">Scarica nuove immagini solo in WiFi</string>
<string name="preference_summary_grab_url">Condividi un\'URL per usarla come fonte</string>
<string name="about_credits"><![CDATA[<b>Immagine predefinita</b> <em>mia</em><br />https://www.flickr.com/photos/maxcanna<br /><br /><b>Muzei</b> di <em>Ian Lake</em><br />https://github.com/muzei/muzei]]></string>
<string name="about_credits_title">Crediti</string>
Expand Down
4 changes: 0 additions & 4 deletions MuzeiWebcam/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<string name="source_description">Usam imagens de webcam</string>
<string name="source_default_subtitle">Definir um URL de imagem para começar</string>
<string name="error_invalid_url">URL inválido</string>
<string name="command_refresh">Atualizar</string>
<string name="preference_title_url">URL</string>
<string name="preference_title_name">Nome</string>
<string name="preference_title_wifi_only">Somente WiFi</string>
<string name="preference_title_grab_url">Agarre URL</string>
<string name="preference_title_interval">Intervalo de atualização (minutos)</string>
<string name="preference_summary_wifi_only">Descarregue novas imagens somente via Wi-Fi</string>
<string name="preference_summary_grab_url">Compartilhar uma URL para usá-lo como fonte</string>
<string name="about_credits"><![CDATA[<b>Imagem predefinida</b> por <em>me</em><br />https://www.flickr.com/photos/maxcanna/<br /><br /><b>Muzei</b> por <em>Ian Lake</em><br />https://github.com/muzei/muzei<br /><br /><b>Calligraphy</b> por <em>Christopher Jenkins</em><br />https://github.com/chrisjenx/Calligraphy]]></string>
<string name="about_credits_title">Créditos</string>
Expand Down
4 changes: 0 additions & 4 deletions MuzeiWebcam/src/main/res/values/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
<resources>
<string translatable="false" name="source_default_url">https://muzeiwebcam.page.link/jpg</string>
<string translatable="false" name="source_default_view_url">https://muzeiwebcam.page.link/flickr</string>
<string translatable="false" name="source_default_interval">1</string>
<string translatable="false" name="url_contacts_twitter">https://muzeiwebcam.page.link/twitter</string>
<string translatable="false" name="url_contacts_facebook">https://muzeiwebcam.page.link/facebook</string>
<string translatable="false" name="url_contacts_gplay">https://muzeiwebcam.page.link/play</string>
<string translatable="false" name="url_contacts_github">https://muzeiwebcam.page.link/gh</string>
<string translatable="false" name="preference_key_url">imageUrl</string>
<string translatable="false" name="preference_key_name">imageName</string>
<string translatable="false" name="preference_key_grab_url">grabUrl</string>
<string translatable="false" name="ga_trackingId" />
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>
5 changes: 0 additions & 5 deletions MuzeiWebcam/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Muzei Webcam</string>
<string name="source_name">Webcam</string>
<string name="source_description">Use webcam images</string>
<string name="source_default_subtitle">Set an image URL to start</string>
<string name="error_invalid_url">Invalid URL</string>
<string name="command_refresh">Refresh</string>
<string name="preference_title_url">URL</string>
<string name="preference_title_name">Name</string>
<string name="preference_title_wifi_only">WiFi only</string>
<string name="preference_title_grab_url">Grab URLs</string>
<string name="preference_title_interval">Refresh interval (minutes)</string>
<string name="preference_summary_wifi_only">Download new images only on WiFi</string>
<string name="preference_summary_grab_url">Share an URL to use it as source</string>
<string name="about_credits"><![CDATA[<b>Default image</b> by <em>me</em><br />https://www.flickr.com/photos/maxcanna<br /><br /><b>Muzei</b> by <em>Ian Lake</em><br />https://github.com/muzei/muzei]]></string>
<string name="about_credits_title">Credits</string>
Expand Down
Loading

0 comments on commit 4cbc884

Please sign in to comment.