Commit fdb34d60 authored by ValentinTimisica's avatar ValentinTimisica
Browse files

For #6804: Adds private browsing label to add-on

parent 7d5b3a98
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ import android.widget.ImageView
import android.widget.RatingBar
import android.widget.TextView
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.annotation.VisibleForTesting
import androidx.cardview.widget.CardView
@@ -117,6 +118,7 @@ class AddonsManagerAdapter(
        val ratingAccessibleView = view.findViewById<TextView>(R.id.rating_accessibility)
        val userCountView = view.findViewById<TextView>(R.id.users_count)
        val addButton = view.findViewById<ImageView>(R.id.add_button)
        val allowedInPrivateBrowsingLabel = view.findViewById<ImageView>(R.id.allowed_in_private_browsing_label)
        return AddonViewHolder(
            view,
            iconContainer,
@@ -126,7 +128,8 @@ class AddonsManagerAdapter(
            ratingView,
            ratingAccessibleView,
            userCountView,
            addButton
            addButton,
            allowedInPrivateBrowsingLabel
        )
    }

@@ -224,6 +227,9 @@ class AddonsManagerAdapter(
            }
        }

        holder.allowedInPrivateBrowsingLabel.isVisible = addon.isAllowedInPrivateBrowsing()
        style?.maybeSetPrivateBrowsingLabelDrawale(holder.allowedInPrivateBrowsingLabel)

        style?.addonBackgroundIconColor?.let {
            val backgroundColor = ContextCompat.getColor(holder.iconContainer.context, it)
            holder.iconContainer.setCardBackgroundColor(backgroundColor)
@@ -327,7 +333,9 @@ class AddonsManagerAdapter(
        val addonSummaryTextColor: Int? = null,
        val sectionsTypeFace: Typeface? = null,
        @ColorRes
        val addonBackgroundIconColor: Int? = null
        val addonBackgroundIconColor: Int? = null,
        @DrawableRes
        val addonAllowPrivateBrowsingLabelDrawableRes: Int? = null
    ) {
        internal fun maybeSetSectionsTextColor(textView: TextView) {
            sectionsTextColor?.let {
@@ -355,6 +363,12 @@ class AddonsManagerAdapter(
                textView.setTextColor(color)
            }
        }

        internal fun maybeSetPrivateBrowsingLabelDrawale(imageView: ImageView) {
            addonAllowPrivateBrowsingLabelDrawableRes?.let {
                imageView.setImageDrawable(ContextCompat.getDrawable(imageView.context, it))
            }
        }
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ sealed class CustomViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val ratingView: RatingBar,
        val ratingAccessibleView: TextView,
        val userCountView: TextView,
        val addButton: ImageView
        val addButton: ImageView,
        val allowedInPrivateBrowsingLabel: ImageView
    ) : CustomViewHolder(view)
}
+27 −7
Original line number Diff line number Diff line
@@ -49,16 +49,36 @@
        android:paddingEnd="4dp"
        android:paddingBottom="8dp">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/add_on_name_container_margin_bottom"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/add_on_name"
            android:layout_width="wrap_content"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
            android:layout_marginBottom="2dp"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:ellipsize="end"
                android:maxLines="1"
                android:textSize="16sp"
                tools:text="uBlock Origin" />

            <androidx.appcompat.widget.AppCompatImageView
                android:id="@+id/allowed_in_private_browsing_label"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginStart="@dimen/allowed_in_private_browsing_label_margins"
                android:layout_marginEnd="@dimen/allowed_in_private_browsing_label_margins"
                android:layout_weight="0"
                android:background="?attr/selectableItemBackgroundBorderless"
                android:visibility="gone" />

        </LinearLayout>

        <TextView
            android:id="@+id/add_on_description"
            android:layout_width="match_parent"
+9 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<resources>
    <dimen name="allowed_in_private_browsing_label_margins">8dp</dimen>
    <dimen name="add_on_name_container_margin_bottom">2dp</dimen>
</resources>
+6 −3
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Config.kt)

* **feature-addons**
  * Added optional `addonAllowPrivateBrowsingLabelDrawableRes` DrawableRes parameter to `AddonPermissionsAdapter.Style` constructor to allow the clients to add their own drawable. This is used to clearly label the WebExtensions that run in private browsing.

# 40.0.0

* [Commits](https://github.com/mozilla-mobile/android-components/compare/v39.0.0...v40.0.0)