Bug 1799230 - Use Non-Transitive R Classes
According to Android documentation: "This leads to faster builds and the corresponding benefits of compilation avoidance."
This commit is contained in:
committed by
mergify[bot]
parent
a7ed62a604
commit
bcc43f0530
@@ -9,6 +9,7 @@ import android.content.Context
|
|||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import mozilla.components.support.ktx.android.content.appName
|
import mozilla.components.support.ktx.android.content.appName
|
||||||
import mozilla.components.support.ktx.kotlin.urlEncode
|
import mozilla.components.support.ktx.kotlin.urlEncode
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
object ErrorPages {
|
object ErrorPages {
|
||||||
|
|
||||||
@@ -111,113 +112,113 @@ enum class ErrorType(
|
|||||||
ERROR_SECURITY_SSL(
|
ERROR_SECURITY_SSL(
|
||||||
R.string.mozac_browser_errorpages_security_ssl_title,
|
R.string.mozac_browser_errorpages_security_ssl_title,
|
||||||
R.string.mozac_browser_errorpages_security_ssl_message,
|
R.string.mozac_browser_errorpages_security_ssl_message,
|
||||||
imageNameRes = R.string.mozac_error_lock,
|
imageNameRes = iconsR.string.mozac_error_lock,
|
||||||
),
|
),
|
||||||
ERROR_SECURITY_BAD_CERT(
|
ERROR_SECURITY_BAD_CERT(
|
||||||
R.string.mozac_browser_errorpages_security_bad_cert_title,
|
R.string.mozac_browser_errorpages_security_bad_cert_title,
|
||||||
R.string.mozac_browser_errorpages_security_bad_cert_message,
|
R.string.mozac_browser_errorpages_security_bad_cert_message,
|
||||||
imageNameRes = R.string.mozac_error_lock,
|
imageNameRes = iconsR.string.mozac_error_lock,
|
||||||
),
|
),
|
||||||
ERROR_NET_INTERRUPT(
|
ERROR_NET_INTERRUPT(
|
||||||
R.string.mozac_browser_errorpages_net_interrupt_title,
|
R.string.mozac_browser_errorpages_net_interrupt_title,
|
||||||
R.string.mozac_browser_errorpages_net_interrupt_message,
|
R.string.mozac_browser_errorpages_net_interrupt_message,
|
||||||
imageNameRes = R.string.mozac_error_eye_roll,
|
imageNameRes = iconsR.string.mozac_error_eye_roll,
|
||||||
),
|
),
|
||||||
ERROR_NET_TIMEOUT(
|
ERROR_NET_TIMEOUT(
|
||||||
R.string.mozac_browser_errorpages_net_timeout_title,
|
R.string.mozac_browser_errorpages_net_timeout_title,
|
||||||
R.string.mozac_browser_errorpages_net_timeout_message,
|
R.string.mozac_browser_errorpages_net_timeout_message,
|
||||||
imageNameRes = R.string.mozac_error_asleep,
|
imageNameRes = iconsR.string.mozac_error_asleep,
|
||||||
),
|
),
|
||||||
ERROR_CONNECTION_REFUSED(
|
ERROR_CONNECTION_REFUSED(
|
||||||
R.string.mozac_browser_errorpages_connection_failure_title,
|
R.string.mozac_browser_errorpages_connection_failure_title,
|
||||||
R.string.mozac_browser_errorpages_connection_failure_message,
|
R.string.mozac_browser_errorpages_connection_failure_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_UNKNOWN_SOCKET_TYPE(
|
ERROR_UNKNOWN_SOCKET_TYPE(
|
||||||
R.string.mozac_browser_errorpages_unknown_socket_type_title,
|
R.string.mozac_browser_errorpages_unknown_socket_type_title,
|
||||||
R.string.mozac_browser_errorpages_unknown_socket_type_message,
|
R.string.mozac_browser_errorpages_unknown_socket_type_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_REDIRECT_LOOP(
|
ERROR_REDIRECT_LOOP(
|
||||||
R.string.mozac_browser_errorpages_redirect_loop_title,
|
R.string.mozac_browser_errorpages_redirect_loop_title,
|
||||||
R.string.mozac_browser_errorpages_redirect_loop_message,
|
R.string.mozac_browser_errorpages_redirect_loop_message,
|
||||||
imageNameRes = R.string.mozac_error_surprised,
|
imageNameRes = iconsR.string.mozac_error_surprised,
|
||||||
),
|
),
|
||||||
ERROR_OFFLINE(
|
ERROR_OFFLINE(
|
||||||
R.string.mozac_browser_errorpages_offline_title,
|
R.string.mozac_browser_errorpages_offline_title,
|
||||||
R.string.mozac_browser_errorpages_offline_message,
|
R.string.mozac_browser_errorpages_offline_message,
|
||||||
imageNameRes = R.string.mozac_error_no_internet,
|
imageNameRes = iconsR.string.mozac_error_no_internet,
|
||||||
),
|
),
|
||||||
ERROR_PORT_BLOCKED(
|
ERROR_PORT_BLOCKED(
|
||||||
R.string.mozac_browser_errorpages_port_blocked_title,
|
R.string.mozac_browser_errorpages_port_blocked_title,
|
||||||
R.string.mozac_browser_errorpages_port_blocked_message,
|
R.string.mozac_browser_errorpages_port_blocked_message,
|
||||||
imageNameRes = R.string.mozac_error_lock,
|
imageNameRes = iconsR.string.mozac_error_lock,
|
||||||
),
|
),
|
||||||
ERROR_NET_RESET(
|
ERROR_NET_RESET(
|
||||||
R.string.mozac_browser_errorpages_net_reset_title,
|
R.string.mozac_browser_errorpages_net_reset_title,
|
||||||
R.string.mozac_browser_errorpages_net_reset_message,
|
R.string.mozac_browser_errorpages_net_reset_message,
|
||||||
imageNameRes = R.string.mozac_error_unplugged,
|
imageNameRes = iconsR.string.mozac_error_unplugged,
|
||||||
),
|
),
|
||||||
ERROR_UNSAFE_CONTENT_TYPE(
|
ERROR_UNSAFE_CONTENT_TYPE(
|
||||||
R.string.mozac_browser_errorpages_unsafe_content_type_title,
|
R.string.mozac_browser_errorpages_unsafe_content_type_title,
|
||||||
R.string.mozac_browser_errorpages_unsafe_content_type_message,
|
R.string.mozac_browser_errorpages_unsafe_content_type_message,
|
||||||
imageNameRes = R.string.mozac_error_inspect,
|
imageNameRes = iconsR.string.mozac_error_inspect,
|
||||||
),
|
),
|
||||||
ERROR_CORRUPTED_CONTENT(
|
ERROR_CORRUPTED_CONTENT(
|
||||||
R.string.mozac_browser_errorpages_corrupted_content_title,
|
R.string.mozac_browser_errorpages_corrupted_content_title,
|
||||||
R.string.mozac_browser_errorpages_corrupted_content_message,
|
R.string.mozac_browser_errorpages_corrupted_content_message,
|
||||||
imageNameRes = R.string.mozac_error_shred_file,
|
imageNameRes = iconsR.string.mozac_error_shred_file,
|
||||||
),
|
),
|
||||||
ERROR_CONTENT_CRASHED(
|
ERROR_CONTENT_CRASHED(
|
||||||
R.string.mozac_browser_errorpages_content_crashed_title,
|
R.string.mozac_browser_errorpages_content_crashed_title,
|
||||||
R.string.mozac_browser_errorpages_content_crashed_message,
|
R.string.mozac_browser_errorpages_content_crashed_message,
|
||||||
imageNameRes = R.string.mozac_error_surprised,
|
imageNameRes = iconsR.string.mozac_error_surprised,
|
||||||
),
|
),
|
||||||
ERROR_INVALID_CONTENT_ENCODING(
|
ERROR_INVALID_CONTENT_ENCODING(
|
||||||
R.string.mozac_browser_errorpages_invalid_content_encoding_title,
|
R.string.mozac_browser_errorpages_invalid_content_encoding_title,
|
||||||
R.string.mozac_browser_errorpages_invalid_content_encoding_message,
|
R.string.mozac_browser_errorpages_invalid_content_encoding_message,
|
||||||
imageNameRes = R.string.mozac_error_surprised,
|
imageNameRes = iconsR.string.mozac_error_surprised,
|
||||||
),
|
),
|
||||||
ERROR_UNKNOWN_HOST(
|
ERROR_UNKNOWN_HOST(
|
||||||
R.string.mozac_browser_errorpages_unknown_host_title,
|
R.string.mozac_browser_errorpages_unknown_host_title,
|
||||||
R.string.mozac_browser_errorpages_unknown_host_message,
|
R.string.mozac_browser_errorpages_unknown_host_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_NO_INTERNET(
|
ERROR_NO_INTERNET(
|
||||||
R.string.mozac_browser_errorpages_no_internet_title,
|
R.string.mozac_browser_errorpages_no_internet_title,
|
||||||
R.string.mozac_browser_errorpages_no_internet_message,
|
R.string.mozac_browser_errorpages_no_internet_message,
|
||||||
R.string.mozac_browser_errorpages_no_internet_refresh_button,
|
R.string.mozac_browser_errorpages_no_internet_refresh_button,
|
||||||
imageNameRes = R.string.mozac_error_no_internet,
|
imageNameRes = iconsR.string.mozac_error_no_internet,
|
||||||
),
|
),
|
||||||
ERROR_MALFORMED_URI(
|
ERROR_MALFORMED_URI(
|
||||||
R.string.mozac_browser_errorpages_malformed_uri_title,
|
R.string.mozac_browser_errorpages_malformed_uri_title,
|
||||||
R.string.mozac_browser_errorpages_malformed_uri_message,
|
R.string.mozac_browser_errorpages_malformed_uri_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_UNKNOWN_PROTOCOL(
|
ERROR_UNKNOWN_PROTOCOL(
|
||||||
R.string.mozac_browser_errorpages_unknown_protocol_title,
|
R.string.mozac_browser_errorpages_unknown_protocol_title,
|
||||||
R.string.mozac_browser_errorpages_unknown_protocol_message,
|
R.string.mozac_browser_errorpages_unknown_protocol_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_FILE_NOT_FOUND(
|
ERROR_FILE_NOT_FOUND(
|
||||||
R.string.mozac_browser_errorpages_file_not_found_title,
|
R.string.mozac_browser_errorpages_file_not_found_title,
|
||||||
R.string.mozac_browser_errorpages_file_not_found_message,
|
R.string.mozac_browser_errorpages_file_not_found_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_FILE_ACCESS_DENIED(
|
ERROR_FILE_ACCESS_DENIED(
|
||||||
R.string.mozac_browser_errorpages_file_access_denied_title,
|
R.string.mozac_browser_errorpages_file_access_denied_title,
|
||||||
R.string.mozac_browser_errorpages_file_access_denied_message,
|
R.string.mozac_browser_errorpages_file_access_denied_message,
|
||||||
imageNameRes = R.string.mozac_error_question_file,
|
imageNameRes = iconsR.string.mozac_error_question_file,
|
||||||
),
|
),
|
||||||
ERROR_PROXY_CONNECTION_REFUSED(
|
ERROR_PROXY_CONNECTION_REFUSED(
|
||||||
R.string.mozac_browser_errorpages_proxy_connection_refused_title,
|
R.string.mozac_browser_errorpages_proxy_connection_refused_title,
|
||||||
R.string.mozac_browser_errorpages_proxy_connection_refused_message,
|
R.string.mozac_browser_errorpages_proxy_connection_refused_message,
|
||||||
imageNameRes = R.string.mozac_error_confused,
|
imageNameRes = iconsR.string.mozac_error_confused,
|
||||||
),
|
),
|
||||||
ERROR_UNKNOWN_PROXY_HOST(
|
ERROR_UNKNOWN_PROXY_HOST(
|
||||||
R.string.mozac_browser_errorpages_unknown_proxy_host_title,
|
R.string.mozac_browser_errorpages_unknown_proxy_host_title,
|
||||||
R.string.mozac_browser_errorpages_unknown_proxy_host_message,
|
R.string.mozac_browser_errorpages_unknown_proxy_host_message,
|
||||||
imageNameRes = R.string.mozac_error_unplugged,
|
imageNameRes = iconsR.string.mozac_error_unplugged,
|
||||||
),
|
),
|
||||||
ERROR_SAFEBROWSING_MALWARE_URI(
|
ERROR_SAFEBROWSING_MALWARE_URI(
|
||||||
R.string.mozac_browser_errorpages_safe_browsing_malware_uri_title,
|
R.string.mozac_browser_errorpages_safe_browsing_malware_uri_title,
|
||||||
@@ -238,11 +239,11 @@ enum class ErrorType(
|
|||||||
ERROR_HTTPS_ONLY(
|
ERROR_HTTPS_ONLY(
|
||||||
R.string.mozac_browser_errorpages_httpsonly_title,
|
R.string.mozac_browser_errorpages_httpsonly_title,
|
||||||
R.string.mozac_browser_errorpages_httpsonly_message,
|
R.string.mozac_browser_errorpages_httpsonly_message,
|
||||||
imageNameRes = R.string.mozac_error_lock,
|
imageNameRes = iconsR.string.mozac_error_lock,
|
||||||
),
|
),
|
||||||
ERROR_BAD_HSTS_CERT(
|
ERROR_BAD_HSTS_CERT(
|
||||||
R.string.mozac_browser_errorpages_security_bad_hsts_cert_title,
|
R.string.mozac_browser_errorpages_security_bad_hsts_cert_title,
|
||||||
R.string.mozac_browser_errorpages_security_bad_hsts_cert_message,
|
R.string.mozac_browser_errorpages_security_bad_hsts_cert_message,
|
||||||
imageNameRes = R.string.mozac_error_lock,
|
imageNameRes = iconsR.string.mozac_error_lock,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import mozilla.components.browser.menu.item.WebExtensionBrowserMenuItem
|
|||||||
import mozilla.components.browser.menu.item.WebExtensionPlaceholderMenuItem
|
import mozilla.components.browser.menu.item.WebExtensionPlaceholderMenuItem
|
||||||
import mozilla.components.browser.state.selector.selectedTab
|
import mozilla.components.browser.state.selector.selectedTab
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browser menu builder with web extension support. It allows [WebExtensionBrowserMenu] to add
|
* Browser menu builder with web extension support. It allows [WebExtensionBrowserMenu] to add
|
||||||
@@ -158,8 +159,8 @@ class WebExtensionBrowserMenuBuilder(
|
|||||||
@ColorRes
|
@ColorRes
|
||||||
val webExtIconTintColorResource: Int = NO_ID,
|
val webExtIconTintColorResource: Int = NO_ID,
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
val backPressMenuItemDrawableRes: Int = R.drawable.mozac_ic_back,
|
val backPressMenuItemDrawableRes: Int = iconsR.drawable.mozac_ic_back,
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
val addonsManagerMenuItemDrawableRes: Int = R.drawable.mozac_ic_extensions,
|
val addonsManagerMenuItemDrawableRes: Int = iconsR.drawable.mozac_ic_extensions,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
|||||||
import mozilla.components.concept.menu.candidate.TextMenuIcon
|
import mozilla.components.concept.menu.candidate.TextMenuIcon
|
||||||
import mozilla.components.concept.menu.candidate.TextStyle
|
import mozilla.components.concept.menu.candidate.TextStyle
|
||||||
import mozilla.components.support.base.log.Log
|
import mozilla.components.support.base.log.Log
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A browser menu item displaying a web extension action.
|
* A browser menu item displaying a web extension action.
|
||||||
@@ -129,7 +130,7 @@ class WebExtensionBrowserMenuItem(
|
|||||||
"Failed to load browser action icon, falling back to default.",
|
"Failed to load browser action icon, falling back to default.",
|
||||||
)
|
)
|
||||||
|
|
||||||
getDrawable(context, R.drawable.mozac_ic_web_extension_default_icon)
|
getDrawable(context, iconsR.drawable.mozac_ic_web_extension_default_icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import mozilla.components.support.test.robolectric.testContext
|
|||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import mozilla.components.ui.colors.R as colorsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class BrowserMenuHighlightTest {
|
class BrowserMenuHighlightTest {
|
||||||
@@ -36,12 +37,13 @@ class BrowserMenuHighlightTest {
|
|||||||
@Suppress("Deprecation")
|
@Suppress("Deprecation")
|
||||||
@Test
|
@Test
|
||||||
fun `classic highlight effect converts background tint`() {
|
fun `classic highlight effect converts background tint`() {
|
||||||
|
val colorId = colorsR.color.photonRed50
|
||||||
val highlight = BrowserMenuHighlight.ClassicHighlight(
|
val highlight = BrowserMenuHighlight.ClassicHighlight(
|
||||||
startImageResource = 0,
|
startImageResource = 0,
|
||||||
endImageResource = 0,
|
endImageResource = 0,
|
||||||
backgroundResource = 0,
|
backgroundResource = 0,
|
||||||
colorResource = R.color.photonRed50,
|
colorResource = colorId,
|
||||||
)
|
)
|
||||||
assertEquals(HighPriorityHighlightEffect(testContext.getColor(R.color.photonRed50)), highlight.asEffect(testContext))
|
assertEquals(HighPriorityHighlightEffect(testContext.getColor(colorId)), highlight.asEffect(testContext))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import org.junit.Assert.assertNotNull
|
|||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class WebExtensionBrowserMenuBuilderTest {
|
class WebExtensionBrowserMenuBuilderTest {
|
||||||
@@ -70,8 +72,8 @@ class WebExtensionBrowserMenuBuilderTest {
|
|||||||
|
|
||||||
val store = BrowserStore(BrowserState(extensions = extensions))
|
val store = BrowserStore(BrowserState(extensions = extensions))
|
||||||
val style = WebExtensionBrowserMenuBuilder.Style(
|
val style = WebExtensionBrowserMenuBuilder.Style(
|
||||||
addonsManagerMenuItemDrawableRes = R.drawable.mozac_ic_extensions,
|
addonsManagerMenuItemDrawableRes = iconsR.drawable.mozac_ic_extensions,
|
||||||
backPressMenuItemDrawableRes = R.drawable.mozac_ic_back,
|
backPressMenuItemDrawableRes = iconsR.drawable.mozac_ic_back,
|
||||||
)
|
)
|
||||||
val builder = WebExtensionBrowserMenuBuilder(
|
val builder = WebExtensionBrowserMenuBuilder(
|
||||||
listOf(mockMenuItem()),
|
listOf(mockMenuItem()),
|
||||||
@@ -251,7 +253,7 @@ class WebExtensionBrowserMenuBuilderTest {
|
|||||||
fun `web extension is moved to main menu when extension id equals WebExtensionPlaceholderMenuItem id`() {
|
fun `web extension is moved to main menu when extension id equals WebExtensionPlaceholderMenuItem id`() {
|
||||||
val promotableWebExtensionId = "promotable extension id"
|
val promotableWebExtensionId = "promotable extension id"
|
||||||
val promotableWebExtensionTitle = "promotable extension action title"
|
val promotableWebExtensionTitle = "promotable extension action title"
|
||||||
val testIconTintColorResource = R.color.accent_material_dark
|
val testIconTintColorResource = appcompatR.color.accent_material_dark
|
||||||
|
|
||||||
val pageAction = WebExtensionBrowserAction("page_action", true, mock(), "", 0, 0) {}
|
val pageAction = WebExtensionBrowserAction("page_action", true, mock(), "", 0, 0) {}
|
||||||
val pageActionPromotableWebExtension = WebExtensionBrowserAction(promotableWebExtensionTitle, true, mock(), "", 0, 0) {}
|
val pageActionPromotableWebExtension = WebExtensionBrowserAction(promotableWebExtensionTitle, true, mock(), "", 0, 0) {}
|
||||||
|
|||||||
@@ -34,10 +34,13 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
import org.robolectric.Shadows
|
import org.robolectric.Shadows
|
||||||
|
import mozilla.components.ui.colors.R as colorsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class BrowserMenuHighlightableItemTest {
|
class BrowserMenuHighlightableItemTest {
|
||||||
|
|
||||||
|
private val colorId = colorsR.color.photonRed50
|
||||||
|
|
||||||
@Suppress("Deprecation")
|
@Suppress("Deprecation")
|
||||||
@Test
|
@Test
|
||||||
fun `browser menu highlightable item should be inflated`() {
|
fun `browser menu highlightable item should be inflated`() {
|
||||||
@@ -49,8 +52,8 @@ class BrowserMenuHighlightableItemTest {
|
|||||||
textColorResource = android.R.color.black,
|
textColorResource = android.R.color.black,
|
||||||
highlight = BrowserMenuHighlightableItem.Highlight(
|
highlight = BrowserMenuHighlightableItem.Highlight(
|
||||||
endImageResource = android.R.drawable.ic_menu_report_image,
|
endImageResource = android.R.drawable.ic_menu_report_image,
|
||||||
backgroundResource = R.color.photonRed50,
|
backgroundResource = colorId,
|
||||||
colorResource = R.color.photonRed50,
|
colorResource = colorId,
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
onClickWasPress = true
|
onClickWasPress = true
|
||||||
@@ -74,8 +77,8 @@ class BrowserMenuHighlightableItemTest {
|
|||||||
highlight = BrowserMenuHighlightableItem.Highlight(
|
highlight = BrowserMenuHighlightableItem.Highlight(
|
||||||
startImageResource = android.R.drawable.ic_menu_camera,
|
startImageResource = android.R.drawable.ic_menu_camera,
|
||||||
endImageResource = android.R.drawable.ic_menu_add,
|
endImageResource = android.R.drawable.ic_menu_add,
|
||||||
backgroundResource = R.color.photonRed50,
|
backgroundResource = colorId,
|
||||||
colorResource = R.color.photonRed50,
|
colorResource = colorId,
|
||||||
),
|
),
|
||||||
isHighlighted = { shouldHighlight },
|
isHighlighted = { shouldHighlight },
|
||||||
)
|
)
|
||||||
@@ -98,7 +101,7 @@ class BrowserMenuHighlightableItemTest {
|
|||||||
assertEquals(android.R.drawable.ic_menu_camera, Shadows.shadowOf(view.startImageView.drawable).createdFromResId)
|
assertEquals(android.R.drawable.ic_menu_camera, Shadows.shadowOf(view.startImageView.drawable).createdFromResId)
|
||||||
assertEquals(android.R.drawable.ic_menu_add, Shadows.shadowOf(view.endImageView.drawable).createdFromResId)
|
assertEquals(android.R.drawable.ic_menu_add, Shadows.shadowOf(view.endImageView.drawable).createdFromResId)
|
||||||
assertNotNull(view.endImageView.imageTintList)
|
assertNotNull(view.endImageView.imageTintList)
|
||||||
assertEquals(R.color.photonRed50, Shadows.shadowOf(view.background).createdFromResId)
|
assertEquals(colorId, Shadows.shadowOf(view.background).createdFromResId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
import org.robolectric.Shadows
|
import org.robolectric.Shadows
|
||||||
|
import mozilla.components.ui.colors.R as colorsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class BrowserMenuHighlightableSwitchTest {
|
class BrowserMenuHighlightableSwitchTest {
|
||||||
@@ -70,7 +71,7 @@ class BrowserMenuHighlightableSwitchTest {
|
|||||||
iconTintColorResource = android.R.color.black,
|
iconTintColorResource = android.R.color.black,
|
||||||
textColorResource = android.R.color.black,
|
textColorResource = android.R.color.black,
|
||||||
highlight = BrowserMenuHighlight.LowPriority(
|
highlight = BrowserMenuHighlight.LowPriority(
|
||||||
notificationTint = R.color.photonRed50,
|
notificationTint = colorsR.color.photonRed50,
|
||||||
label = "highlight",
|
label = "highlight",
|
||||||
),
|
),
|
||||||
isHighlighted = { shouldHighlight },
|
isHighlighted = { shouldHighlight },
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import android.view.LayoutInflater
|
|||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.R
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
import androidx.core.content.ContextCompat.getColor
|
import androidx.core.content.ContextCompat.getColor
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import mozilla.components.browser.menu.BrowserMenu
|
import mozilla.components.browser.menu.BrowserMenu
|
||||||
import mozilla.components.browser.menu.R
|
|
||||||
import mozilla.components.concept.menu.candidate.ContainerStyle
|
import mozilla.components.concept.menu.candidate.ContainerStyle
|
||||||
import mozilla.components.concept.menu.candidate.DrawableMenuIcon
|
import mozilla.components.concept.menu.candidate.DrawableMenuIcon
|
||||||
import mozilla.components.concept.menu.candidate.RowMenuCandidate
|
import mozilla.components.concept.menu.candidate.RowMenuCandidate
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.junit.Assert.assertNull
|
|||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class ParentBrowserMenuItemTest {
|
class ParentBrowserMenuItemTest {
|
||||||
@@ -77,7 +78,7 @@ class ParentBrowserMenuItemTest {
|
|||||||
fun `onBackPressed after sub menu is shown will dismiss the sub menu`() {
|
fun `onBackPressed after sub menu is shown will dismiss the sub menu`() {
|
||||||
val backPressMenuItem = BackPressMenuItem(
|
val backPressMenuItem = BackPressMenuItem(
|
||||||
label = "back",
|
label = "back",
|
||||||
imageResource = R.drawable.mozac_ic_back,
|
imageResource = iconsR.drawable.mozac_ic_back,
|
||||||
)
|
)
|
||||||
val backPressView = LayoutInflater.from(testContext).inflate(backPressMenuItem.getLayoutResource(), null)
|
val backPressView = LayoutInflater.from(testContext).inflate(backPressMenuItem.getLayoutResource(), null)
|
||||||
val subMenuItem = SimpleBrowserMenuItem("test")
|
val subMenuItem = SimpleBrowserMenuItem("test")
|
||||||
@@ -109,7 +110,7 @@ class ParentBrowserMenuItemTest {
|
|||||||
fun `menu item image text item can be converted to candidate`() {
|
fun `menu item image text item can be converted to candidate`() {
|
||||||
val backPressMenuItem = BackPressMenuItem(
|
val backPressMenuItem = BackPressMenuItem(
|
||||||
label = "back",
|
label = "back",
|
||||||
imageResource = R.drawable.mozac_ic_back,
|
imageResource = iconsR.drawable.mozac_ic_back,
|
||||||
)
|
)
|
||||||
val subMenuItem = SimpleBrowserMenuItem("test")
|
val subMenuItem = SimpleBrowserMenuItem("test")
|
||||||
val subMenuAdapter = BrowserMenuAdapter(testContext, listOf(backPressMenuItem, subMenuItem))
|
val subMenuAdapter = BrowserMenuAdapter(testContext, listOf(backPressMenuItem, subMenuItem))
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.junit.runner.RunWith
|
|||||||
import org.mockito.Mockito.notNull
|
import org.mockito.Mockito.notNull
|
||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@@ -288,7 +289,7 @@ class WebExtensionBrowserMenuItemTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `GIVEN setIcon was called, WHEN bind is called, icon setup uses the tint set`() = runTest {
|
fun `GIVEN setIcon was called, WHEN bind is called, icon setup uses the tint set`() = runTest {
|
||||||
val webExtMenuItem = spy(WebExtensionBrowserMenuItem(mock(), mock()))
|
val webExtMenuItem = spy(WebExtensionBrowserMenuItem(mock(), mock()))
|
||||||
val testIconTintColorResource = R.color.accent_material_dark
|
val testIconTintColorResource = appcompatR.color.accent_material_dark
|
||||||
val menu: WebExtensionBrowserMenu = mock()
|
val menu: WebExtensionBrowserMenu = mock()
|
||||||
val imageView: ImageView = mock()
|
val imageView: ImageView = mock()
|
||||||
val badgeView: TextView = mock()
|
val badgeView: TextView = mock()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import mozilla.components.browser.toolbar.internal.ActionContainer
|
|||||||
import mozilla.components.concept.menu.MenuController
|
import mozilla.components.concept.menu.MenuController
|
||||||
import mozilla.components.concept.toolbar.Toolbar
|
import mozilla.components.concept.toolbar.Toolbar
|
||||||
import mozilla.components.support.ktx.android.content.isScreenReaderEnabled
|
import mozilla.components.support.ktx.android.content.isScreenReaderEnabled
|
||||||
|
import mozilla.components.ui.colors.R.color as photonColors
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub-component of the browser toolbar responsible for displaying the URL and related controls ("display mode").
|
* Sub-component of the browser toolbar responsible for displaying the URL and related controls ("display mode").
|
||||||
@@ -164,15 +165,15 @@ class DisplayToolbar internal constructor(
|
|||||||
* Customizable colors in "display mode".
|
* Customizable colors in "display mode".
|
||||||
*/
|
*/
|
||||||
var colors: Colors = Colors(
|
var colors: Colors = Colors(
|
||||||
securityIconSecure = ContextCompat.getColor(context, R.color.photonWhite),
|
securityIconSecure = ContextCompat.getColor(context, photonColors.photonWhite),
|
||||||
securityIconInsecure = ContextCompat.getColor(context, R.color.photonWhite),
|
securityIconInsecure = ContextCompat.getColor(context, photonColors.photonWhite),
|
||||||
emptyIcon = ContextCompat.getColor(context, R.color.photonWhite),
|
emptyIcon = ContextCompat.getColor(context, photonColors.photonWhite),
|
||||||
menu = ContextCompat.getColor(context, R.color.photonWhite),
|
menu = ContextCompat.getColor(context, photonColors.photonWhite),
|
||||||
hint = views.origin.hintColor,
|
hint = views.origin.hintColor,
|
||||||
title = views.origin.titleColor,
|
title = views.origin.titleColor,
|
||||||
text = views.origin.textColor,
|
text = views.origin.textColor,
|
||||||
trackingProtection = null,
|
trackingProtection = null,
|
||||||
separator = ContextCompat.getColor(context, R.color.photonGrey80),
|
separator = ContextCompat.getColor(context, photonColors.photonGrey80),
|
||||||
highlight = null,
|
highlight = null,
|
||||||
)
|
)
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import mozilla.components.support.base.utils.NamedThreadFactory
|
|||||||
import mozilla.components.support.ktx.android.view.showKeyboard
|
import mozilla.components.support.ktx.android.view.showKeyboard
|
||||||
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText
|
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
import mozilla.components.ui.colors.R as colorsR
|
||||||
|
|
||||||
private const val AUTOCOMPLETE_QUERY_THREADS = 3
|
private const val AUTOCOMPLETE_QUERY_THREADS = 3
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ class EditToolbar internal constructor(
|
|||||||
* Customizable colors in "edit mode".
|
* Customizable colors in "edit mode".
|
||||||
*/
|
*/
|
||||||
var colors: Colors = Colors(
|
var colors: Colors = Colors(
|
||||||
clear = ContextCompat.getColor(context, R.color.photonWhite),
|
clear = ContextCompat.getColor(context, colorsR.color.photonWhite),
|
||||||
icon = null,
|
icon = null,
|
||||||
hint = views.url.currentHintTextColor,
|
hint = views.url.currentHintTextColor,
|
||||||
text = views.url.currentTextColor,
|
text = views.url.currentTextColor,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import org.mockito.Mockito.reset
|
|||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.robolectric.util.ReflectionHelpers
|
import org.robolectric.util.ReflectionHelpers
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class DisplayToolbarTest {
|
class DisplayToolbarTest {
|
||||||
@@ -553,7 +554,10 @@ class DisplayToolbarTest {
|
|||||||
assertNull(displayToolbar.views.background.drawable)
|
assertNull(displayToolbar.views.background.drawable)
|
||||||
|
|
||||||
displayToolbar.setUrlBackground(
|
displayToolbar.setUrlBackground(
|
||||||
ContextCompat.getDrawable(testContext, R.drawable.mozac_ic_broken_lock),
|
ContextCompat.getDrawable(
|
||||||
|
testContext,
|
||||||
|
iconsR.drawable.mozac_ic_broken_lock,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assertNotNull(displayToolbar.views.background.drawable)
|
assertNotNull(displayToolbar.views.background.drawable)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import mozilla.components.compose.browser.awesomebar.AwesomeBarColors
|
|||||||
import mozilla.components.compose.browser.awesomebar.AwesomeBarOrientation
|
import mozilla.components.compose.browser.awesomebar.AwesomeBarOrientation
|
||||||
import mozilla.components.compose.browser.awesomebar.R
|
import mozilla.components.compose.browser.awesomebar.R
|
||||||
import mozilla.components.concept.awesomebar.AwesomeBar
|
import mozilla.components.concept.awesomebar.AwesomeBar
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
// We only show one row of text, covering at max screen width.
|
// We only show one row of text, covering at max screen width.
|
||||||
// Limit bigger texts that could cause slowdowns or even crashes.
|
// Limit bigger texts that could cause slowdowns or even crashes.
|
||||||
@@ -165,7 +166,7 @@ private fun AutocompleteButton(
|
|||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painterResource(R.drawable.mozac_ic_edit_suggestion),
|
painterResource(iconsR.drawable.mozac_ic_edit_suggestion),
|
||||||
colorFilter = ColorFilter.tint(colors.autocompleteIcon),
|
colorFilter = ColorFilter.tint(colors.autocompleteIcon),
|
||||||
contentDescription = stringResource(R.string.mozac_browser_awesomebar_edit_suggestion),
|
contentDescription = stringResource(R.string.mozac_browser_awesomebar_edit_suggestion),
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ dependencies {
|
|||||||
implementation project(":concept-engine")
|
implementation project(":concept-engine")
|
||||||
implementation project(":browser-state")
|
implementation project(":browser-state")
|
||||||
implementation project(":feature-session")
|
implementation project(":feature-session")
|
||||||
|
implementation project(":ui-icons")
|
||||||
implementation Dependencies.androidx_compose_ui
|
implementation Dependencies.androidx_compose_ui
|
||||||
implementation Dependencies.androidx_compose_ui_tooling
|
implementation Dependencies.androidx_compose_ui_tooling
|
||||||
implementation Dependencies.androidx_compose_foundation
|
implementation Dependencies.androidx_compose_foundation
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.compose.ui.res.stringResource
|
|||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub-component of the [BrowserToolbar] responsible for allowing the user to edit the current
|
* Sub-component of the [BrowserToolbar] responsible for allowing the user to edit the current
|
||||||
@@ -84,7 +85,7 @@ fun ClearButton(onButtonClicked: () -> Unit = {}) {
|
|||||||
onClick = { onButtonClicked() },
|
onClick = { onButtonClicked() },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(R.drawable.mozac_ic_clear),
|
painter = painterResource(iconsR.drawable.mozac_ic_clear),
|
||||||
contentDescription = stringResource(R.string.mozac_clear_button_description),
|
contentDescription = stringResource(R.string.mozac_clear_button_description),
|
||||||
tint = Color.Black,
|
tint = Color.Black,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import androidx.compose.ui.unit.Dp
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import mozilla.components.compose.cfr.CFRPopup.IndicatorDirection.DOWN
|
import mozilla.components.compose.cfr.CFRPopup.IndicatorDirection.DOWN
|
||||||
import mozilla.components.compose.cfr.CFRPopup.IndicatorDirection.UP
|
import mozilla.components.compose.cfr.CFRPopup.IndicatorDirection.UP
|
||||||
import mozilla.components.compose.cfr.R.drawable
|
import mozilla.components.ui.icons.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete content of the popup.
|
* Complete content of the popup.
|
||||||
@@ -122,7 +122,7 @@ fun CFRPopupContent(
|
|||||||
.size(48.dp),
|
.size(48.dp),
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(drawable.mozac_ic_close_20),
|
painter = painterResource(R.drawable.mozac_ic_close_20),
|
||||||
contentDescription = "Test",
|
contentDescription = "Test",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
// Following alignment and padding are intended to visually align the middle
|
// Following alignment and padding are intended to visually align the middle
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import mozilla.components.browser.state.state.TabSessionState
|
import mozilla.components.browser.state.state.TabSessionState
|
||||||
import mozilla.components.compose.browser.tabstray.R
|
import mozilla.components.ui.icons.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a single [TabSessionState] as a list item.
|
* Renders a single [TabSessionState] as a list item.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import mozilla.components.concept.menu.candidate.ContainerStyle
|
|||||||
import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
||||||
import mozilla.components.concept.menu.candidate.TextMenuIcon
|
import mozilla.components.concept.menu.candidate.TextMenuIcon
|
||||||
import mozilla.components.concept.menu.candidate.TextStyle
|
import mozilla.components.concept.menu.candidate.TextStyle
|
||||||
import mozilla.components.feature.addons.R
|
import mozilla.components.ui.icons.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a browser menu item for displaying a web extension action.
|
* Create a browser menu item for displaying a web extension action.
|
||||||
|
|||||||
@@ -17,16 +17,17 @@ import mozilla.components.concept.menu.candidate.MenuCandidate
|
|||||||
import mozilla.components.concept.menu.candidate.NestedMenuCandidate
|
import mozilla.components.concept.menu.candidate.NestedMenuCandidate
|
||||||
import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
||||||
import mozilla.components.feature.addons.R
|
import mozilla.components.feature.addons.R
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
private fun createBackMenuItem(
|
private fun createBackMenuItem(
|
||||||
context: Context,
|
context: Context,
|
||||||
@ColorInt webExtIconTintColor: Int?,
|
@ColorInt webExtIconTintColor: Int?,
|
||||||
) = NestedMenuCandidate(
|
) = NestedMenuCandidate(
|
||||||
id = R.drawable.mozac_ic_back,
|
id = iconsR.drawable.mozac_ic_back,
|
||||||
text = context.getString(R.string.mozac_feature_addons_addons),
|
text = context.getString(R.string.mozac_feature_addons_addons),
|
||||||
start = DrawableMenuIcon(
|
start = DrawableMenuIcon(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_back,
|
iconsR.drawable.mozac_ic_back,
|
||||||
tint = webExtIconTintColor,
|
tint = webExtIconTintColor,
|
||||||
),
|
),
|
||||||
subMenuItems = null,
|
subMenuItems = null,
|
||||||
@@ -40,7 +41,7 @@ private fun createAddonsManagerItem(
|
|||||||
text = context.getString(R.string.mozac_feature_addons_addons_manager),
|
text = context.getString(R.string.mozac_feature_addons_addons_manager),
|
||||||
start = DrawableMenuIcon(
|
start = DrawableMenuIcon(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_extensions,
|
iconsR.drawable.mozac_ic_extensions,
|
||||||
tint = webExtIconTintColor,
|
tint = webExtIconTintColor,
|
||||||
),
|
),
|
||||||
onClick = onAddonsManagerTapped,
|
onClick = onAddonsManagerTapped,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import mozilla.components.support.ktx.android.content.appName
|
|||||||
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
||||||
import mozilla.components.support.utils.ext.getParcelableCompat
|
import mozilla.components.support.utils.ext.getParcelableCompat
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@VisibleForTesting internal const val KEY_INSTALLED_ADDON = "KEY_ADDON"
|
@VisibleForTesting internal const val KEY_INSTALLED_ADDON = "KEY_ADDON"
|
||||||
private const val KEY_DIALOG_GRAVITY = "KEY_DIALOG_GRAVITY"
|
private const val KEY_DIALOG_GRAVITY = "KEY_DIALOG_GRAVITY"
|
||||||
@@ -226,7 +227,10 @@ class AddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
|
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
|
||||||
iconView.setColorFilter(ContextCompat.getColor(context, att))
|
iconView.setColorFilter(ContextCompat.getColor(context, att))
|
||||||
iconView.setImageDrawable(
|
iconView.setImageDrawable(
|
||||||
ContextCompat.getDrawable(context, R.drawable.mozac_ic_extensions),
|
ContextCompat.getDrawable(
|
||||||
|
context,
|
||||||
|
iconsR.drawable.mozac_ic_extensions,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
|
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import mozilla.components.feature.addons.ui.CustomViewHolder.UnsupportedSectionV
|
|||||||
import mozilla.components.support.base.log.logger.Logger
|
import mozilla.components.support.base.log.logger.Logger
|
||||||
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
private const val VIEW_HOLDER_TYPE_SECTION = 0
|
private const val VIEW_HOLDER_TYPE_SECTION = 0
|
||||||
private const val VIEW_HOLDER_TYPE_NOT_YET_SUPPORTED_SECTION = 1
|
private const val VIEW_HOLDER_TYPE_NOT_YET_SUPPORTED_SECTION = 1
|
||||||
@@ -273,7 +274,10 @@ class AddonsManagerAdapter(
|
|||||||
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
|
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
|
||||||
iconView.setColorFilter(ContextCompat.getColor(context, att))
|
iconView.setColorFilter(ContextCompat.getColor(context, att))
|
||||||
iconView.setImageDrawable(
|
iconView.setImageDrawable(
|
||||||
ContextCompat.getDrawable(context, R.drawable.mozac_ic_extensions),
|
ContextCompat.getDrawable(
|
||||||
|
context,
|
||||||
|
iconsR.drawable.mozac_ic_extensions,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
|
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import java.util.Date
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
import kotlin.coroutines.suspendCoroutine
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract to define the behavior for updating addons.
|
* Contract to define the behavior for updating addons.
|
||||||
@@ -281,7 +282,7 @@ class DefaultAddonUpdater(
|
|||||||
|
|
||||||
logger.info("Created update notification for add-on ${extension.id}")
|
logger.info("Created update notification for add-on ${extension.id}")
|
||||||
return NotificationCompat.Builder(applicationContext, channelId)
|
return NotificationCompat.Builder(applicationContext, channelId)
|
||||||
.setSmallIcon(mozilla.components.ui.icons.R.drawable.mozac_ic_extensions)
|
.setSmallIcon(iconsR.drawable.mozac_ic_extensions)
|
||||||
.setContentTitle(getNotificationTitle(extension))
|
.setContentTitle(getNotificationTitle(extension))
|
||||||
.setContentText(text)
|
.setContentText(text)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
@@ -358,7 +359,7 @@ class DefaultAddonUpdater(
|
|||||||
applicationContext.getString(R.string.mozac_feature_addons_updater_notification_allow_button)
|
applicationContext.getString(R.string.mozac_feature_addons_updater_notification_allow_button)
|
||||||
|
|
||||||
return NotificationCompat.Action.Builder(
|
return NotificationCompat.Action.Builder(
|
||||||
mozilla.components.ui.icons.R.drawable.mozac_ic_extensions,
|
iconsR.drawable.mozac_ic_extensions,
|
||||||
allowText,
|
allowText,
|
||||||
allowPendingIntent,
|
allowPendingIntent,
|
||||||
).build()
|
).build()
|
||||||
@@ -378,7 +379,7 @@ class DefaultAddonUpdater(
|
|||||||
applicationContext.getString(R.string.mozac_feature_addons_updater_notification_deny_button)
|
applicationContext.getString(R.string.mozac_feature_addons_updater_notification_deny_button)
|
||||||
|
|
||||||
return NotificationCompat.Action.Builder(
|
return NotificationCompat.Action.Builder(
|
||||||
mozilla.components.ui.icons.R.drawable.mozac_ic_extensions,
|
iconsR.drawable.mozac_ic_extensions,
|
||||||
denyText,
|
denyText,
|
||||||
denyPendingIntent,
|
denyPendingIntent,
|
||||||
).build()
|
).build()
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import android.widget.TextView
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import mozilla.components.feature.addons.R
|
|
||||||
import mozilla.components.feature.addons.ui.AddonPermissionsAdapter.PermissionViewHolder
|
import mozilla.components.feature.addons.ui.AddonPermissionsAdapter.PermissionViewHolder
|
||||||
import mozilla.components.feature.addons.ui.AddonPermissionsAdapter.Style
|
import mozilla.components.feature.addons.ui.AddonPermissionsAdapter.Style
|
||||||
import mozilla.components.support.test.mock
|
import mozilla.components.support.test.mock
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import mozilla.components.support.test.whenever
|
import mozilla.components.support.test.whenever
|
||||||
|
import mozilla.components.ui.colors.R
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ import org.mockito.Mockito.doNothing
|
|||||||
import org.mockito.Mockito.doReturn
|
import org.mockito.Mockito.doReturn
|
||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.robolectric.Shadows.shadowOf
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class SimpleRedirectDialogFragmentTest {
|
class SimpleRedirectDialogFragmentTest {
|
||||||
private val webUrl = "https://example.com"
|
private val webUrl = "https://example.com"
|
||||||
|
private val themeResId = appcompatR.style.Theme_AppCompat_Light
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Dialog confirmed callback is called correctly`() {
|
fun `Dialog confirmed callback is called correctly`() {
|
||||||
@@ -32,7 +34,7 @@ class SimpleRedirectDialogFragmentTest {
|
|||||||
val onConfirm = { onConfirmCalled = true }
|
val onConfirm = { onConfirmCalled = true }
|
||||||
val onCancel = { onCancelCalled = true }
|
val onCancel = { onCancelCalled = true }
|
||||||
|
|
||||||
val fragment = spy(SimpleRedirectDialogFragment.newInstance(themeResId = R.style.Theme_AppCompat_Light))
|
val fragment = spy(SimpleRedirectDialogFragment.newInstance(themeResId = themeResId))
|
||||||
doNothing().`when`(fragment).dismiss()
|
doNothing().`when`(fragment).dismiss()
|
||||||
|
|
||||||
doReturn(testContext).`when`(fragment).requireContext()
|
doReturn(testContext).`when`(fragment).requireContext()
|
||||||
@@ -62,7 +64,7 @@ class SimpleRedirectDialogFragmentTest {
|
|||||||
val onConfirm = { onConfirmCalled = true }
|
val onConfirm = { onConfirmCalled = true }
|
||||||
val onCancel = { onCancelCalled = true }
|
val onCancel = { onCancelCalled = true }
|
||||||
|
|
||||||
val fragment = spy(SimpleRedirectDialogFragment.newInstance(themeResId = R.style.Theme_AppCompat_Light))
|
val fragment = spy(SimpleRedirectDialogFragment.newInstance(themeResId = themeResId))
|
||||||
doNothing().`when`(fragment).dismiss()
|
doNothing().`when`(fragment).dismiss()
|
||||||
|
|
||||||
doReturn(testContext).`when`(fragment).requireContext()
|
doReturn(testContext).`when`(fragment).requireContext()
|
||||||
@@ -92,7 +94,7 @@ class SimpleRedirectDialogFragmentTest {
|
|||||||
val onConfirm = { onConfirmCalled = true }
|
val onConfirm = { onConfirmCalled = true }
|
||||||
val onCancel = { onCancelCalled = true }
|
val onCancel = { onCancelCalled = true }
|
||||||
|
|
||||||
val fragment = spy(SimpleRedirectDialogFragment.newInstance(themeResId = R.style.Theme_AppCompat_Light))
|
val fragment = spy(SimpleRedirectDialogFragment.newInstance(themeResId = themeResId))
|
||||||
doNothing().`when`(fragment).dismiss()
|
doNothing().`when`(fragment).dismiss()
|
||||||
|
|
||||||
doReturn(testContext).`when`(fragment).requireContext()
|
doReturn(testContext).`when`(fragment).requireContext()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import mozilla.components.feature.autofill.R
|
|||||||
import mozilla.components.feature.autofill.response.dataset.createInlinePresentation
|
import mozilla.components.feature.autofill.response.dataset.createInlinePresentation
|
||||||
import mozilla.components.feature.autofill.structure.ParsedStructure
|
import mozilla.components.feature.autofill.structure.ParsedStructure
|
||||||
import mozilla.components.feature.autofill.ui.AbstractAutofillUnlockActivity
|
import mozilla.components.feature.autofill.ui.AbstractAutofillUnlockActivity
|
||||||
|
import androidx.biometric.R as biometricR
|
||||||
|
|
||||||
internal data class AuthFillResponseBuilder(
|
internal data class AuthFillResponseBuilder(
|
||||||
private val parsedStructure: ParsedStructure,
|
private val parsedStructure: ParsedStructure,
|
||||||
@@ -82,7 +83,10 @@ internal data class AuthFillResponseBuilder(
|
|||||||
)
|
)
|
||||||
val intentSender: IntentSender = authPendingIntent.intentSender
|
val intentSender: IntentSender = authPendingIntent.intentSender
|
||||||
|
|
||||||
val icon: Icon = Icon.createWithResource(context, R.drawable.fingerprint_dialog_fp_icon)
|
val icon: Icon = Icon.createWithResource(
|
||||||
|
context,
|
||||||
|
biometricR.drawable.fingerprint_dialog_fp_icon,
|
||||||
|
)
|
||||||
val authInlinePresentation = createInlinePresentation(authPendingIntent, imeSpec, title, icon)
|
val authInlinePresentation = createInlinePresentation(authPendingIntent, imeSpec, title, icon)
|
||||||
builder.setAuthentication(
|
builder.setAuthentication(
|
||||||
autofillIds.toTypedArray(),
|
autofillIds.toTypedArray(),
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ dependencies {
|
|||||||
implementation project(':support-ktx')
|
implementation project(':support-ktx')
|
||||||
implementation project(':support-utils')
|
implementation project(':support-utils')
|
||||||
|
|
||||||
|
implementation project(':ui-icons')
|
||||||
|
|
||||||
implementation Dependencies.androidx_core_ktx
|
implementation Dependencies.androidx_core_ktx
|
||||||
implementation Dependencies.kotlin_stdlib
|
implementation Dependencies.kotlin_stdlib
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import mozilla.components.concept.awesomebar.AwesomeBar
|
import mozilla.components.concept.awesomebar.AwesomeBar
|
||||||
import mozilla.components.concept.engine.Engine
|
import mozilla.components.concept.engine.Engine
|
||||||
import mozilla.components.feature.awesomebar.R
|
|
||||||
import mozilla.components.feature.awesomebar.facts.emitClipboardSuggestionClickedFact
|
import mozilla.components.feature.awesomebar.facts.emitClipboardSuggestionClickedFact
|
||||||
import mozilla.components.feature.session.SessionUseCases
|
import mozilla.components.feature.session.SessionUseCases
|
||||||
import mozilla.components.support.utils.WebURLFinder
|
import mozilla.components.support.utils.WebURLFinder
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
private const val MIME_TYPE_TEXT_PLAIN = "text/plain"
|
private const val MIME_TYPE_TEXT_PLAIN = "text/plain"
|
||||||
private const val MINIMUM_CONFIDENCE_SCORE_FOR_URL = 0.7F
|
private const val MINIMUM_CONFIDENCE_SCORE_FOR_URL = 0.7F
|
||||||
@@ -69,7 +69,7 @@ class ClipboardSuggestionProvider(
|
|||||||
description = url,
|
description = url,
|
||||||
editSuggestion = url,
|
editSuggestion = url,
|
||||||
flags = setOf(AwesomeBar.Suggestion.Flag.CLIPBOARD),
|
flags = setOf(AwesomeBar.Suggestion.Flag.CLIPBOARD),
|
||||||
icon = icon ?: ContextCompat.getDrawable(context, R.drawable.mozac_ic_search)?.toBitmap(),
|
icon = icon ?: getSearchIcon(),
|
||||||
title = title,
|
title = title,
|
||||||
onSuggestionClicked = {
|
onSuggestionClicked = {
|
||||||
loadUrlUseCase.invoke(url)
|
loadUrlUseCase.invoke(url)
|
||||||
@@ -78,6 +78,11 @@ class ClipboardSuggestionProvider(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getSearchIcon(): Bitmap? {
|
||||||
|
val drawable = iconsR.drawable.mozac_ic_search
|
||||||
|
return ContextCompat.getDrawable(context, drawable)?.toBitmap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findUrl(text: String): String? {
|
private fun findUrl(text: String): String? {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package mozilla.components.feature.awesomebar.provider
|
package mozilla.components.feature.awesomebar.provider
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@@ -12,7 +13,6 @@ import mozilla.components.concept.engine.Engine
|
|||||||
import mozilla.components.concept.fetch.Client
|
import mozilla.components.concept.fetch.Client
|
||||||
import mozilla.components.concept.fetch.Request
|
import mozilla.components.concept.fetch.Request
|
||||||
import mozilla.components.concept.fetch.Response
|
import mozilla.components.concept.fetch.Response
|
||||||
import mozilla.components.feature.awesomebar.R
|
|
||||||
import mozilla.components.feature.awesomebar.facts.AwesomeBarFacts
|
import mozilla.components.feature.awesomebar.facts.AwesomeBarFacts
|
||||||
import mozilla.components.feature.search.SearchUseCases
|
import mozilla.components.feature.search.SearchUseCases
|
||||||
import mozilla.components.feature.search.ext.createSearchEngine
|
import mozilla.components.feature.search.ext.createSearchEngine
|
||||||
@@ -36,6 +36,7 @@ import org.mockito.Mockito.never
|
|||||||
import org.mockito.Mockito.times
|
import org.mockito.Mockito.times
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
private const val GOOGLE_MOCK_RESPONSE = "[\"firefox\",[\"firefox\",\"firefox for mac\",\"firefox quantum\",\"firefox update\",\"firefox esr\",\"firefox focus\",\"firefox addons\",\"firefox extensions\",\"firefox nightly\",\"firefox clear cache\"]]"
|
private const val GOOGLE_MOCK_RESPONSE = "[\"firefox\",[\"firefox\",\"firefox for mac\",\"firefox quantum\",\"firefox update\",\"firefox esr\",\"firefox focus\",\"firefox addons\",\"firefox extensions\",\"firefox nightly\",\"firefox clear cache\"]]"
|
||||||
private const val GOOGLE_MOCK_RESPONSE_WITH_DUPLICATES = "[\"firefox\",[\"firefox\",\"firefox\",\"firefox for mac\",\"firefox quantum\",\"firefox update\",\"firefox esr\",\"firefox esr\",\"firefox focus\",\"firefox addons\",\"firefox extensions\",\"firefox nightly\",\"firefox clear cache\"]]"
|
private const val GOOGLE_MOCK_RESPONSE_WITH_DUPLICATES = "[\"firefox\",[\"firefox\",\"firefox\",\"firefox for mac\",\"firefox quantum\",\"firefox update\",\"firefox esr\",\"firefox esr\",\"firefox focus\",\"firefox addons\",\"firefox extensions\",\"firefox nightly\",\"firefox clear cache\"]]"
|
||||||
@@ -242,6 +243,16 @@ class SearchSuggestionProviderTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDeviceDesktopIcon(): Bitmap {
|
||||||
|
val drawable = iconsR.drawable.mozac_ic_device_desktop
|
||||||
|
return testContext.getDrawable(drawable)!!.toBitmap()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getSearchIcon(): Bitmap {
|
||||||
|
val drawable = iconsR.drawable.mozac_ic_search
|
||||||
|
return testContext.getDrawable(drawable)!!.toBitmap()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Provider should use engine icon by default`() {
|
fun `Provider should use engine icon by default`() {
|
||||||
runTest {
|
runTest {
|
||||||
@@ -249,7 +260,7 @@ class SearchSuggestionProviderTest {
|
|||||||
server.enqueue(MockResponse().setBody(GOOGLE_MOCK_RESPONSE))
|
server.enqueue(MockResponse().setBody(GOOGLE_MOCK_RESPONSE))
|
||||||
server.start()
|
server.start()
|
||||||
|
|
||||||
val engineIcon = testContext.getDrawable(R.drawable.mozac_ic_device_desktop)!!.toBitmap()
|
val engineIcon = getDeviceDesktopIcon()
|
||||||
|
|
||||||
val searchEngine = createSearchEngine(
|
val searchEngine = createSearchEngine(
|
||||||
name = "Test",
|
name = "Test",
|
||||||
@@ -276,7 +287,7 @@ class SearchSuggestionProviderTest {
|
|||||||
server.enqueue(MockResponse().setBody(GOOGLE_MOCK_RESPONSE))
|
server.enqueue(MockResponse().setBody(GOOGLE_MOCK_RESPONSE))
|
||||||
server.start()
|
server.start()
|
||||||
|
|
||||||
val engineIcon = testContext.getDrawable(R.drawable.mozac_ic_device_desktop)!!.toBitmap()
|
val engineIcon = getDeviceDesktopIcon()
|
||||||
|
|
||||||
val searchEngine = createSearchEngine(
|
val searchEngine = createSearchEngine(
|
||||||
name = "Test",
|
name = "Test",
|
||||||
@@ -285,7 +296,7 @@ class SearchSuggestionProviderTest {
|
|||||||
suggestUrl = server.url("/").toString(),
|
suggestUrl = server.url("/").toString(),
|
||||||
)
|
)
|
||||||
|
|
||||||
val paramIcon = testContext.getDrawable(R.drawable.mozac_ic_search)!!.toBitmap()
|
val paramIcon = getSearchIcon()
|
||||||
|
|
||||||
val provider = SearchSuggestionProvider(
|
val provider = SearchSuggestionProvider(
|
||||||
searchEngine,
|
searchEngine,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import mozilla.components.support.ktx.android.view.setNavigationBarTheme
|
|||||||
import mozilla.components.support.ktx.android.view.setStatusBarTheme
|
import mozilla.components.support.ktx.android.view.setStatusBarTheme
|
||||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
|
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
|
||||||
import mozilla.components.support.utils.ColorUtils.getReadableTextColor
|
import mozilla.components.support.utils.ColorUtils.getReadableTextColor
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes and resets the Toolbar for a Custom Tab based on the CustomTabConfig.
|
* Initializes and resets the Toolbar for a Custom Tab based on the CustomTabConfig.
|
||||||
@@ -164,7 +165,7 @@ class CustomTabsToolbarFeature(
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal fun addCloseButton(tab: CustomTabSessionState, bitmap: Bitmap?) {
|
internal fun addCloseButton(tab: CustomTabSessionState, bitmap: Bitmap?) {
|
||||||
val drawableIcon = bitmap?.toDrawable(context.resources)
|
val drawableIcon = bitmap?.toDrawable(context.resources)
|
||||||
?: getDrawable(context, R.drawable.mozac_ic_close)!!.mutate()
|
?: getDrawable(context, iconsR.drawable.mozac_ic_close)!!.mutate()
|
||||||
|
|
||||||
drawableIcon.setTint(readableColor)
|
drawableIcon.setTint(readableColor)
|
||||||
|
|
||||||
@@ -215,7 +216,7 @@ class CustomTabsToolbarFeature(
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal fun addShareButton(tab: CustomTabSessionState) {
|
internal fun addShareButton(tab: CustomTabSessionState) {
|
||||||
val drawableIcon = getDrawable(context, R.drawable.mozac_ic_share)!!
|
val drawableIcon = getDrawable(context, iconsR.drawable.mozac_ic_share)!!
|
||||||
drawableIcon.setTint(readableColor)
|
drawableIcon.setTint(readableColor)
|
||||||
|
|
||||||
val button = Toolbar.ActionButton(
|
val button = Toolbar.ActionButton(
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.mockito.Mockito
|
|||||||
import org.mockito.Mockito.doNothing
|
import org.mockito.Mockito.doNothing
|
||||||
import org.mockito.Mockito.doReturn
|
import org.mockito.Mockito.doReturn
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@Config(application = TestApplication::class)
|
@Config(application = TestApplication::class)
|
||||||
@@ -149,6 +150,6 @@ class SimpleDownloadDialogFragmentTest {
|
|||||||
class TestApplication : Application() {
|
class TestApplication : Application() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
setTheme(R.style.Theme_AppCompat)
|
setTheme(appcompatR.style.Theme_AppCompat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.mockito.Mockito.doNothing
|
|||||||
import org.mockito.Mockito.doReturn
|
import org.mockito.Mockito.doReturn
|
||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@Config(application = TestApplication::class)
|
@Config(application = TestApplication::class)
|
||||||
@@ -128,6 +129,6 @@ class DownloadAppChooserDialogTest {
|
|||||||
class TestApplication : Application() {
|
class TestApplication : Application() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
setTheme(R.style.Theme_AppCompat)
|
setTheme(appcompatR.style.Theme_AppCompat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import mozilla.components.lib.state.Middleware
|
|||||||
import mozilla.components.lib.state.MiddlewareContext
|
import mozilla.components.lib.state.MiddlewareContext
|
||||||
import mozilla.components.support.base.ids.SharedIdsHelper
|
import mozilla.components.support.base.ids.SharedIdsHelper
|
||||||
import mozilla.components.support.utils.PendingIntentUtils
|
import mozilla.components.support.utils.PendingIntentUtils
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
private const val NOTIFICATION_TAG = "mozac.feature.media.recordingDevices"
|
private const val NOTIFICATION_TAG = "mozac.feature.media.recordingDevices"
|
||||||
private const val NOTIFICATION_ID = 1
|
private const val NOTIFICATION_ID = 1
|
||||||
@@ -126,17 +127,17 @@ internal sealed class RecordingState {
|
|||||||
get() = this !is None
|
get() = this !is None
|
||||||
|
|
||||||
object CameraAndMicrophone : RecordingState() {
|
object CameraAndMicrophone : RecordingState() {
|
||||||
override val iconResource = R.drawable.mozac_ic_video
|
override val iconResource = iconsR.drawable.mozac_ic_video
|
||||||
override val titleResource = R.string.mozac_feature_media_sharing_camera_and_microphone
|
override val titleResource = R.string.mozac_feature_media_sharing_camera_and_microphone
|
||||||
}
|
}
|
||||||
|
|
||||||
object Camera : RecordingState() {
|
object Camera : RecordingState() {
|
||||||
override val iconResource = R.drawable.mozac_ic_video
|
override val iconResource = iconsR.drawable.mozac_ic_video
|
||||||
override val titleResource = R.string.mozac_feature_media_sharing_camera
|
override val titleResource = R.string.mozac_feature_media_sharing_camera
|
||||||
}
|
}
|
||||||
|
|
||||||
object Microphone : RecordingState() {
|
object Microphone : RecordingState() {
|
||||||
override val iconResource = R.drawable.mozac_ic_microphone
|
override val iconResource = iconsR.drawable.mozac_ic_microphone
|
||||||
override val titleResource = R.string.mozac_feature_media_sharing_microphone
|
override val titleResource = R.string.mozac_feature_media_sharing_microphone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.mockito.Mockito.spy
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations.openMocks
|
import org.mockito.MockitoAnnotations.openMocks
|
||||||
import org.robolectric.Shadows.shadowOf
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class AlertDialogFragmentTest {
|
class AlertDialogFragmentTest {
|
||||||
@@ -51,7 +52,7 @@ class AlertDialogFragmentTest {
|
|||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
val titleTextView = dialog.findViewById<TextView>(androidx.appcompat.R.id.alertTitle)
|
val titleTextView = dialog.findViewById<TextView>(appcompatR.id.alertTitle)
|
||||||
val messageTextView = dialog.findViewById<TextView>(R.id.message)
|
val messageTextView = dialog.findViewById<TextView>(R.id.message)
|
||||||
val checkBox = dialog.findViewById<CheckBox>(id.mozac_feature_prompts_no_more_dialogs_check_box)
|
val checkBox = dialog.findViewById<CheckBox>(id.mozac_feature_prompts_no_more_dialogs_check_box)
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.mockito.Mockito.spy
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations.openMocks
|
import org.mockito.MockitoAnnotations.openMocks
|
||||||
import org.robolectric.Shadows.shadowOf
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class AuthenticationDialogFragmentTest {
|
class AuthenticationDialogFragmentTest {
|
||||||
@@ -56,7 +57,7 @@ class AuthenticationDialogFragmentTest {
|
|||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
val titleTextView = dialog.findViewById<TextView>(androidx.appcompat.R.id.alertTitle)
|
val titleTextView = dialog.findViewById<TextView>(appcompatR.id.alertTitle)
|
||||||
val messageTextView = dialog.findViewById<TextView>(android.R.id.message)
|
val messageTextView = dialog.findViewById<TextView>(android.R.id.message)
|
||||||
val usernameEditText = dialog.findViewById<AutofillEditText>(id.username)
|
val usernameEditText = dialog.findViewById<AutofillEditText>(id.username)
|
||||||
val passwordEditText = dialog.findViewById<AutofillEditText>(id.password)
|
val passwordEditText = dialog.findViewById<AutofillEditText>(id.password)
|
||||||
@@ -132,7 +133,7 @@ class AuthenticationDialogFragmentTest {
|
|||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
val titleTextView = dialog.findViewById<TextView>(androidx.appcompat.R.id.alertTitle)
|
val titleTextView = dialog.findViewById<TextView>(appcompatR.id.alertTitle)
|
||||||
|
|
||||||
val defaultTitle = appCompatContext.getString(AuthenticationDialogFragment.DEFAULT_TITLE)
|
val defaultTitle = appCompatContext.getString(AuthenticationDialogFragment.DEFAULT_TITLE)
|
||||||
assertEquals(titleTextView.text.toString(), defaultTitle)
|
assertEquals(titleTextView.text.toString(), defaultTitle)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.mockito.Mockito.spy
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations.openMocks
|
import org.mockito.MockitoAnnotations.openMocks
|
||||||
import org.robolectric.Shadows.shadowOf
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class ConfirmDialogFragmentTest {
|
class ConfirmDialogFragmentTest {
|
||||||
@@ -54,7 +55,7 @@ class ConfirmDialogFragmentTest {
|
|||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
val titleTextView = dialog.findViewById<TextView>(androidx.appcompat.R.id.alertTitle)
|
val titleTextView = dialog.findViewById<TextView>(appcompatR.id.alertTitle)
|
||||||
val messageTextView = dialog.findViewById<TextView>(R.id.message)
|
val messageTextView = dialog.findViewById<TextView>(R.id.message)
|
||||||
|
|
||||||
assertEquals(fragment.sessionId, "sessionId")
|
assertEquals(fragment.sessionId, "sessionId")
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.mockito.Mockito.spy
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations.openMocks
|
import org.mockito.MockitoAnnotations.openMocks
|
||||||
import org.robolectric.Shadows.shadowOf
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class MultiButtonDialogFragmentTest {
|
class MultiButtonDialogFragmentTest {
|
||||||
@@ -61,7 +62,7 @@ class MultiButtonDialogFragmentTest {
|
|||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
val titleTextView = dialog.findViewById<TextView>(androidx.appcompat.R.id.alertTitle)
|
val titleTextView = dialog.findViewById<TextView>(appcompatR.id.alertTitle)
|
||||||
val messageTextView = dialog.findViewById<TextView>(R.id.message)
|
val messageTextView = dialog.findViewById<TextView>(R.id.message)
|
||||||
val checkBox = dialog.findViewById<CheckBox>(id.mozac_feature_prompts_no_more_dialogs_check_box)
|
val checkBox = dialog.findViewById<CheckBox>(id.mozac_feature_prompts_no_more_dialogs_check_box)
|
||||||
val positiveButton = (dialog as AlertDialog).getButton(BUTTON_POSITIVE)
|
val positiveButton = (dialog as AlertDialog).getButton(BUTTON_POSITIVE)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.mockito.Mockito.times
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.robolectric.Shadows
|
import org.robolectric.Shadows
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class SaveLoginDialogFragmentTest : TestCase() {
|
class SaveLoginDialogFragmentTest : TestCase() {
|
||||||
@@ -96,7 +97,7 @@ class SaveLoginDialogFragmentTest : TestCase() {
|
|||||||
icon,
|
icon,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val defaultIconResource = R.drawable.mozac_ic_globe
|
val defaultIconResource = iconsR.drawable.mozac_ic_globe
|
||||||
doReturn(appCompatContext).`when`(fragment).requireContext()
|
doReturn(appCompatContext).`when`(fragment).requireContext()
|
||||||
doAnswer {
|
doAnswer {
|
||||||
FrameLayout(appCompatContext).apply {
|
FrameLayout(appCompatContext).apply {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.mockito.Mockito.spy
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
import org.robolectric.Shadows.shadowOf
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class TextPromptDialogFragmentTest {
|
class TextPromptDialogFragmentTest {
|
||||||
@@ -49,7 +50,7 @@ class TextPromptDialogFragmentTest {
|
|||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
val titleTextView = dialog.findViewById<TextView>(androidx.appcompat.R.id.alertTitle)
|
val titleTextView = dialog.findViewById<TextView>(appcompatR.id.alertTitle)
|
||||||
val inputLabel = dialog.findViewById<TextView>(id.input_label)
|
val inputLabel = dialog.findViewById<TextView>(id.input_label)
|
||||||
val inputValue = dialog.findViewById<TextView>(id.input_value)
|
val inputValue = dialog.findViewById<TextView>(id.input_value)
|
||||||
val checkBox = dialog.findViewById<CheckBox>(id.mozac_feature_prompts_no_more_dialogs_check_box)
|
val checkBox = dialog.findViewById<CheckBox>(id.mozac_feature_prompts_no_more_dialogs_check_box)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
package mozilla.ext
|
package mozilla.ext
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.appcompat.R
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import mozilla.components.feature.readerview.R
|
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ import mozilla.components.support.ktx.kotlin.stripDefaultPort
|
|||||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.filterChanged
|
import mozilla.components.support.ktx.kotlinx.coroutines.flow.filterChanged
|
||||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
|
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
|
||||||
import java.security.InvalidParameterException
|
import java.security.InvalidParameterException
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
internal const val FRAGMENT_TAG = "mozac_feature_sitepermissions_prompt_dialog"
|
internal const val FRAGMENT_TAG = "mozac_feature_sitepermissions_prompt_dialog"
|
||||||
|
|
||||||
@@ -733,7 +734,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_camera_and_microphone,
|
R.string.mozac_feature_sitepermissions_camera_and_microphone,
|
||||||
R.drawable.mozac_ic_microphone,
|
iconsR.drawable.mozac_ic_microphone,
|
||||||
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
||||||
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
||||||
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
||||||
@@ -757,7 +758,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_location_title,
|
R.string.mozac_feature_sitepermissions_location_title,
|
||||||
R.drawable.mozac_ic_location,
|
iconsR.drawable.mozac_ic_location,
|
||||||
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
||||||
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
||||||
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
||||||
@@ -769,7 +770,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_notification_title,
|
R.string.mozac_feature_sitepermissions_notification_title,
|
||||||
R.drawable.mozac_ic_notification,
|
iconsR.drawable.mozac_ic_notification,
|
||||||
showDoNotAskAgainCheckBox = false,
|
showDoNotAskAgainCheckBox = false,
|
||||||
shouldSelectRememberChoice = false,
|
shouldSelectRememberChoice = false,
|
||||||
isNotificationRequest = true,
|
isNotificationRequest = true,
|
||||||
@@ -781,7 +782,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_microfone_title,
|
R.string.mozac_feature_sitepermissions_microfone_title,
|
||||||
R.drawable.mozac_ic_microphone,
|
iconsR.drawable.mozac_ic_microphone,
|
||||||
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
||||||
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
||||||
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
||||||
@@ -793,7 +794,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_camera_title,
|
R.string.mozac_feature_sitepermissions_camera_title,
|
||||||
R.drawable.mozac_ic_video,
|
iconsR.drawable.mozac_ic_video,
|
||||||
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
showDoNotAskAgainCheckBox = shouldShowDoNotAskAgainCheckBox,
|
||||||
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
shouldSelectRememberChoice = dialogConfig?.shouldPreselectDoNotAskAgain
|
||||||
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
?: DialogConfig.DEFAULT_PRESELECT_DO_NOT_ASK_AGAIN,
|
||||||
@@ -805,7 +806,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_persistent_storage_title,
|
R.string.mozac_feature_sitepermissions_persistent_storage_title,
|
||||||
R.drawable.mozac_ic_storage,
|
iconsR.drawable.mozac_ic_storage,
|
||||||
showDoNotAskAgainCheckBox = false,
|
showDoNotAskAgainCheckBox = false,
|
||||||
shouldSelectRememberChoice = true,
|
shouldSelectRememberChoice = true,
|
||||||
)
|
)
|
||||||
@@ -816,7 +817,7 @@ class SitePermissionsFeature(
|
|||||||
host,
|
host,
|
||||||
permissionRequest,
|
permissionRequest,
|
||||||
R.string.mozac_feature_sitepermissions_media_key_system_access_title,
|
R.string.mozac_feature_sitepermissions_media_key_system_access_title,
|
||||||
R.drawable.mozac_ic_link,
|
iconsR.drawable.mozac_ic_link,
|
||||||
showDoNotAskAgainCheckBox = false,
|
showDoNotAskAgainCheckBox = false,
|
||||||
shouldSelectRememberChoice = true,
|
shouldSelectRememberChoice = true,
|
||||||
)
|
)
|
||||||
@@ -889,7 +890,7 @@ class SitePermissionsFeature(
|
|||||||
return SitePermissionsDialogFragment.newInstance(
|
return SitePermissionsDialogFragment.newInstance(
|
||||||
sessionId = currentSession.id,
|
sessionId = currentSession.id,
|
||||||
title = title,
|
title = title,
|
||||||
titleIcon = R.drawable.mozac_ic_cookies,
|
titleIcon = iconsR.drawable.mozac_ic_cookies,
|
||||||
message = message,
|
message = message,
|
||||||
negativeButtonText = negativeButtonText,
|
negativeButtonText = negativeButtonText,
|
||||||
permissionRequestId = permissionRequest.id,
|
permissionRequestId = permissionRequest.id,
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ import org.mockito.Mockito.doNothing
|
|||||||
import org.mockito.Mockito.doReturn
|
import org.mockito.Mockito.doReturn
|
||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
import androidx.core.R as coreR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class SitePermissionsDialogFragmentTest {
|
class SitePermissionsDialogFragmentTest {
|
||||||
|
|
||||||
private val permissionRequestId = "permissionID"
|
private val permissionRequestId = "permissionID"
|
||||||
|
private val titleIcon = coreR.drawable.notification_icon_background
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `build dialog`() {
|
fun `build dialog`() {
|
||||||
@@ -37,7 +39,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = true,
|
shouldShowDoNotAskAgainCheckBox = true,
|
||||||
@@ -61,7 +63,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = true,
|
shouldShowDoNotAskAgainCheckBox = true,
|
||||||
@@ -86,7 +88,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = true,
|
shouldShowDoNotAskAgainCheckBox = true,
|
||||||
@@ -111,7 +113,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -135,7 +137,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -159,7 +161,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -184,7 +186,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -208,7 +210,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = feature,
|
feature = feature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -237,7 +239,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mockFeature,
|
feature = mockFeature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -269,7 +271,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mockFeature,
|
feature = mockFeature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -297,7 +299,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -319,7 +321,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -341,7 +343,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mockFeature,
|
feature = mockFeature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -374,7 +376,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mockFeature,
|
feature = mockFeature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -407,7 +409,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mockFeature,
|
feature = mockFeature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -443,7 +445,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mockFeature,
|
feature = mockFeature,
|
||||||
shouldShowDoNotAskAgainCheckBox = false,
|
shouldShowDoNotAskAgainCheckBox = false,
|
||||||
@@ -468,7 +470,7 @@ class SitePermissionsDialogFragmentTest {
|
|||||||
SitePermissionsDialogFragment.newInstance(
|
SitePermissionsDialogFragment.newInstance(
|
||||||
"sessionId",
|
"sessionId",
|
||||||
"title",
|
"title",
|
||||||
R.drawable.notification_icon_background,
|
titleIcon,
|
||||||
permissionRequestId = permissionRequestId,
|
permissionRequestId = permissionRequestId,
|
||||||
feature = mock(),
|
feature = mock(),
|
||||||
shouldShowDoNotAskAgainCheckBox = true,
|
shouldShowDoNotAskAgainCheckBox = true,
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ import org.mockito.Mockito.times
|
|||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import java.security.InvalidParameterException
|
import java.security.InvalidParameterException
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class SitePermissionsFeatureTest {
|
class SitePermissionsFeatureTest {
|
||||||
@@ -1094,7 +1095,7 @@ class SitePermissionsFeatureTest {
|
|||||||
),
|
),
|
||||||
dialog.title,
|
dialog.title,
|
||||||
)
|
)
|
||||||
assertEquals(R.drawable.mozac_ic_cookies, dialog.icon)
|
assertEquals(iconsR.drawable.mozac_ic_cookies, dialog.icon)
|
||||||
assertEquals(permissionRequest.id, dialog.permissionRequestId)
|
assertEquals(permissionRequest.id, dialog.permissionRequestId)
|
||||||
assertEquals(sitePermissionFeature, dialog.feature)
|
assertEquals(sitePermissionFeature, dialog.feature)
|
||||||
assertEquals(false, dialog.shouldShowDoNotAskAgainCheckBox)
|
assertEquals(false, dialog.shouldShowDoNotAskAgainCheckBox)
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ import mozilla.components.browser.state.state.recover.RecoverableTab
|
|||||||
import mozilla.components.browser.state.state.recover.TabState
|
import mozilla.components.browser.state.state.recover.TabState
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.concept.menu.MenuController
|
import mozilla.components.concept.menu.MenuController
|
||||||
import mozilla.components.feature.tabs.R
|
|
||||||
import mozilla.components.support.test.ext.joinBlocking
|
import mozilla.components.support.test.ext.joinBlocking
|
||||||
import mozilla.components.support.test.mock
|
import mozilla.components.support.test.mock
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import mozilla.components.support.test.rule.MainCoroutineRule
|
import mozilla.components.support.test.rule.MainCoroutineRule
|
||||||
import mozilla.components.support.test.whenever
|
import mozilla.components.support.test.whenever
|
||||||
|
import mozilla.components.ui.tabcounter.R
|
||||||
import mozilla.components.ui.tabcounter.TabCounter
|
import mozilla.components.ui.tabcounter.TabCounter
|
||||||
import mozilla.components.ui.tabcounter.TabCounterMenu
|
import mozilla.components.ui.tabcounter.TabCounterMenu
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import mozilla.components.concept.toolbar.Toolbar.Action
|
|||||||
import mozilla.components.support.base.android.Padding
|
import mozilla.components.support.base.android.Padding
|
||||||
import mozilla.components.support.ktx.android.view.setPadding
|
import mozilla.components.support.ktx.android.view.setPadding
|
||||||
import mozilla.components.support.utils.DrawableUtils.loadAndTintDrawable
|
import mozilla.components.support.utils.DrawableUtils.loadAndTintDrawable
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An action button that represents a container to be added to the toolbar.
|
* An action button that represents a container to be added to the toolbar.
|
||||||
@@ -56,19 +57,19 @@ class ContainerToolbarAction(
|
|||||||
@ColorInt val tint = getTint(context, container.color)
|
@ColorInt val tint = getTint(context, container.color)
|
||||||
|
|
||||||
return when (container.icon) {
|
return when (container.icon) {
|
||||||
Icon.FINGERPRINT -> loadAndTintDrawable(context, R.drawable.mozac_ic_fingerprint, tint)
|
Icon.FINGERPRINT -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_fingerprint, tint)
|
||||||
Icon.BRIEFCASE -> loadAndTintDrawable(context, R.drawable.mozac_ic_briefcase, tint)
|
Icon.BRIEFCASE -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_briefcase, tint)
|
||||||
Icon.DOLLAR -> loadAndTintDrawable(context, R.drawable.mozac_ic_dollar, tint)
|
Icon.DOLLAR -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_dollar, tint)
|
||||||
Icon.CART -> loadAndTintDrawable(context, R.drawable.mozac_ic_cart, tint)
|
Icon.CART -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_cart, tint)
|
||||||
Icon.CIRCLE -> loadAndTintDrawable(context, R.drawable.mozac_ic_circle, tint)
|
Icon.CIRCLE -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_circle, tint)
|
||||||
Icon.GIFT -> loadAndTintDrawable(context, R.drawable.mozac_ic_gift, tint)
|
Icon.GIFT -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_gift, tint)
|
||||||
Icon.VACATION -> loadAndTintDrawable(context, R.drawable.mozac_ic_vacation, tint)
|
Icon.VACATION -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_vacation, tint)
|
||||||
Icon.FOOD -> loadAndTintDrawable(context, R.drawable.mozac_ic_food, tint)
|
Icon.FOOD -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_food, tint)
|
||||||
Icon.FRUIT -> loadAndTintDrawable(context, R.drawable.mozac_ic_fruit, tint)
|
Icon.FRUIT -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_fruit, tint)
|
||||||
Icon.PET -> loadAndTintDrawable(context, R.drawable.mozac_ic_pet, tint)
|
Icon.PET -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_pet, tint)
|
||||||
Icon.TREE -> loadAndTintDrawable(context, R.drawable.mozac_ic_tree, tint)
|
Icon.TREE -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_tree, tint)
|
||||||
Icon.CHILL -> loadAndTintDrawable(context, R.drawable.mozac_ic_chill, tint)
|
Icon.CHILL -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_chill, tint)
|
||||||
Icon.FENCE -> loadAndTintDrawable(context, R.drawable.mozac_ic_fence, tint)
|
Icon.FENCE -> loadAndTintDrawable(context, iconsR.drawable.mozac_ic_fence, tint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import mozilla.components.support.base.android.Padding
|
|||||||
import mozilla.components.support.base.log.Log
|
import mozilla.components.support.base.log.Log
|
||||||
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
import mozilla.components.support.ktx.android.content.res.resolveAttribute
|
||||||
import mozilla.components.support.ktx.android.view.setPadding
|
import mozilla.components.support.ktx.android.view.setPadding
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An action button that represents an web extension item to be added to the toolbar.
|
* An action button that represents an web extension item to be added to the toolbar.
|
||||||
@@ -76,7 +77,9 @@ open class WebExtensionToolbarAction(
|
|||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
MainScope().launch {
|
MainScope().launch {
|
||||||
imageView.setImageResource(R.drawable.mozac_ic_web_extension_default_icon)
|
imageView.setImageResource(
|
||||||
|
iconsR.drawable.mozac_ic_web_extension_default_icon,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Log.log(
|
Log.log(
|
||||||
Log.Priority.ERROR,
|
Log.Priority.ERROR,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class WebExtensionToolbarTest {
|
class WebExtensionToolbarTest {
|
||||||
@@ -97,7 +98,9 @@ class WebExtensionToolbarTest {
|
|||||||
action.iconJob?.joinBlocking()
|
action.iconJob?.joinBlocking()
|
||||||
testDispatcher.scheduler.advanceUntilIdle()
|
testDispatcher.scheduler.advanceUntilIdle()
|
||||||
|
|
||||||
verify(imageView).setImageResource(R.drawable.mozac_ic_web_extension_default_icon)
|
verify(imageView).setImageResource(
|
||||||
|
iconsR.drawable.mozac_ic_web_extension_default_icon,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import mozilla.components.support.base.facts.Action
|
|||||||
import mozilla.components.support.base.facts.Fact
|
import mozilla.components.support.base.facts.Fact
|
||||||
import mozilla.components.support.base.facts.collect
|
import mozilla.components.support.base.facts.collect
|
||||||
import mozilla.components.support.utils.SafeUrl
|
import mozilla.components.support.utils.SafeUrl
|
||||||
|
import androidx.appcompat.R as appcompatR
|
||||||
|
|
||||||
typealias OnCommitListener = () -> Unit
|
typealias OnCommitListener = () -> Unit
|
||||||
typealias OnFilterListener = (String) -> Unit
|
typealias OnFilterListener = (String) -> Unit
|
||||||
@@ -95,7 +96,7 @@ interface AutocompleteView {
|
|||||||
open class InlineAutocompleteEditText @JvmOverloads constructor(
|
open class InlineAutocompleteEditText @JvmOverloads constructor(
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = R.attr.editTextStyle,
|
defStyleAttr: Int = appcompatR.attr.editTextStyle,
|
||||||
) : AppCompatEditText(ctx, attrs, defStyleAttr), AutocompleteView {
|
) : AppCompatEditText(ctx, attrs, defStyleAttr), AutocompleteView {
|
||||||
|
|
||||||
data class AutocompleteResult(
|
data class AutocompleteResult(
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class InlineAutocompleteEditTextTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onFocusChange() {
|
fun onFocusChange() {
|
||||||
val et = InlineAutocompleteEditText(testContext, attributes, R.attr.editTextStyle)
|
val et = InlineAutocompleteEditText(testContext, attributes)
|
||||||
val searchStates = mutableListOf<Boolean>()
|
val searchStates = mutableListOf<Boolean>()
|
||||||
|
|
||||||
et.setOnSearchStateChangeListener { b: Boolean -> searchStates.add(searchStates.size, b) }
|
et.setOnSearchStateChangeListener { b: Boolean -> searchStates.add(searchStates.size, b) }
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ dependencies {
|
|||||||
implementation project(':concept-menu')
|
implementation project(':concept-menu')
|
||||||
implementation project(':browser-menu2')
|
implementation project(':browser-menu2')
|
||||||
implementation project(':support-base')
|
implementation project(':support-base')
|
||||||
|
implementation project(':ui-icons')
|
||||||
|
|
||||||
testImplementation project(":support-test")
|
testImplementation project(":support-test")
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import mozilla.components.concept.menu.MenuController
|
|||||||
import mozilla.components.concept.menu.candidate.DrawableMenuIcon
|
import mozilla.components.concept.menu.candidate.DrawableMenuIcon
|
||||||
import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
import mozilla.components.concept.menu.candidate.TextMenuCandidate
|
||||||
import mozilla.components.concept.menu.candidate.TextStyle
|
import mozilla.components.concept.menu.candidate.TextStyle
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu that is shown when clicking on the [TabCounter]
|
* The menu that is shown when clicking on the [TabCounter]
|
||||||
@@ -53,7 +54,7 @@ open class TabCounterMenu(
|
|||||||
text = context.getString(R.string.mozac_browser_menu_new_tab),
|
text = context.getString(R.string.mozac_browser_menu_new_tab),
|
||||||
start = DrawableMenuIcon(
|
start = DrawableMenuIcon(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_new,
|
iconsR.drawable.mozac_ic_new,
|
||||||
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
||||||
),
|
),
|
||||||
textStyle = TextStyle(),
|
textStyle = TextStyle(),
|
||||||
@@ -65,7 +66,7 @@ open class TabCounterMenu(
|
|||||||
text = context.getString(R.string.mozac_browser_menu_new_private_tab),
|
text = context.getString(R.string.mozac_browser_menu_new_private_tab),
|
||||||
start = DrawableMenuIcon(
|
start = DrawableMenuIcon(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_private_browsing,
|
iconsR.drawable.mozac_ic_private_browsing,
|
||||||
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
||||||
),
|
),
|
||||||
textStyle = TextStyle(),
|
textStyle = TextStyle(),
|
||||||
@@ -77,7 +78,7 @@ open class TabCounterMenu(
|
|||||||
text = context.getString(R.string.mozac_close_tab),
|
text = context.getString(R.string.mozac_close_tab),
|
||||||
start = DrawableMenuIcon(
|
start = DrawableMenuIcon(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_close,
|
iconsR.drawable.mozac_ic_close,
|
||||||
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
||||||
),
|
),
|
||||||
textStyle = TextStyle(),
|
textStyle = TextStyle(),
|
||||||
@@ -89,7 +90,7 @@ open class TabCounterMenu(
|
|||||||
text = context.getString(R.string.mozac_ui_tabcounter_duplicate_tab),
|
text = context.getString(R.string.mozac_ui_tabcounter_duplicate_tab),
|
||||||
start = DrawableMenuIcon(
|
start = DrawableMenuIcon(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_tab,
|
iconsR.drawable.mozac_ic_tab,
|
||||||
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
tint = iconColor ?: getColor(context, R.color.mozac_ui_tabcounter_default_text),
|
||||||
),
|
),
|
||||||
textStyle = TextStyle(),
|
textStyle = TextStyle(),
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.junit.Assert.assertTrue
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class WidgetSiteItemViewTest {
|
class WidgetSiteItemViewTest {
|
||||||
@@ -69,8 +70,8 @@ class WidgetSiteItemViewTest {
|
|||||||
val secondaryButton = view.findViewById<ImageButton>(R.id.secondary_button)
|
val secondaryButton = view.findViewById<ImageButton>(R.id.secondary_button)
|
||||||
var clicked = false
|
var clicked = false
|
||||||
view.setSecondaryButton(
|
view.setSecondaryButton(
|
||||||
icon = R.drawable.mozac_ic_lock,
|
icon = iconsR.drawable.mozac_ic_lock,
|
||||||
contentDescription = R.string.mozac_error_lock,
|
contentDescription = iconsR.string.mozac_error_lock,
|
||||||
onClickListener = { clicked = true },
|
onClickListener = { clicked = true },
|
||||||
)
|
)
|
||||||
assertTrue(secondaryButton.isVisible)
|
assertTrue(secondaryButton.isVisible)
|
||||||
|
|||||||
@@ -48,3 +48,5 @@ libLicenseUrl=https://www.mozilla.org/en-US/MPL/2.0/
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=false
|
android.enableJetifier=false
|
||||||
|
|
||||||
|
# Non-Transitive R Classes
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ import org.mozilla.samples.browser.ext.components
|
|||||||
import org.mozilla.samples.browser.integration.FindInPageIntegration
|
import org.mozilla.samples.browser.integration.FindInPageIntegration
|
||||||
import org.mozilla.samples.browser.request.SampleUrlEncodedRequestInterceptor
|
import org.mozilla.samples.browser.request.SampleUrlEncodedRequestInterceptor
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import mozilla.components.ui.colors.R.color as photonColors
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
private const val DAY_IN_MINUTES = 24 * 60L
|
private const val DAY_IN_MINUTES = 24 * 60L
|
||||||
|
|
||||||
@@ -253,7 +255,7 @@ open class DefaultComponents(private val applicationContext: Context) {
|
|||||||
menuItems,
|
menuItems,
|
||||||
store = store,
|
store = store,
|
||||||
style = WebExtensionBrowserMenuBuilder.Style(
|
style = WebExtensionBrowserMenuBuilder.Style(
|
||||||
webExtIconTintColorResource = R.color.photonGrey90,
|
webExtIconTintColorResource = photonColors.photonGrey90,
|
||||||
),
|
),
|
||||||
onAddonsManagerTapped = {
|
onAddonsManagerTapped = {
|
||||||
val intent = Intent(applicationContext, AddonsActivity::class.java)
|
val intent = Intent(applicationContext, AddonsActivity::class.java)
|
||||||
@@ -268,7 +270,7 @@ open class DefaultComponents(private val applicationContext: Context) {
|
|||||||
menuToolbar,
|
menuToolbar,
|
||||||
BrowserMenuHighlightableItem(
|
BrowserMenuHighlightableItem(
|
||||||
"No Highlight",
|
"No Highlight",
|
||||||
R.drawable.mozac_ic_share,
|
iconsR.drawable.mozac_ic_share,
|
||||||
android.R.color.black,
|
android.R.color.black,
|
||||||
highlight = BrowserMenuHighlight.LowPriority(
|
highlight = BrowserMenuHighlight.LowPriority(
|
||||||
notificationTint = ContextCompat.getColor(applicationContext, android.R.color.holo_green_dark),
|
notificationTint = ContextCompat.getColor(applicationContext, android.R.color.holo_green_dark),
|
||||||
@@ -277,7 +279,7 @@ open class DefaultComponents(private val applicationContext: Context) {
|
|||||||
) {
|
) {
|
||||||
Toast.makeText(applicationContext, "Highlight", Toast.LENGTH_SHORT).show()
|
Toast.makeText(applicationContext, "Highlight", Toast.LENGTH_SHORT).show()
|
||||||
},
|
},
|
||||||
BrowserMenuImageText("Share", R.drawable.mozac_ic_share, android.R.color.black) {
|
BrowserMenuImageText("Share", iconsR.drawable.mozac_ic_share, android.R.color.black) {
|
||||||
Toast.makeText(applicationContext, "Share", Toast.LENGTH_SHORT).show()
|
Toast.makeText(applicationContext, "Share", Toast.LENGTH_SHORT).show()
|
||||||
},
|
},
|
||||||
SimpleBrowserMenuItem("Settings") {
|
SimpleBrowserMenuItem("Settings") {
|
||||||
@@ -350,41 +352,41 @@ open class DefaultComponents(private val applicationContext: Context) {
|
|||||||
|
|
||||||
private val menuToolbar by lazy {
|
private val menuToolbar by lazy {
|
||||||
val back = BrowserMenuItemToolbar.TwoStateButton(
|
val back = BrowserMenuItemToolbar.TwoStateButton(
|
||||||
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_back,
|
primaryImageResource = iconsR.drawable.mozac_ic_back,
|
||||||
primaryImageTintResource = R.color.photonBlue90,
|
primaryImageTintResource = photonColors.photonBlue90,
|
||||||
primaryContentDescription = "Back",
|
primaryContentDescription = "Back",
|
||||||
isInPrimaryState = {
|
isInPrimaryState = {
|
||||||
store.state.selectedTab?.content?.canGoBack ?: true
|
store.state.selectedTab?.content?.canGoBack ?: true
|
||||||
},
|
},
|
||||||
disableInSecondaryState = true,
|
disableInSecondaryState = true,
|
||||||
secondaryImageTintResource = R.color.photonGrey40,
|
secondaryImageTintResource = photonColors.photonGrey40,
|
||||||
) {
|
) {
|
||||||
sessionUseCases.goBack()
|
sessionUseCases.goBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
val forward = BrowserMenuItemToolbar.TwoStateButton(
|
val forward = BrowserMenuItemToolbar.TwoStateButton(
|
||||||
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_forward,
|
primaryImageResource = iconsR.drawable.mozac_ic_forward,
|
||||||
primaryContentDescription = "Forward",
|
primaryContentDescription = "Forward",
|
||||||
primaryImageTintResource = R.color.photonBlue90,
|
primaryImageTintResource = photonColors.photonBlue90,
|
||||||
isInPrimaryState = {
|
isInPrimaryState = {
|
||||||
store.state.selectedTab?.content?.canGoForward ?: true
|
store.state.selectedTab?.content?.canGoForward ?: true
|
||||||
},
|
},
|
||||||
disableInSecondaryState = true,
|
disableInSecondaryState = true,
|
||||||
secondaryImageTintResource = R.color.photonGrey40,
|
secondaryImageTintResource = photonColors.photonGrey40,
|
||||||
) {
|
) {
|
||||||
sessionUseCases.goForward()
|
sessionUseCases.goForward()
|
||||||
}
|
}
|
||||||
|
|
||||||
val refresh = BrowserMenuItemToolbar.TwoStateButton(
|
val refresh = BrowserMenuItemToolbar.TwoStateButton(
|
||||||
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_refresh,
|
primaryImageResource = iconsR.drawable.mozac_ic_refresh,
|
||||||
primaryContentDescription = "Refresh",
|
primaryContentDescription = "Refresh",
|
||||||
primaryImageTintResource = R.color.photonBlue90,
|
primaryImageTintResource = photonColors.photonBlue90,
|
||||||
isInPrimaryState = {
|
isInPrimaryState = {
|
||||||
store.state.selectedTab?.content?.loading == false
|
store.state.selectedTab?.content?.loading == false
|
||||||
},
|
},
|
||||||
secondaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_stop,
|
secondaryImageResource = iconsR.drawable.mozac_ic_stop,
|
||||||
secondaryContentDescription = "Stop",
|
secondaryContentDescription = "Stop",
|
||||||
secondaryImageTintResource = R.color.photonBlue90,
|
secondaryImageTintResource = photonColors.photonBlue90,
|
||||||
disableInSecondaryState = false,
|
disableInSecondaryState = false,
|
||||||
) {
|
) {
|
||||||
if (store.state.selectedTab?.content?.loading == true) {
|
if (store.state.selectedTab?.content?.loading == true) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import mozilla.components.support.base.feature.UserInteractionHandler
|
|||||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||||
import org.mozilla.samples.browser.databinding.FragmentTabstrayBinding
|
import org.mozilla.samples.browser.databinding.FragmentTabstrayBinding
|
||||||
import org.mozilla.samples.browser.ext.components
|
import org.mozilla.samples.browser.ext.components
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fragment for displaying the tabs tray.
|
* A fragment for displaying the tabs tray.
|
||||||
@@ -35,7 +36,7 @@ class TabsTrayFragment : Fragment(), UserInteractionHandler {
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val binding = FragmentTabstrayBinding.bind(view)
|
val binding = FragmentTabstrayBinding.bind(view)
|
||||||
binding.toolbar.setNavigationIcon(R.drawable.mozac_ic_back)
|
binding.toolbar.setNavigationIcon(iconsR.drawable.mozac_ic_back)
|
||||||
binding.toolbar.setNavigationOnClickListener {
|
binding.toolbar.setNavigationOnClickListener {
|
||||||
closeTabsTray()
|
closeTabsTray()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.mozilla.samples.browser.R
|
|||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import mozilla.components.feature.addons.R as addonsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity to show the details of an add-on.
|
* An activity to show the details of an add-on.
|
||||||
@@ -65,7 +66,9 @@ class AddonDetailsActivity : AppCompatActivity() {
|
|||||||
val ratingView = findViewById<RatingBar>(R.id.rating_view)
|
val ratingView = findViewById<RatingBar>(R.id.rating_view)
|
||||||
val userCountView = findViewById<TextView>(R.id.users_count)
|
val userCountView = findViewById<TextView>(R.id.users_count)
|
||||||
|
|
||||||
val ratingContentDescription = getString(R.string.mozac_feature_addons_rating_content_description)
|
val ratingContentDescription = getString(
|
||||||
|
addonsR.string.mozac_feature_addons_rating_content_description,
|
||||||
|
)
|
||||||
ratingView.contentDescription = String.format(ratingContentDescription, it.average)
|
ratingView.contentDescription = String.format(ratingContentDescription, it.average)
|
||||||
ratingView.rating = it.average
|
ratingView.rating = it.average
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import org.mozilla.samples.browser.databinding.FragmentAddOnsBinding
|
|||||||
import org.mozilla.samples.browser.databinding.OverlayAddOnProgressBinding
|
import org.mozilla.samples.browser.databinding.OverlayAddOnProgressBinding
|
||||||
import org.mozilla.samples.browser.ext.components
|
import org.mozilla.samples.browser.ext.components
|
||||||
import java.util.concurrent.CancellationException
|
import java.util.concurrent.CancellationException
|
||||||
|
import androidx.browser.R as androidxBrowserR
|
||||||
|
import mozilla.components.browser.menu.R as menuR
|
||||||
|
import mozilla.components.feature.addons.R as addonsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment use for managing add-ons.
|
* Fragment use for managing add-ons.
|
||||||
@@ -82,8 +85,8 @@ class AddonsFragment : Fragment(), AddonsManagerAdapterDelegate {
|
|||||||
val addons = context.components.addonManager.getAddons()
|
val addons = context.components.addonManager.getAddons()
|
||||||
|
|
||||||
val style = AddonsManagerAdapter.Style(
|
val style = AddonsManagerAdapter.Style(
|
||||||
dividerColor = R.color.browser_actions_divider_color,
|
dividerColor = androidxBrowserR.color.browser_actions_divider_color,
|
||||||
dividerHeight = R.dimen.mozac_browser_menu_item_divider_height,
|
dividerHeight = menuR.dimen.mozac_browser_menu_item_divider_height,
|
||||||
)
|
)
|
||||||
|
|
||||||
scope.launch(Dispatchers.Main) {
|
scope.launch(Dispatchers.Main) {
|
||||||
@@ -103,7 +106,7 @@ class AddonsFragment : Fragment(), AddonsManagerAdapterDelegate {
|
|||||||
scope.launch(Dispatchers.Main) {
|
scope.launch(Dispatchers.Main) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
R.string.mozac_feature_addons_failed_to_query_add_ons,
|
addonsR.string.mozac_feature_addons_failed_to_query_add_ons,
|
||||||
Toast.LENGTH_SHORT,
|
Toast.LENGTH_SHORT,
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
@@ -213,7 +216,7 @@ class AddonsFragment : Fragment(), AddonsManagerAdapterDelegate {
|
|||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
getString(
|
getString(
|
||||||
R.string.mozac_feature_addons_failed_to_install,
|
addonsR.string.mozac_feature_addons_failed_to_install,
|
||||||
addon.translateName(requireContext()),
|
addon.translateName(requireContext()),
|
||||||
),
|
),
|
||||||
Toast.LENGTH_SHORT,
|
Toast.LENGTH_SHORT,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
import androidx.appcompat.widget.SwitchCompat
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -20,6 +21,7 @@ import mozilla.components.support.utils.ext.getParcelableExtraCompat
|
|||||||
import org.mozilla.samples.browser.BrowserActivity
|
import org.mozilla.samples.browser.BrowserActivity
|
||||||
import org.mozilla.samples.browser.R
|
import org.mozilla.samples.browser.R
|
||||||
import org.mozilla.samples.browser.ext.components
|
import org.mozilla.samples.browser.ext.components
|
||||||
|
import mozilla.components.feature.addons.R as addonsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity to show the details of a installed add-on.
|
* An activity to show the details of a installed add-on.
|
||||||
@@ -53,7 +55,7 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
|
|||||||
scope.launch(Dispatchers.Main) {
|
scope.launch(Dispatchers.Main) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
baseContext,
|
baseContext,
|
||||||
R.string.mozac_feature_addons_failed_to_query_add_ons,
|
addonsR.string.mozac_feature_addons_failed_to_query_add_ons,
|
||||||
Toast.LENGTH_SHORT,
|
Toast.LENGTH_SHORT,
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
@@ -86,18 +88,16 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
|
|||||||
addon,
|
addon,
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
switch.setState(true)
|
switch.setState(true)
|
||||||
Toast.makeText(
|
showAddonToast(
|
||||||
this,
|
addonsR.string.mozac_feature_addons_successfully_enabled,
|
||||||
getString(R.string.mozac_feature_addons_successfully_enabled, addon.translateName(this)),
|
addon,
|
||||||
Toast.LENGTH_SHORT,
|
)
|
||||||
).show()
|
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
Toast.makeText(
|
showAddonToast(
|
||||||
this,
|
addonsR.string.mozac_feature_addons_failed_to_enable,
|
||||||
getString(R.string.mozac_feature_addons_failed_to_enable, addon.translateName(this)),
|
addon,
|
||||||
Toast.LENGTH_SHORT,
|
)
|
||||||
).show()
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -105,18 +105,16 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
|
|||||||
addon,
|
addon,
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
switch.setState(false)
|
switch.setState(false)
|
||||||
Toast.makeText(
|
showAddonToast(
|
||||||
this,
|
addonsR.string.mozac_feature_addons_successfully_disabled,
|
||||||
getString(R.string.mozac_feature_addons_successfully_disabled, addon.translateName(this)),
|
addon,
|
||||||
Toast.LENGTH_SHORT,
|
)
|
||||||
).show()
|
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
Toast.makeText(
|
showAddonToast(
|
||||||
this,
|
addonsR.string.mozac_feature_addons_failed_to_disable,
|
||||||
getString(R.string.mozac_feature_addons_failed_to_disable, addon.translateName(this)),
|
addon,
|
||||||
Toast.LENGTH_SHORT,
|
)
|
||||||
).show()
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -176,29 +174,35 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
|
|||||||
this.components.addonManager.uninstallAddon(
|
this.components.addonManager.uninstallAddon(
|
||||||
addon,
|
addon,
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
Toast.makeText(
|
showAddonToast(
|
||||||
this,
|
addonsR.string.mozac_feature_addons_successfully_uninstalled,
|
||||||
getString(R.string.mozac_feature_addons_successfully_uninstalled, addon.translateName(this)),
|
addon,
|
||||||
Toast.LENGTH_SHORT,
|
)
|
||||||
).show()
|
|
||||||
finish()
|
finish()
|
||||||
},
|
},
|
||||||
onError = { _, _ ->
|
onError = { _, _ ->
|
||||||
Toast.makeText(
|
showAddonToast(
|
||||||
this,
|
addonsR.string.mozac_feature_addons_failed_to_uninstall,
|
||||||
getString(R.string.mozac_feature_addons_failed_to_uninstall, addon.translateName(this)),
|
addon,
|
||||||
Toast.LENGTH_SHORT,
|
)
|
||||||
).show()
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showAddonToast(@StringRes textId: Int, addon: Addon) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
getString(textId, addon.translateName(context = this)),
|
||||||
|
Toast.LENGTH_SHORT,
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
private fun SwitchCompat.setState(checked: Boolean) {
|
private fun SwitchCompat.setState(checked: Boolean) {
|
||||||
val text = if (checked) {
|
val text = if (checked) {
|
||||||
R.string.mozac_feature_addons_enabled
|
addonsR.string.mozac_feature_addons_enabled
|
||||||
} else {
|
} else {
|
||||||
R.string.mozac_feature_addons_disabled
|
addonsR.string.mozac_feature_addons_disabled
|
||||||
}
|
}
|
||||||
setText(text)
|
setText(text)
|
||||||
isChecked = checked
|
isChecked = checked
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package org.mozilla.samples.browser.integration
|
package org.mozilla.samples.browser.integration
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import mozilla.components.browser.state.selector.selectedTab
|
import mozilla.components.browser.state.selector.selectedTab
|
||||||
@@ -16,6 +17,8 @@ import mozilla.components.feature.readerview.view.ReaderViewControlsView
|
|||||||
import mozilla.components.support.base.feature.LifecycleAwareFeature
|
import mozilla.components.support.base.feature.LifecycleAwareFeature
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import org.mozilla.samples.browser.R
|
import org.mozilla.samples.browser.R
|
||||||
|
import mozilla.components.ui.colors.R as colorsR
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
@Suppress("UndocumentedPublicClass")
|
@Suppress("UndocumentedPublicClass")
|
||||||
class ReaderViewIntegration(
|
class ReaderViewIntegration(
|
||||||
@@ -30,9 +33,9 @@ class ReaderViewIntegration(
|
|||||||
private var readerViewButtonVisible = false
|
private var readerViewButtonVisible = false
|
||||||
|
|
||||||
private val readerViewButton: BrowserToolbar.ToggleButton = BrowserToolbar.ToggleButton(
|
private val readerViewButton: BrowserToolbar.ToggleButton = BrowserToolbar.ToggleButton(
|
||||||
image = ContextCompat.getDrawable(context, R.drawable.mozac_ic_reader_mode)!!,
|
image = getReaderDrawable(context),
|
||||||
imageSelected = ContextCompat.getDrawable(context, R.drawable.mozac_ic_reader_mode)!!.mutate().apply {
|
imageSelected = getReaderDrawable(context).mutate().apply {
|
||||||
setTint(ContextCompat.getColor(context, R.color.photonBlue40))
|
setTint(ContextCompat.getColor(context, colorsR.color.photonBlue40))
|
||||||
},
|
},
|
||||||
contentDescription = context.getString(R.string.mozac_reader_view_description),
|
contentDescription = context.getString(R.string.mozac_reader_view_description),
|
||||||
contentDescriptionSelected = context.getString(R.string.mozac_reader_view_description_selected),
|
contentDescriptionSelected = context.getString(R.string.mozac_reader_view_description_selected),
|
||||||
@@ -74,3 +77,8 @@ class ReaderViewIntegration(
|
|||||||
return feature.onBackPressed()
|
return feature.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getReaderDrawable(context: Context): Drawable {
|
||||||
|
val drawable = iconsR.drawable.mozac_ic_reader_mode
|
||||||
|
return ContextCompat.getDrawable(context, drawable)!!
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ import mozilla.components.support.ktx.android.view.hideKeyboard
|
|||||||
import mozilla.components.support.ktx.util.URLStringUtils
|
import mozilla.components.support.ktx.util.URLStringUtils
|
||||||
import mozilla.components.ui.tabcounter.TabCounter
|
import mozilla.components.ui.tabcounter.TabCounter
|
||||||
import org.mozilla.samples.toolbar.databinding.ActivityToolbarBinding
|
import org.mozilla.samples.toolbar.databinding.ActivityToolbarBinding
|
||||||
|
import mozilla.components.browser.menu.R as menuR
|
||||||
|
import mozilla.components.browser.toolbar.R as toolbarR
|
||||||
|
import mozilla.components.ui.colors.R as colorsR
|
||||||
|
import mozilla.components.ui.icons.R as iconsR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This sample application shows how to use and customize the browser-toolbar component.
|
* This sample application shows how to use and customize the browser-toolbar component.
|
||||||
@@ -100,7 +104,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
*/
|
*/
|
||||||
private fun setupDefaultToolbar(private: Boolean = false) {
|
private fun setupDefaultToolbar(private: Boolean = false) {
|
||||||
binding.toolbar.setBackgroundColor(
|
binding.toolbar.setBackgroundColor(
|
||||||
ContextCompat.getColor(this, mozilla.components.ui.colors.R.color.photonBlue80),
|
ContextCompat.getColor(this, colorsR.color.photonBlue80),
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.toolbar.private = private
|
binding.toolbar.private = private
|
||||||
@@ -124,7 +128,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
// //////////////////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
val back = BrowserToolbar.Button(
|
val back = BrowserToolbar.Button(
|
||||||
resources.getThemedDrawable(mozilla.components.ui.icons.R.drawable.mozac_ic_back)!!,
|
resources.getThemedDrawable(iconsR.drawable.mozac_ic_back)!!,
|
||||||
"Back",
|
"Back",
|
||||||
) {
|
) {
|
||||||
simulateReload()
|
simulateReload()
|
||||||
@@ -133,7 +137,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
binding.toolbar.addNavigationAction(back)
|
binding.toolbar.addNavigationAction(back)
|
||||||
|
|
||||||
val forward = BrowserToolbar.Button(
|
val forward = BrowserToolbar.Button(
|
||||||
resources.getThemedDrawable(mozilla.components.ui.icons.R.drawable.mozac_ic_forward)!!,
|
resources.getThemedDrawable(iconsR.drawable.mozac_ic_forward)!!,
|
||||||
"Forward",
|
"Forward",
|
||||||
) {
|
) {
|
||||||
simulateReload()
|
simulateReload()
|
||||||
@@ -146,9 +150,9 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
// //////////////////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
val reload = BrowserToolbar.TwoStateButton(
|
val reload = BrowserToolbar.TwoStateButton(
|
||||||
primaryImage = resources.getThemedDrawable(mozilla.components.ui.icons.R.drawable.mozac_ic_refresh)!!,
|
primaryImage = resources.getThemedDrawable(iconsR.drawable.mozac_ic_refresh)!!,
|
||||||
primaryContentDescription = "Reload",
|
primaryContentDescription = "Reload",
|
||||||
secondaryImage = resources.getThemedDrawable(mozilla.components.ui.icons.R.drawable.mozac_ic_stop)!!,
|
secondaryImage = resources.getThemedDrawable(iconsR.drawable.mozac_ic_stop)!!,
|
||||||
secondaryContentDescription = "Stop",
|
secondaryContentDescription = "Stop",
|
||||||
isInPrimaryState = { loading.value != true },
|
isInPrimaryState = { loading.value != true },
|
||||||
disableInSecondaryState = false,
|
disableInSecondaryState = false,
|
||||||
@@ -186,7 +190,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
*/
|
*/
|
||||||
private fun setupCustomMenu() {
|
private fun setupCustomMenu() {
|
||||||
binding.toolbar.setBackgroundColor(
|
binding.toolbar.setBackgroundColor(
|
||||||
ContextCompat.getColor(this, mozilla.components.ui.colors.R.color.photonBlue80),
|
ContextCompat.getColor(this, colorsR.color.photonBlue80),
|
||||||
)
|
)
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -195,12 +199,12 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val share = TextMenuCandidate(
|
val share = TextMenuCandidate(
|
||||||
"Share",
|
"Share",
|
||||||
start = DrawableMenuIcon(this, R.drawable.mozac_ic_share),
|
start = DrawableMenuIcon(this, iconsR.drawable.mozac_ic_share),
|
||||||
) { /* Do nothing */ }
|
) { /* Do nothing */ }
|
||||||
|
|
||||||
val search = TextMenuCandidate(
|
val search = TextMenuCandidate(
|
||||||
"Search",
|
"Search",
|
||||||
start = DrawableMenuIcon(this, R.drawable.mozac_ic_search),
|
start = DrawableMenuIcon(this, iconsR.drawable.mozac_ic_search),
|
||||||
) { /* Do nothing */ }
|
) { /* Do nothing */ }
|
||||||
|
|
||||||
binding.toolbar.display.menuController = BrowserMenuController(Side.START).apply {
|
binding.toolbar.display.menuController = BrowserMenuController(Side.START).apply {
|
||||||
@@ -230,7 +234,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
// //////////////////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
val forward = BrowserMenuItemToolbar.Button(
|
val forward = BrowserMenuItemToolbar.Button(
|
||||||
mozilla.components.ui.icons.R.drawable.mozac_ic_forward,
|
iconsR.drawable.mozac_ic_forward,
|
||||||
"Forward",
|
"Forward",
|
||||||
isEnabled = { canGoForward() },
|
isEnabled = { canGoForward() },
|
||||||
) {
|
) {
|
||||||
@@ -238,9 +242,9 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val reload = BrowserMenuItemToolbar.TwoStateButton(
|
val reload = BrowserMenuItemToolbar.TwoStateButton(
|
||||||
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_refresh,
|
primaryImageResource = iconsR.drawable.mozac_ic_refresh,
|
||||||
primaryContentDescription = "Reload",
|
primaryContentDescription = "Reload",
|
||||||
secondaryImageResource = R.drawable.mozac_ic_stop,
|
secondaryImageResource = iconsR.drawable.mozac_ic_stop,
|
||||||
secondaryContentDescription = "Stop",
|
secondaryContentDescription = "Stop",
|
||||||
isInPrimaryState = { loading.value != true },
|
isInPrimaryState = { loading.value != true },
|
||||||
disableInSecondaryState = false,
|
disableInSecondaryState = false,
|
||||||
@@ -344,10 +348,10 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
val homeScreen = TextMenuCandidate("Add to Home screen") { /* Do nothing */ }
|
val homeScreen = TextMenuCandidate("Add to Home screen") { /* Do nothing */ }
|
||||||
val open = TextMenuCandidate("Open in…") { /* Do nothing */ }
|
val open = TextMenuCandidate("Open in…") { /* Do nothing */ }
|
||||||
val settings = NestedMenuCandidate(
|
val settings = NestedMenuCandidate(
|
||||||
id = R.id.mozac_browser_toolbar_menu,
|
id = toolbarR.id.mozac_browser_toolbar_menu,
|
||||||
text = "Settings",
|
text = "Settings",
|
||||||
subMenuItems = listOf(
|
subMenuItems = listOf(
|
||||||
NestedMenuCandidate(id = R.id.container, text = "Back", subMenuItems = null),
|
NestedMenuCandidate(id = menuR.id.container, text = "Back", subMenuItems = null),
|
||||||
TextMenuCandidate("Setting 1") { /* Do nothing */ },
|
TextMenuCandidate("Setting 1") { /* Do nothing */ },
|
||||||
TextMenuCandidate("Setting 2") { /* Do nothing */ },
|
TextMenuCandidate("Setting 2") { /* Do nothing */ },
|
||||||
),
|
),
|
||||||
@@ -376,7 +380,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
ContextCompat.getDrawable(this, R.drawable.fenix_url_background),
|
ContextCompat.getDrawable(this, R.drawable.fenix_url_background),
|
||||||
)
|
)
|
||||||
binding.toolbar.edit.setIcon(
|
binding.toolbar.edit.setIcon(
|
||||||
ContextCompat.getDrawable(this, R.drawable.mozac_ic_search)!!,
|
ContextCompat.getDrawable(this, iconsR.drawable.mozac_ic_search)!!,
|
||||||
"Search",
|
"Search",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -424,7 +428,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
binding.toolbar.url = "https://www.mozilla.org/en-US/firefox/mobile/"
|
binding.toolbar.url = "https://www.mozilla.org/en-US/firefox/mobile/"
|
||||||
|
|
||||||
val drawableIcon = ContextCompat.getDrawable(this, R.drawable.mozac_ic_close)
|
val drawableIcon = ContextCompat.getDrawable(this, iconsR.drawable.mozac_ic_close)
|
||||||
|
|
||||||
drawableIcon?.apply {
|
drawableIcon?.apply {
|
||||||
setTint(0xFF20123a.toInt())
|
setTint(0xFF20123a.toInt())
|
||||||
@@ -438,7 +442,7 @@ class ToolbarActivity : AppCompatActivity() {
|
|||||||
binding.toolbar.addNavigationAction(button)
|
binding.toolbar.addNavigationAction(button)
|
||||||
}
|
}
|
||||||
|
|
||||||
val drawable = ContextCompat.getDrawable(this, R.drawable.mozac_ic_share)?.apply {
|
val drawable = ContextCompat.getDrawable(this, iconsR.drawable.mozac_ic_share)?.apply {
|
||||||
setTint(0xFF20123a.toInt())
|
setTint(0xFF20123a.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user