Commit b3248ec7 authored by Simon Chae's avatar Simon Chae Committed by Arturo Mejia
Browse files

For #6123: Expose WebExtensions in private browsing control

parent cc67de29
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ class InstalledAddonDetailsFragment : Fragment() {
        bindSettings(view)
        bindDetails(view)
        bindPermissions(view)
        bindAllowInPrivateBrowsingSwitch(view)
        bindRemoveButton(view)
    }

@@ -211,6 +212,32 @@ class InstalledAddonDetailsFragment : Fragment() {
        }
    }

    private fun bindAllowInPrivateBrowsingSwitch(view: View) {
        val switch = view.allow_in_private_browsing_switch
        switch.isChecked = addon.isAllowedInPrivateBrowsing()
        switch.setOnCheckedChangeListener { v, isChecked ->
            val addonManager = v.context.components.addonManager
            switch.isClickable = false
            view.remove_add_on.isEnabled = false
            addonManager.setAddonAllowedInPrivateBrowsing(
                addon,
                isChecked,
                onSuccess = {
                    runIfFragmentIsAttached {
                        this.addon = it
                        switch.isClickable = true
                        view.remove_add_on.isEnabled = true
                    }
                },
                onError = {
                    runIfFragmentIsAttached {
                        switch.isClickable = true
                        view.remove_add_on.isEnabled = true
                    }
                }
            )
        }
    }
    private fun bindRemoveButton(view: View) {
        view.remove_add_on.setOnClickListener {
            setAllInteractiveViewsClickable(view, false)
+20 −2
Original line number Diff line number Diff line
@@ -32,11 +32,29 @@
                android:textColor="?primaryText"
                android:textSize="16sp" />

            <Switch
                android:id="@+id/allow_in_private_browsing_switch"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical|end"
                android:layout_below="@+id/enable_switch"
                android:background="?android:attr/selectableItemBackground"
                android:checked="false"
                android:clickable="true"
                android:focusable="true"
                android:text="@string/mozac_feature_addons_settings_run_in_private_browsing"
                android:padding="16dp"
                android:textSize="16sp"
                android:textColor="?primaryText"
                android:drawablePadding="32dp"
                android:drawableStart="@drawable/ic_private_browsing"
                app:drawableTint="?primaryText" />

            <TextView
                android:id="@+id/settings"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/enable_switch"
                android:layout_below="@+id/allow_in_private_browsing_switch"
                android:background="?android:attr/selectableItemBackground"
                android:drawablePadding="32dp"
                android:padding="16dp"
@@ -76,8 +94,8 @@
            <Button
                android:id="@+id/remove_add_on"
                style="@style/DestructiveButton"
                android:layout_below="@+id/permissions"
                android:layout_marginHorizontal="16dp"
                android:layout_below="@+id/permissions"
                android:text="@string/mozac_feature_addons_remove" />
        </RelativeLayout>
    </ScrollView>