From 0b0b41008894551bd0d8239d11f3ced48997999a Mon Sep 17 00:00:00 2001 From: Javi Pacheco Date: Thu, 22 Dec 2016 17:21:01 +0100 Subject: [PATCH] Added Google Analytics preference --- .../icon_preferences_analytics.png | Bin 0 -> 928 bytes .../icon_preferences_feedback.png | Bin 0 -> 345 bytes .../icon_preferences_analytics.png | Bin 0 -> 650 bytes .../icon_preferences_feedback.png | Bin 0 -> 228 bytes .../icon_preferences_analytics.png | Bin 0 -> 1129 bytes .../icon_preferences_feedback.png | Bin 0 -> 316 bytes .../icon_preferences_analytics.png | Bin 0 -> 1518 bytes .../icon_preferences_feedback.png | Bin 0 -> 427 bytes .../icon_preferences_analytics.png | Bin 0 -> 1892 bytes .../icon_preferences_feedback.png | Bin 0 -> 544 bytes .../app/src/main/res/values-es/strings.xml | 10 +++++++ modules/app/src/main/res/values/strings.xml | 8 ++++++ .../main/res/xml/preferences_analytics.xml | 17 ++++++++++++ .../main/res/xml/preferences_devs_headers.xml | 8 +++++- .../src/main/res/xml/preferences_headers.xml | 8 +++++- .../scala/cards/nine/app/di/Injector.scala | 13 ++++++--- .../NineCardsPreferencesActivity.scala | 4 +++ .../analytics/AnalyticsFragment.scala | 17 ++++++++++++ .../commons/NineCardsPreferences.scala | 14 ++++++++++ .../track/impl/DisableTrackServices.scala | 25 ++++++++++++++++++ 20 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 modules/app/src/main/res/drawable-hdpi/icon_preferences_analytics.png create mode 100644 modules/app/src/main/res/drawable-hdpi/icon_preferences_feedback.png create mode 100644 modules/app/src/main/res/drawable-mdpi/icon_preferences_analytics.png create mode 100644 modules/app/src/main/res/drawable-mdpi/icon_preferences_feedback.png create mode 100644 modules/app/src/main/res/drawable-xhdpi/icon_preferences_analytics.png create mode 100644 modules/app/src/main/res/drawable-xhdpi/icon_preferences_feedback.png create mode 100644 modules/app/src/main/res/drawable-xxhdpi/icon_preferences_analytics.png create mode 100644 modules/app/src/main/res/drawable-xxhdpi/icon_preferences_feedback.png create mode 100644 modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_analytics.png create mode 100644 modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_feedback.png create mode 100644 modules/app/src/main/res/xml/preferences_analytics.xml create mode 100644 modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala create mode 100644 modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala diff --git a/modules/app/src/main/res/drawable-hdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-hdpi/icon_preferences_analytics.png new file mode 100644 index 0000000000000000000000000000000000000000..4828ecdb937c86d325b8361d64d2f0c30b7c8f0a GIT binary patch literal 928 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`ZSkfJR9T^xl_H+M9WMyDr%nR@d zaRrM1|Np<KM4gC3u@-=uU^=t$x6tc}BaED{?cE_L{PCzvwK=xLkX%2xv5unCx4nf<2$UbKtZr9&>SEa$Oan=Vmkx@m2Cx!Yz6BD zvJniBVz3&RO0fALD;{nS5C+gjs74S2Yz|0Q;8vxK@IGLO zSC$0%1v4-*F|)9;ad2{R^Y97?ii%4}$;c}xDyyn%XzJ=48k<;JIXJtxd3bsI`Ui(Z zM8zefXXX?Xm6lc4H8!=hc69YmoH=XmyhTe_t=X_~%l4hS4;(yn_~^+~XD?j5eC5W? zTet7rfB5L}(`V0Lzj^!q!^clwzJB}u#wcl#dETj%PnU*ePyv%pZPmng7&F<KYyGqe#a0P(F~rhelF{r G5}E)VsFp$i literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-hdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-hdpi/icon_preferences_feedback.png new file mode 100644 index 0000000000000000000000000000000000000000..10aa9dc1c1bb010f4503d5a3ec024e04d1014611 GIT binary patch literal 345 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`ZSkfJR9T^xl_H+M9WCikF1AIbU zf%O0X|J_4(I0o);2-)r&xYZ$Wn|%lFz zu{izq@?E}W1s>Lfltt3(gl}H^ULSH$=MRflq4@47{j=0qM z&*|TFv{E{QuQ)1;zj$F|nZ enAZIxt<1Yng|+>@+$^9&89ZJ6T-G@yGywpG6pdg2 literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-mdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-mdpi/icon_preferences_analytics.png new file mode 100644 index 0000000000000000000000000000000000000000..d28ea3b5a71e2e59e816db0cc537873608a6a510 GIT binary patch literal 650 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAv7|ftIx;Y9?C1WI$O`2D5AX?b z1=0WiH#GbY4gH^%b|y6Rm~Yw{x7eKyq5J)kj(A3Ia|_(*9<;+XVwXeEHn)hKE}^?! zg7>%v?{W#=<{Y%$DRhTp@J^?Yoz5XUoC3Ew2X1u=+2$C$!!c;9eb5faz-{({TOERc z2q?JCA!xgO;5G-KAdm}W14*DPNF0QKT%ZD=ELbmCBoJr_L>$Zja)H`G%76@znIJ7N z^TEb~1;OTnEQM$XYXPda2Rj3z49Er=1r#*gGCdj?1R*6se!&ckOw6pDT--dod}5MP zGO}_?s)nX!=2o^&uAX60v2lqh#dYxUEMvCXU<-*Xz7ZT>o#rKdg$2k6DLof zJAe7gjfan)K70P+<;TxozkUDl^Y6dZo1r&==3n!4aSYKozxGmOcvFA~>jUOC=ZVWa zmrc^>i(D4g_q4}yY3G~&|D%&Gaz#|kk9jw}`rA*rbEj3U(nGFp7O)S##$Byy<@$Gp$RmnO+^6CSIZHZOQ*8e9guioGw{KHUq*DLNB1v1?8BrTt+|6w}g==M1_ TeBC*q4;egN{an^LB{Ts5`+FAI literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-mdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-mdpi/icon_preferences_feedback.png new file mode 100644 index 0000000000000000000000000000000000000000..f9a92f8a1eb50b1fe2772fa75e8d49c5f757e641 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaN3?zjj6;1;wmUKs7M+SzC{oH>NS%G|&0G|+7 zAng>g%`tepL(q1I;H~z-+Z=+o*#~WN2-;>JxYa%oMBbdy?gUiFT@vIM%;1@po{^ce z_3@{F2J90JfWjf3E{-7*my;75*m~~nR!m@?aCoD1=i$AKo|01R%d*=UCNN*W%JAfX z2veq1kpSPJCk=BpH}bxb>G*Dz(k#mrxG{G+<01Lo(-kVS!Wo(l+jTMm-K?kKAQ!{E R;Th0;22WQ%mvv4FO#meFNVxz2 literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-xhdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-xhdpi/icon_preferences_analytics.png new file mode 100644 index 0000000000000000000000000000000000000000..d4b216f9a0684de903bee59fb45579198c8eab02 GIT binary patch literal 1129 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sEa{HEjtmSN`?>!lvNA9*&Is@c zaRrM1|Np5 z-0v2+(>-X1Tf|P6(A`eq+Z;l7xCZZX2;S)&y3HkYt7G5}m*8zqK|36Rw>pLHa17q* z7z9+a-5DgZ!zpB&WAJu|Krka{hZ9KUc84IK;0_?^5V+kwc)MfJRtKP(pzZd7TOEV9 z0U00^yww574Foal1GhT@xgho1fGQzs?15~M#%=aMageTUKzr?hB0)f1U_$~yQjURO zjUc^SK`J4-f`Dd%H3CVX0+1j?FPIBc3{(%c1tJJi2G#{M2h0W=0&*3Q0VZKqfVf~| zK~}>}0J{z303ZYI5)d2ghBIG_8-Q`sUJ~RN%)rRR%)-jX&dJ5i%O@ZxEFvZ;E2pfY zs-dN;Z)jv)5U%!3-@$=X3KY#xf{EZg|CYzU@E{-7{$KOu<86FfUaD4s_wIz&N%brYnnm6lN z(6py)Srd2fT((Ga+U_8(NlFj?+^%asE_}f|?%c;8&CB0gzCU+n?#~bJs=xF32mX8g zZprL-9=&eAFX%c*U(7lh>T+TKYuF)m`QKk|l&D`)%ywEZRXIG=+Yql z^jVo6-P~iU!W6gRHqY~~c{6rM+&lE6H~6y(L(ugHx}Th;xbLmsy4+IV@_vU)CFJAY~%7AzCOvy}ftBT2s?zLWbQ(7?1ckVU43q?E2!lvI6bP0l+XkK-41-N literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_analytics.png new file mode 100644 index 0000000000000000000000000000000000000000..daa4be532b895a2c1fac1324620b0e82fac1c8cf GIT binary patch literal 1518 zcmXw&2~ZPP7{`|*D2I?Da;qsKNI*dZ1&?Mo350-&sc<%9k(r|z z1VM|KA#^U-L-1#z5qQU~qosn)I1ynX5G2hvpW97 zgu5vEkSUbIyHqIJ%}Tf%9NPk;Dt25aGg?kZ+dw~Thnj&ZXgk}Ps63d1PZ?ZAP-H6= zRR%}4P`OGt5(`FK=)87ngd7HBgbe1j&?DMts2t%bU``8-hansVjJ8s_3YaIOaWN{Y zfVpxSioqyG<0}wU4)ZY@SAp;`n5RGh4@ka@%9A5p4B-P6u#y1@g@fU58~`a81xPq@ zP{3Rn1!q739Aq#DOyv}=9N}Pk3BuK3JUIXm+*S^Aa6nJ$o%IoTUzerx2Ub8L!&86| z@F151$10}=r1d5SJ&-Up24G0>kM0Z&~Y zm*6UpsQUzcG(MU?&-`I<6CH^k39ogGaErMD+=I(0Ts99fFf=kIm@HUmYG!V+$kK}V zh4tbkw)PH=PD_`QzI0jP>bA;*?CG_}+sD_>e|wn+8eK$Vwe)7Mm>6wqS zbDuuBHRS zXQGRKLiD%Tu$PPI>!RalDe?}mxZy|2FK>=|*9r5gK( z^|cb`HWyY;LjGa>cOqHZwB-J;$Vp=ahZ9ZR5uN5DZeG!pKY3zzPg9}YQ0U580=vI% z)%JGlL&$+962EkrAT_j)Lsody5PF@CDAxuie%^3*`TcEHDMqA$W>*J|?^wl>0mG7G zanDCH)RbXQ!*idJie(KsTc=}c`;zPPV(q=+f7nlYIqcZgXDO-(AL@V{Zo0zn>X8rW zVw3*!Q9LCEb*3!1D&XXu^psjz2b8+U`BskbyJE%7Dy6qZ_4M>N zGb0w^{#~obXSYD)48e%4AVFSO9TT!*Y&OQ5zPOAy+zv``7vy+l z=9-l7Qr?J9z4x~(H|l^gRz0asmR{QCq9Gm^pKz!&E0rv@Dc^^MMu}g!#chhUiG_p( z*YfKGron{8#D)#b3<9Pm4rkq|RXLD0U2PofE`NM@QZXd>^f-h1ugBcWEUP>twts73Pm(sKNj4pz zAH2Z0RC{zV-K61X+x#A7O|tZ@Xsv454P@M-)%xDpU=opDD%D;wFbOG>B>OI>TC)Nz z2Fwer<3IG)Yu1NcL!wvuz>hR%%Yzw|ngKs^dXePpnQ>+aj|rztYKZ5R?Ul2meg^Kh zRTg>wki0dL2~(Fn1pz_A4)cv6MR5goL$!zO?>pP9DWc?xvpPKvTLmBwHqJfX?leZ& mTjwSCrE-CDZ>F%Y;rck;LWia4KTo~ctN?Z~L!{gj*2 z#FG8Nad*k*%!LN-w;kl)*r@Wc%?#iy+Nu!G{i}xih~SHCf!z0djJeuhRHvJ=O?@*r zl%qte@(EjG*SB+u0T=I8vMjP|-Tt3d$U~u#MJR(!K>ZPi3Hu3ukv8Y~9j2D7>Q9d> zm>Rq@$gii)Qq|yTgzJi>n(o0}pB^9HIG^iHrT8D4^QlL*B`!vOp2c-va>2ouW_R8l zDUVy2#~rFL&)Dg@Y)In{zAeq0pPSuVHi@}=8SnPbLjTI&O_{x@{^bcFcc51pJYD@< J);T3K0RSJKt0e#c literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_analytics.png new file mode 100644 index 0000000000000000000000000000000000000000..9c28ef300bd18d78e59b7e3a13362147613215ce GIT binary patch literal 1892 zcmYk63se(l7Jvsrz=A{sDC2Fk}Y$h23MC37(3|KX>lE-*@kvGba_% zk)e+E%k3cua^!{uW8gQDxEGMXIUG_>6l_vi5iAJ$d7s0pBr*h9XGL%3b3oo~HcKRC z95=&~E}?J$$A`IDDmbwV$1g?*2SO6GFy0lJ+|7+w1>pav1brm#o}p#aV5f2 zvrr9;cLeiPY)r$#wJ=YKU}`q5Vezyurb2KvjH?koD5+q+8Ua1vM3rnlFsNZvLj;%x z<||p48YU!a(7@s;0n0=|gPI9OU`iNOF#(IJU`)+KK^5dJ27*!&G00#l7C_#ygalAv z3J;WkUj_W22e2@vWTF63S+oQTqe=^|BzjQG0t8D?Z&_ji;Qv1kB=2w#SQaMa#AVs= z?Ky8I<`OJ1g#Zcd+ehFhO7oXx9N2AMV(9@Tf+Au|Fu%NI1o0LGZjpoFt;+ItMA8!c zVGv=M-_gMKSPp=QD-m82*qWSsLKMr85UbFU-b)T-^5VVmAvk*>5Xc#wq zb7VA%@%XqPZcBW^w#1~r>=34k($cebX6NMQ6^Q@(<=?(4Dwcdxvb#)LUQt=Kw_5)9 z{ofv}JyieQ_YIAQfBeUhqfN(tI^J@!we9D2#c8El({ZNrY?n^oec@tHU;m|n%fAj@ z{nzmIk$)R*j{axtmT_Y8x7)wpnYwrXztayMKAL&_ zA9O&A-@6g%*dFXYw9@(67p9l|*M0jpeB)yL;2QO@)n@o$UN#-l=ciPRE9@@GsXg7~ zE5jw!HDtP^s5dvrb@(NkFK3` zl&q!g5p66UTurU>)ldX?bB>muwp}lM5ngg%B3=Ga{(5&*m8pEBV*L8qEGYB9Cc%m0 zWq0ia?MRM?aXV*!o={{vSl)G5A(|0eG%_K+Vi)AAh&<)EAw# zB8F=lsZjreYH$_8-}%7zbA4(+7CSnKL7Fo=UlyM`uXBGKHA6p<+lQsmoy#Dr!Aq!1;kYMnji-G$wBqS#)l7m-#0NsjO+Uei{x|W_7^&~6 zrFKfhspbMjaC}(0P}^eK<{>R6Ge|*Q>1wb1vF0bW1)D-}GAMQS`7{Pe_*ojVn{2|~WVBrd^F9h4mS%RY z@MLb9>|Q;W0j=|?^>88~2jh9T>f)uFu4cvFvYm^5cbB3U-_guZan!y?oiIw zT{F7twF**oi$Ok@2C8$)=utnPfE25%j%6B zo^E0>Rho>>n0+!gC%V#02r}rGs!u;f(MFnJXzZe7 z4Ti%@tzu4lA>-U*g=9E%T;@raWN)k&_Xj~4Nw+v#q1LO?rwZ_~^OPgg4jRh+B@@;^ zUBrj$F5AhW$>kH)ZANu!EB3iWbfenY6<%eKCnKbs%c}JA={oRl1#vl%!Kc`XCI172XHc8~ literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_feedback.png new file mode 100644 index 0000000000000000000000000000000000000000..f8a98d28ebba25e861b27fe57bd21882e84f2218 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wSy#B(j9#r85lP9bN@+X1@e;vd_r7- zbZF>R_n;jPLE9XIcQ^#@bP3(+9K78zaEC+aE|=hKPC+{yLw7m^Z*>gX22|q^xXmGW zyM54Bhrq3lfm`i^w%G@61Cl^4PzuZiN!bIrK&c=Qqx#3q&p>MwN`m}?8Q3Icv~_g# z^bHJ+j7_ZjCrp{Tc-h{o&tAWI`|kax&woELeDY#oV6^dcaSX}0_jcw@zrzLsuIg9b zcpGfdTq5xM|9&C4h-GWv-1r*Pxxo7TNy|y5-%eatT4Nu)PJY>q2+5k~&N=IO>V=g< z9w>)BV2Zflz9GSZTW!mN1^u_Xn7G8WGG_8$zOY-;@pBEwzSEpK&kip;%`s2MPi?-~ zoY`mEA53a;pM7|%KUdGQ!xKa#&bDi6X56iC{~zqY$SM*5Bf146;?HO7Blk}HG5&W?*t?bX@h!=kAJg^2Drj}BiB_ci{j*<+ z^sdc$d;W05=N8^2KlH^L7{Wj6GjeWxv|s8|J*-e~endl>KjE!XCjD z2j=b9zj5>Pcb47Jja&*fH~)QlFHjR%|M|W_O=NHU-(vj*QETnPGk@2ptx>(o&hRuv VdDb=V>A)~&@O1TaS?83{1OOfc>5>2d literal 0 HcmV?d00001 diff --git a/modules/app/src/main/res/values-es/strings.xml b/modules/app/src/main/res/values-es/strings.xml index 1198bcfc6..70c902316 100644 --- a/modules/app/src/main/res/values-es/strings.xml +++ b/modules/app/src/main/res/values-es/strings.xml @@ -618,6 +618,16 @@ Movimiento Fondo de Pantalla La imagen de fondo se mueve en el desplazamiento entre pantallas en el launcher + + + Analítica + Aprende más sobre nuestra política de analítica + + Habilitar analítica + 9 Cards usa Google Analytics para trackear el comportamiento independientemente de como ellos usas las apps. La información es anónima y es usada con el propósito de la generación de estadísticas de las apps más populares, mejores colecciones y mejor experiencia del usuario. Los datos son sólo usados con este propósito y no son vendidos, publicados ni usados de otra manera que para mejorar la experiencia en el Launcher. Si prefieres que tus datos anónimos no sean usados tu puedes deshabilitarlo + + + Opciones para Desarrolladores Activada diff --git a/modules/app/src/main/res/values/strings.xml b/modules/app/src/main/res/values/strings.xml index 864296ddd..e4396cb2e 100644 --- a/modules/app/src/main/res/values/strings.xml +++ b/modules/app/src/main/res/values/strings.xml @@ -630,6 +630,14 @@ Wallpaper movement The background image will move along with you as you swipe left or right through your home screens + + + Analytics + Learn more about our analytics + + Analytics Enable + 9 Cards uses Google Analytics to track user behavior regarding how they open and use apps. This user data is anonymous and is collected for the purpose of generating statistics on popular apps, best collections, and improving your user experience. The data is only used for this purpose and will not be sold, published, or used in any other manner, other than to improve the functionality of this launcher. If you prefer that your anonymous data is not used, you may opt-out here + Developer options activated diff --git a/modules/app/src/main/res/xml/preferences_analytics.xml b/modules/app/src/main/res/xml/preferences_analytics.xml new file mode 100644 index 000000000..bfa2a3840 --- /dev/null +++ b/modules/app/src/main/res/xml/preferences_analytics.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/app/src/main/res/xml/preferences_devs_headers.xml b/modules/app/src/main/res/xml/preferences_devs_headers.xml index 156e2a749..e2d8bf9ed 100644 --- a/modules/app/src/main/res/xml/preferences_devs_headers.xml +++ b/modules/app/src/main/res/xml/preferences_devs_headers.xml @@ -28,6 +28,12 @@ android:key="animationsKey" android:summary="@string/animationsPrefSummary"/> + + diff --git a/modules/app/src/main/res/xml/preferences_headers.xml b/modules/app/src/main/res/xml/preferences_headers.xml index 17c569d78..eae297d64 100644 --- a/modules/app/src/main/res/xml/preferences_headers.xml +++ b/modules/app/src/main/res/xml/preferences_headers.xml @@ -28,6 +28,12 @@ android:key="animationsKey" android:summary="@string/animationsPrefSummary"/> + + @@ -45,7 +51,7 @@ android:summary="@string/aboutSummary"/> diff --git a/modules/app/src/main/scala/cards/nine/app/di/Injector.scala b/modules/app/src/main/scala/cards/nine/app/di/Injector.scala index 1015dbd78..bc6052a95 100644 --- a/modules/app/src/main/scala/cards/nine/app/di/Injector.scala +++ b/modules/app/src/main/scala/cards/nine/app/di/Injector.scala @@ -4,7 +4,12 @@ import android.content.res.Resources import cards.nine.api.rest.client.ServiceClient import cards.nine.api.rest.client.http.OkHttpClient import cards.nine.app.observers.ObserverRegister -import cards.nine.app.ui.preferences.commons.{BackendV2Url, IsStethoActive, OverrideBackendV2Url} +import cards.nine.app.ui.preferences.commons.{ + AnalyticsEnabled, + BackendV2Url, + IsStethoActive, + OverrideBackendV2Url +} import cards.nine.commons.contentresolver.{ContentResolverWrapperImpl, UriCreator} import cards.nine.commons.contexts.ContextSupport import cards.nine.models.types.NineCardsCategory @@ -55,7 +60,7 @@ import cards.nine.services.permissions.impl.AndroidSupportPermissionsServices import cards.nine.services.persistence.impl.PersistenceServicesImpl import cards.nine.services.plus.impl.GooglePlusServicesImpl import cards.nine.services.shortcuts.impl.ShortcutsServicesImpl -import cards.nine.services.track.impl.ConsoleTrackServices +import cards.nine.services.track.impl.{ConsoleTrackServices, DisableTrackServices} import cards.nine.services.widgets.impl.WidgetsServicesImpl import cards.nine.services.connectivity.impl.ConnectivityServicesImpl import com.facebook.stetho.okhttp3.StethoInterceptor @@ -249,7 +254,9 @@ class InjectorImpl(implicit contextSupport: ContextSupport) extends Injector { override def trackEventProcess: TrackEventProcess = { def createService() = { val resources = contextSupport.getResources - if (resources.getString(R.string.analytics_enabled).equalsIgnoreCase("true")) { + if (!AnalyticsEnabled.readValueWith(contextSupport.context)) { + new DisableTrackServices + } else if (resources.getString(R.string.analytics_enabled).equalsIgnoreCase("true")) { val track = GoogleAnalytics .getInstance(contextSupport.context) .newTracker(resources.getString(R.string.ga_trackingId)) diff --git a/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala b/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala index 8199efd8f..b027fd4f8 100644 --- a/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala +++ b/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala @@ -7,6 +7,7 @@ import android.preference.{Preference, PreferenceActivity, PreferenceFragment} import android.view.MenuItem import cards.nine.app.ui.commons.ops.TaskServiceOps._ import cards.nine.app.ui.preferences.about.AboutFragment +import cards.nine.app.ui.preferences.analytics.AnalyticsFragment import cards.nine.app.ui.preferences.animations.AnimationsFragment import cards.nine.app.ui.preferences.appdrawer.AppDrawerFragment import cards.nine.app.ui.preferences.commons._ @@ -79,6 +80,9 @@ class NineCardsPreferencesActivity findPreference(AnimationsPreferences.name).setOnPreferenceClickListener( preferenceClick(AnimationsPreferences.name, new AnimationsFragment())) + findPreference(AnalyticsPreferences.name).setOnPreferenceClickListener( + preferenceClick(AnalyticsPreferences.name, new AnalyticsFragment())) + findPreference(WizardInlinePreferences.name).setOnPreferenceClickListener( preferenceActionClick(() => jobs.cleanWizardInlinePreferences().resolveAsync())) diff --git a/modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala b/modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala new file mode 100644 index 000000000..2c3823dfc --- /dev/null +++ b/modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala @@ -0,0 +1,17 @@ +package cards.nine.app.ui.preferences.analytics + +import android.os.Bundle +import cards.nine.app.ui.preferences.commons.PreferenceChangeListenerFragment +import com.fortysevendeg.ninecardslauncher.R + +class AnalyticsFragment extends PreferenceChangeListenerFragment { + + override def onCreate(savedInstanceState: Bundle): Unit = { + super.onCreate(savedInstanceState) + withActivity { activity => + Option(activity.getActionBar) foreach (_.setTitle(getString(R.string.analyticsPrefTitle))) + } + addPreferencesFromResource(R.xml.preferences_analytics) + } + +} diff --git a/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala b/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala index 5420447aa..99244e0ad 100644 --- a/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala +++ b/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala @@ -31,6 +31,10 @@ case object AnimationsPreferences extends NineCardsPreferences { override val name: String = "animationsKey" } +case object AnalyticsPreferences extends NineCardsPreferences { + override val name: String = "analyticsKey" +} + case object DeveloperPreferences extends NineCardsPreferences { override val name: String = "developerKey" } @@ -258,6 +262,16 @@ case object CardPadding extends NineCardsPreferenceValue[IconsSizeValue] { } } +// Analytics + +case object AnalyticsEnabled extends NineCardsPreferenceValue[Boolean] { + override val name: String = "analyticsEnabled" + override val default: Boolean = true + + override def readValueWith(context: Context): Boolean = + getBoolean(context, name, default) +} + // Developer Preferences case object IsDeveloper extends NineCardsPreferenceValue[Boolean] { diff --git a/modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala b/modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala new file mode 100644 index 000000000..b0b777390 --- /dev/null +++ b/modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala @@ -0,0 +1,25 @@ +package cards.nine.services.track.impl + +import cards.nine.commons.services.TaskService +import cards.nine.commons.services.TaskService._ +import cards.nine.models.TrackEvent +import cards.nine.models.types.MomentCategory +import cards.nine.services.track.TrackServices +import monix.eval.Task + +class DisableTrackServices extends TrackServices { + + override def trackEvent(event: TrackEvent): TaskService[Unit] = TaskService { + val categoryName = event.category match { + case MomentCategory(moment) => s"WIDGET_${moment.name}" + case _ => event.category.name + } + + Task(Right(println(s"""Event no tracked + | Action ${event.action.name} + | Category $categoryName + | Label ${event.label.getOrElse("")} + | Screen ${event.screen.name} + | Value ${event.value.map(_.value).getOrElse(0)}""".stripMargin))) + } +}