Skip to content

Commit

Permalink
Add tracking for browser type.
Browse files Browse the repository at this point in the history
  • Loading branch information
mopsalarm committed Sep 17, 2017
1 parent ad7ac1b commit d866a60
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
15 changes: 15 additions & 0 deletions app/src/main/java/com/pr0gramm/app/services/Track.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ object Track {
}
}

fun gotoFirefoxFocusWebsite() {
send {
setCategory("FirefoxFocus")
setAction("Website")
}
}

fun openBrowser(type: String) {
send {
setCategory("Browser")
setAction("Open")
setLabel(type)
}
}

fun upload(size: Long) {
val categoryStart = size / (512 * 1024) * 512

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/pr0gramm/app/util/BrowserHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.support.customtabs.CustomTabsService
import android.support.v4.content.ContextCompat
import com.pr0gramm.app.R
import com.pr0gramm.app.services.ThemeHelper
import com.pr0gramm.app.services.Track
import com.pr0gramm.app.ui.showDialog
import com.thefinestartist.finestwebview.FinestWebView
import java.util.*
Expand Down Expand Up @@ -64,14 +65,17 @@ object BrowserHelper {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
intent.`package` = packageName
context.startActivity(intent)
Track.openBrowser("FirefoxFocus")
return
}

showDialog(context) {
dontShowAgainKey("hint.install-firefox-focus")
content(R.string.hint_use_firefox_focus)

positive(R.string.play_store) {
openCustomTab(context, "https://play.google.com/store/apps/details?id=org.mozilla.klar&hl=en")
Track.gotoFirefoxFocusWebsite()
}

negative(R.string.not_now) {
Expand All @@ -85,6 +89,8 @@ object BrowserHelper {
}

private fun openInWebView(context: Context, url: String) {
Track.openBrowser("WebView")

FinestWebView.Builder(context.applicationContext)
.theme(ThemeHelper.theme.noActionBar)
.iconDefaultColor(Color.WHITE)
Expand All @@ -104,6 +110,7 @@ object BrowserHelper {
// get the chrome package to use
val packageName = chromeTabPackageName(context)
if (packageName == null) {
Track.openBrowser("External")
context.startActivity(Intent(Intent.ACTION_VIEW, uri))
return
}
Expand All @@ -122,5 +129,6 @@ object BrowserHelper {
}

customTabsIntent.launchUrl(themedContext, uri)
Track.openBrowser("CustomTabs")
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<color name="stats_fav">#d45099</color>

<color name="type_sfw">#2f9b16</color>
<color name="type_nsfw">#94881e</color>
<color name="type_nsfl">#8c2d8e</color>
<color name="type_nsfw">#c9cc28</color>
<color name="type_nsfl">#843924</color>

</resources>

0 comments on commit d866a60

Please sign in to comment.