Matthew Finkel pushed to branch android-components-57.0.6-10.0-2 at The Tor Project / Applications / android-components

Commits:

9 changed files:

Changes:

  • build.gradle
    ... ... @@ -126,7 +126,13 @@ subprojects {
    126 126
                 rename { 'manifest.json' }
    
    127 127
                 into extDir
    
    128 128
     
    
    129
    -            def values = ['version': rootProject.ext.config.componentsVersion + "." + new Date().format('MMddHHmmss')]
    
    129
    +            def systemEnvBuildDate = System.getenv('MOZ_BUILD_DATE')
    
    130
    +            // MOZ_BUILD_DATE is in the YYYYMMDDHHMMSS format. Thus, we only use a
    
    131
    +            // substring of it if it is available.
    
    132
    +            def values = ['version': rootProject.ext.config.componentsVersion + "." +
    
    133
    +                          (systemEnvBuildDate != null ?
    
    134
    +                           systemEnvBuildDate.substring(4) :
    
    135
    +                           new Date().format('MMddHHmmss'))]
    
    130 136
                 inputs.properties(values)
    
    131 137
                 expand(values)
    
    132 138
             }
    

  • components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/DisplayToolbar.kt
    ... ... @@ -476,6 +476,7 @@ class DisplayToolbar internal constructor(
    476 476
             @ColorInt val color = when (siteSecurity) {
    
    477 477
                 Toolbar.SiteSecurity.INSECURE -> colors.securityIconInsecure
    
    478 478
                 Toolbar.SiteSecurity.SECURE -> colors.securityIconSecure
    
    479
    +            Toolbar.SiteSecurity.ONION -> colors.securityIconSecure
    
    479 480
             }
    
    480 481
             if (color == Color.TRANSPARENT) {
    
    481 482
                 views.securityIndicator.clearColorFilter()
    

  • components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/SiteSecurityIconView.kt
    ... ... @@ -43,6 +43,11 @@ internal class SiteSecurityIconView @JvmOverloads constructor(
    43 43
                     View.mergeDrawableStates(drawableState, intArrayOf(R.attr.state_site_secure))
    
    44 44
                     drawableState
    
    45 45
                 }
    
    46
    +            SiteSecurity.ONION -> {
    
    47
    +                val drawableState = super.onCreateDrawableState(extraSpace + 1)
    
    48
    +                View.mergeDrawableStates(drawableState, intArrayOf(R.attr.state_site_onion))
    
    49
    +                drawableState
    
    50
    +            }
    
    46 51
             }
    
    47 52
         }
    
    48 53
     }

  • components/browser/toolbar/src/main/res/drawable/mozac_ic_site_security.xml
    ... ... @@ -3,6 +3,9 @@
    3 3
        - License, v. 2.0. If a copy of the MPL was not distributed with this
    
    4 4
        - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
    
    5 5
     <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ac="http://schemas.android.com/apk/res-auto">
    
    6
    +    <item
    
    7
    +        android:drawable="@drawable/mozac_ic_onion"
    
    8
    +        ac:state_site_onion="true" />
    
    6 9
         <item
    
    7 10
             android:drawable="@drawable/mozac_ic_lock"
    
    8 11
             ac:state_site_secure="true" />
    

  • components/browser/toolbar/src/main/res/values/attrs_browser_toolbar.xml
    ... ... @@ -27,6 +27,10 @@
    27 27
         <attr name="state_site_secure" format="boolean"/>
    
    28 28
       </declare-styleable>
    
    29 29
     
    
    30
    +  <declare-styleable name="BrowserToolbarSiteOnionState">
    
    31
    +    <attr name="state_site_onion" format="boolean"/>
    
    32
    +  </declare-styleable>
    
    33
    +
    
    30 34
       <declare-styleable name="ActionContainer">
    
    31 35
         <attr name="actionContainerItemSize" format="dimension" />
    
    32 36
       </declare-styleable>
    

  • components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt
    ... ... @@ -385,6 +385,7 @@ interface Toolbar {
    385 385
         enum class SiteSecurity {
    
    386 386
             INSECURE,
    
    387 387
             SECURE,
    
    388
    +        ONION,
    
    388 389
         }
    
    389 390
     
    
    390 391
         /**
    

  • components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarPresenter.kt
    ... ... @@ -16,6 +16,7 @@ import mozilla.components.concept.toolbar.Toolbar
    16 16
     import mozilla.components.concept.toolbar.Toolbar.SiteTrackingProtection
    
    17 17
     import mozilla.components.feature.toolbar.internal.URLRenderer
    
    18 18
     import mozilla.components.lib.state.ext.flowScoped
    
    19
    +import mozilla.components.support.ktx.kotlin.isOnionUrl
    
    19 20
     import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
    
    20 21
     
    
    21 22
     /**
    
    ... ... @@ -64,7 +65,11 @@ class ToolbarPresenter(
    64 65
                 toolbar.displayProgress(tab.content.progress)
    
    65 66
     
    
    66 67
                 toolbar.siteSecure = if (tab.content.securityInfo.secure) {
    
    67
    -                Toolbar.SiteSecurity.SECURE
    
    68
    +                if (tab.content.url.isOnionUrl()) {
    
    69
    +                    Toolbar.SiteSecurity.ONION
    
    70
    +                } else {
    
    71
    +                    Toolbar.SiteSecurity.SECURE
    
    72
    +                }
    
    68 73
                 } else {
    
    69 74
                     Toolbar.SiteSecurity.INSECURE
    
    70 75
                 }
    

  • components/support/ktx/src/main/java/mozilla/components/support/ktx/kotlin/String.kt
    ... ... @@ -115,6 +115,15 @@ fun String.tryGetHostFromUrl(): String = try {
    115 115
         this
    
    116 116
     }
    
    117 117
     
    
    118
    +/**
    
    119
    + * Returns whether the string is an .onion URL.
    
    120
    + */
    
    121
    +fun String.isOnionUrl(): Boolean = try {
    
    122
    +    URL(this).host.endsWith(".onion")
    
    123
    +} catch (e: MalformedURLException) {
    
    124
    +    false
    
    125
    +}
    
    126
    +
    
    118 127
     /**
    
    119 128
      * Compares 2 URLs and returns true if they have the same origin,
    
    120 129
      * which means: same protocol, same host, same port.
    

  • components/ui/icons/src/main/res/drawable/mozac_ic_onion.xml
    1
    +<?xml version="1.0" encoding="utf-8"?>
    
    2
    +<!-- This Source Code Form is subject to the terms of the Mozilla Public
    
    3
    +   - License, v. 2.0. If a copy of the MPL was not distributed with this
    
    4
    +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
    
    5
    +<vector xmlns:android="http://schemas.android.com/apk/res/android"
    
    6
    +        android:width="24dp"
    
    7
    +        android:height="24dp"
    
    8
    +        android:viewportWidth="24"
    
    9
    +        android:viewportHeight="24">
    
    10
    +    <path
    
    11
    +        android:pathData="m12.0215,20.5903c0,0 0,-1.2728 0,-1.2728 4.0319,-0.0117 7.2965,-3.283 7.2965,-7.3177 0,-4.0345 -3.2646,-7.3058 -7.2965,-7.3175 0,0 0,-1.2728 0,-1.2728 4.7348,0.0119 8.5691,3.8529 8.5691,8.5903 0,4.7377 -3.8342,8.5789 -8.5691,8.5906 0,0 0,0 0,0m0,-4.4551c2.2741,-0.012 4.1148,-1.8582 4.1148,-4.1355 0,-2.277 -1.8407,-4.1233 -4.1148,-4.1352 0,0 0,-1.2726 0,-1.2726 2.9773,0.0116 5.3877,2.4278 5.3877,5.4078 0,2.9802 -2.4103,5.3964 -5.3877,5.408 0,0 0,-1.2725 0,-1.2725m0,-6.3616c1.2199,0.0116 2.2057,1.0033 2.2057,2.2261 0,1.2231 -0.9858,2.2147 -2.2057,2.2264 0,0 0,-4.4525 0,-4.4525M1.5,11.9997C1.5,17.799 6.2008,22.5 12,22.5 17.799,22.5 22.5,17.799 22.5,11.9997 22.5,6.2008 17.799,1.5 12,1.5 6.2008,1.5 1.5,6.2008 1.5,11.9997c0,0 0,0 0,0"
    
    12
    +        android:strokeWidth="1.49999"
    
    13
    +        android:fillColor="@color/mozac_ui_icons_fill"/>
    
    14
    +</vector>