Skip to content

Commit

Permalink
Use non-transitive R classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kidinov committed Mar 7, 2023
1 parent 4d6b7b9 commit 4057a88
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class UserEligibilityErrorFragment : BaseFragment(layout.fragment_user_eligibili
requireActivity().addMenuProvider(
object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.menu_login, menu)
menuInflater.inflate(org.wordpress.android.login.R.menu.menu_login, menu)
}

override fun onMenuItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.help) {
if (item.itemId == org.wordpress.android.login.R.id.help) {
startActivity(
HelpActivity.createIntent(
requireActivity(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ fun WCPasswordField(
keyboardActions = keyboardActions,
trailingIcon = {
val image = if (isPasswordVisible) {
painterResource(id = R.drawable.ic_password_visibility)
painterResource(id = org.wordpress.android.login.R.drawable.ic_password_visibility)
} else {
painterResource(id = R.drawable.ic_password_visibility_off)
painterResource(id = org.wordpress.android.login.R.drawable.ic_password_visibility_off)
}

val description = if (isPasswordVisible) stringResource(id = R.string.hide_password_content_description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class LoginDiscoveryErrorFragment : Fragment(layout.fragment_login_discovery_err
}

override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.menu_login, menu)
menuInflater.inflate(org.wordpress.android.login.R.menu.menu_login, menu)
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
if (menuItem.itemId == R.id.help) {
if (menuItem.itemId == org.wordpress.android.login.R.id.help) {
AnalyticsTracker.track(AnalyticsEvent.LOGIN_DISCOVERY_ERROR_MENU_HELP_TAPPED)
loginListener?.helpSiteAddress(siteAddress)
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ class LoginMagicLinkSentImprovedFragment : Fragment(R.layout.fragment_login_magi

override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menu.clear()
menuInflater.inflate(R.menu.menu_login, menu)
menuInflater.inflate(org.wordpress.android.login.R.menu.menu_login, menu)
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
return when (menuItem.itemId) {
R.id.help -> {
org.wordpress.android.login.R.id.help -> {
mAnalyticsListener.trackShowHelpClick()
mLoginListener?.helpMagicLinkSent(mEmail)
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MagicLinkInterceptFragment : Fragment() {
): View? {
setHasOptionsMenu(true)

return inflater.inflate(R.layout.login_magic_link_sent_screen, container, false)
return inflater.inflate(org.wordpress.android.login.R.layout.login_magic_link_sent_screen, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class AccountMismatchErrorViewModel @Inject constructor(
step.value = Step.SiteCredentials()
return@launch
}
_loadingDialogMessage.value = R.string.loading
_loadingDialogMessage.value = org.wordpress.android.mediapicker.R.string.loading
accountMismatchRepository.fetchJetpackConnectionUrl(site).fold(
onSuccess = {
_loadingDialogMessage.value = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private fun MagicLinkSentContent(
.fillMaxWidth()
.weight(1f)
) {
Image(painter = painterResource(id = R.drawable.img_envelope), contentDescription = null)
Image(painter = painterResource(id = org.wordpress.android.login.R.drawable.img_envelope), contentDescription = null)
Spacer(modifier = Modifier.height(dimensionResource(id = R.dimen.major_100)))
Text(
text = stringResource(id = R.string.login_magic_links_sent_label_short),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SignUpViewModel @Inject constructor(
AnalyticsTracker.track(stat = AnalyticsEvent.SIGNUP_SUBMITTED)

if (!networkStatus.isConnected()) {
triggerEvent(ShowSnackbar(R.string.no_network_message))
triggerEvent(ShowSnackbar(org.wordpress.android.mediapicker.source.wordpress.R.string.no_network_message))
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private fun DomainSearchForm(
.border(
BorderStroke(
width = dimensionResource(id = R.dimen.minor_10),
color = colorResource(id = R.color.gray_5)
color = colorResource(id = org.wordpress.android.mediapicker.api.R.color.gray_5)
),
RoundedCornerShape(dimensionResource(id = R.dimen.minor_100))
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.viewinterop.AndroidView
import com.woocommerce.android.R.color
import com.woocommerce.android.R.dimen
import com.woocommerce.android.R.string
import com.woocommerce.android.R
import com.woocommerce.android.ui.compose.component.ProgressIndicator
import com.woocommerce.android.ui.compose.component.WCColoredButton
import com.woocommerce.android.ui.compose.component.WCOutlinedButton
Expand Down Expand Up @@ -63,7 +61,7 @@ fun InstallationScreen(viewModel: InstallationViewModel) {
viewModel::onRetryButtonClicked
)
is InitialState, LoadingState -> {
ProgressIndicator(stringResource(id = string.store_creation_in_progress))
ProgressIndicator(stringResource(id = R.string.store_creation_in_progress))
}
}
}
Expand All @@ -83,24 +81,24 @@ private fun InstallationSummary(
.fillMaxSize()
) {
Text(
text = stringResource(id = string.store_creation_installation_success),
color = colorResource(id = color.color_on_surface),
text = stringResource(id = R.string.store_creation_installation_success),
color = colorResource(id = R.color.color_on_surface),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.h5,
modifier = Modifier
.padding(
top = dimensionResource(id = dimen.major_350)
top = dimensionResource(id = R.dimen.major_350)
)
)

Box(
modifier = Modifier
.weight(1f)
.background(color = colorResource(id = color.color_surface))
.clip(RoundedCornerShape(dimensionResource(id = dimen.minor_100)))
.background(color = colorResource(id = R.color.color_surface))
.clip(RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)))
.padding(
horizontal = dimensionResource(id = dimen.major_350),
vertical = dimensionResource(id = dimen.major_200)
horizontal = dimensionResource(id = R.dimen.major_350),
vertical = dimensionResource(id = R.dimen.major_200)
)
) {
PreviewWebView(
Expand All @@ -109,42 +107,42 @@ private fun InstallationSummary(
.fillMaxSize()
.align(Alignment.Center)
.drawShadow(
color = colorResource(id = color.color_on_surface),
backgroundColor = colorResource(id = color.color_surface),
borderRadius = dimensionResource(id = dimen.major_100)
color = colorResource(id = R.color.color_on_surface),
backgroundColor = colorResource(id = R.color.color_surface),
borderRadius = dimensionResource(id = R.dimen.major_100)
)
)
}

Divider(
color = colorResource(id = color.divider_color),
thickness = dimensionResource(id = dimen.minor_10),
modifier = Modifier.padding(bottom = dimensionResource(id = dimen.major_100))
color = colorResource(id = R.color.divider_color),
thickness = dimensionResource(id = R.dimen.minor_10),
modifier = Modifier.padding(bottom = dimensionResource(id = R.dimen.major_100))
)

WCColoredButton(
modifier = Modifier
.padding(horizontal = dimensionResource(id = dimen.major_100))
.padding(horizontal = dimensionResource(id = R.dimen.major_100))
.fillMaxWidth(),
onClick = onManageStoreButtonClicked
) {
Text(
text = stringResource(id = string.store_creation_installation_manage_store_button)
text = stringResource(id = R.string.store_creation_installation_manage_store_button)
)
}

WCOutlinedButton(
modifier = Modifier
.padding(
start = dimensionResource(id = dimen.major_100),
end = dimensionResource(id = dimen.major_100),
bottom = dimensionResource(id = dimen.major_100)
start = dimensionResource(id = R.dimen.major_100),
end = dimensionResource(id = R.dimen.major_100),
bottom = dimensionResource(id = R.dimen.major_100)
)
.fillMaxWidth(),
onClick = onShowPreviewButtonClicked
) {
Text(
text = stringResource(id = string.store_creation_installation_show_preview_button)
text = stringResource(id = R.string.store_creation_installation_show_preview_button)
)
}
}
Expand All @@ -155,13 +153,13 @@ private fun InstallationSummary(
private fun PreviewWebView(url: String, modifier: Modifier = Modifier) {
Box(
modifier = modifier
.padding(dimensionResource(id = dimen.minor_100))
.padding(dimensionResource(id = R.dimen.minor_100))
.fillMaxSize()
.clip(RoundedCornerShape(dimensionResource(id = dimen.minor_100)))
.clip(RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)))
.border(
dimensionResource(id = dimen.minor_10),
colorResource(id = color.gray_0),
shape = RoundedCornerShape(dimensionResource(id = dimen.minor_100)),
dimensionResource(id = R.dimen.minor_10),
colorResource(id = R.color.woo_gray_0),
shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)),
)
) {
var progress by remember { mutableStateOf(0) }
Expand Down Expand Up @@ -201,7 +199,7 @@ private fun PreviewWebView(url: String, modifier: Modifier = Modifier) {
},
modifier = Modifier
.alpha(if (progress == 100) 1f else 0f)
.clip(RoundedCornerShape(dimensionResource(id = dimen.minor_75)))
.clip(RoundedCornerShape(dimensionResource(id = R.dimen.minor_75)))
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private fun PlanInformation(
Icon(
Icons.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.back),
tint = colorResource(id = R.color.white)
tint = colorResource(id = org.wordpress.aztec.R.color.white)
)
}

Expand All @@ -157,7 +157,7 @@ private fun PlanInformation(
Text(
text = planState.plan.name,
fontWeight = FontWeight.Bold,
color = colorResource(id = R.color.white),
color = colorResource(id = org.wordpress.aztec.R.color.white),
fontSize = 20.sp,
modifier = Modifier
.constrainAs(title) {
Expand All @@ -169,7 +169,7 @@ private fun PlanInformation(
)
Text(
text = planState.plan.formattedPrice,
color = colorResource(id = R.color.white),
color = colorResource(id = org.wordpress.aztec.R.color.white),
fontSize = 40.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier
Expand Down Expand Up @@ -209,7 +209,7 @@ private fun PlanInformation(
Text(
fontWeight = FontWeight.Bold,
text = stringResource(id = R.string.store_creation_ecommerce_plan_features_tagline),
color = colorResource(id = R.color.white),
color = colorResource(id = org.wordpress.aztec.R.color.white),
fontSize = 28.sp,
lineHeight = 36.sp
)
Expand Down Expand Up @@ -309,7 +309,7 @@ fun PlanFeatureRow(@DrawableRes iconId: Int, @StringRes textId: Int) {
)
Text(
text = stringResource(id = textId),
color = colorResource(id = R.color.white),
color = colorResource(id = org.wordpress.aztec.R.color.white),
style = MaterialTheme.typography.body2
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private fun SearchBar(
.border(
BorderStroke(
width = dimensionResource(id = R.dimen.minor_10),
color = colorResource(id = R.color.gray_5)
color = colorResource(id = org.wordpress.android.mediapicker.api.R.color.gray_5)
),
RoundedCornerShape(dimensionResource(id = R.dimen.minor_100))
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.woocommerce.android.R
import com.woocommerce.android.R.color
import com.woocommerce.android.R.drawable
import com.woocommerce.android.R.string
import com.woocommerce.android.ui.moremenu.MoreMenuViewModel.MoreMenuViewState

@ExperimentalFoundationApi
Expand Down Expand Up @@ -133,7 +130,7 @@ private fun MoreMenuHeader(
.fillMaxWidth()
.clickable(
enabled = state.isStoreSwitcherEnabled,
onClickLabel = stringResource(id = string.settings_switch_store),
onClickLabel = stringResource(id = R.string.settings_switch_store),
role = Role.Button,
onClick = onSwitchStore
)
Expand Down Expand Up @@ -170,8 +167,8 @@ private fun SettingsButton(modifier: Modifier, onSettingsClick: () -> Unit) {
onClick = { onSettingsClick() },
) {
Icon(
painter = painterResource(id = drawable.ic_more_screen_settings),
contentDescription = stringResource(id = string.settings),
painter = painterResource(id = R.drawable.ic_more_screen_settings),
contentDescription = stringResource(id = R.string.settings),
tint = Color.Unspecified
)
}
Expand Down Expand Up @@ -201,7 +198,7 @@ private fun StoreDetailsHeader(
)
if (isStoreSwitcherEnabled) {
Text(
text = stringResource(string.settings_switch_store),
text = stringResource(R.string.settings_switch_store),
color = MaterialTheme.colors.secondary,
style = MaterialTheme.typography.body2,
)
Expand Down Expand Up @@ -242,12 +239,12 @@ private fun MoreMenuUserAvatar(avatarUrl: String) {
bitmapState.value?.let {
Image(
bitmap = it.asImageBitmap(),
contentDescription = stringResource(id = string.more_menu_avatar),
contentDescription = stringResource(id = R.string.more_menu_avatar),
modifier = circledModifier
)
} ?: Image(
painter = painterResource(id = drawable.img_gravatar_placeholder),
contentDescription = stringResource(id = string.more_menu_avatar),
painter = painterResource(id = R.drawable.img_gravatar_placeholder),
contentDescription = stringResource(id = R.string.more_menu_avatar),
modifier = circledModifier
)
}
Expand All @@ -263,7 +260,7 @@ private fun MoreMenuButton(
onClick = onClick,
contentPadding = PaddingValues(dimensionResource(id = R.dimen.major_75)),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(id = color.more_menu_button_background)
backgroundColor = colorResource(id = R.color.more_menu_button_background)
),
modifier = Modifier.height(dimensionResource(id = R.dimen.more_menu_button_height)),
shape = RoundedCornerShape(dimensionResource(id = R.dimen.major_75))
Expand All @@ -280,7 +277,7 @@ private fun MoreMenuButton(
modifier = Modifier
.size(dimensionResource(id = R.dimen.major_350))
.clip(CircleShape)
.background(colorResource(id = color.more_menu_button_icon_background))
.background(colorResource(id = R.color.more_menu_button_icon_background))
) {
Image(
painter = painterResource(id = iconDrawable),
Expand Down Expand Up @@ -350,28 +347,28 @@ private fun MoreMenuPreview() {
val state = MoreMenuViewState(
moreMenuItems = listOf(
MenuUiButton(
string.more_menu_button_payments, drawable.ic_more_menu_payments,
R.string.more_menu_button_payments, R.drawable.ic_more_menu_payments,
BadgeState(
badgeSize = R.dimen.major_110,
backgroundColor = color.color_secondary,
textColor = color.color_on_surface_inverted,
backgroundColor = R.color.color_secondary,
textColor = org.wordpress.android.mediapicker.R.color.color_on_surface_inverted,
textState = TextState("", R.dimen.text_minor_80),
animateAppearance = true
)
),
MenuUiButton(string.more_menu_button_wс_admin, drawable.ic_more_menu_wp_admin),
MenuUiButton(string.more_menu_button_store, drawable.ic_more_menu_store),
MenuUiButton(R.string.more_menu_button_wс_admin, R.drawable.ic_more_menu_wp_admin),
MenuUiButton(R.string.more_menu_button_store, R.drawable.ic_more_menu_store),
MenuUiButton(
string.more_menu_button_reviews, drawable.ic_more_menu_reviews,
R.string.more_menu_button_reviews, R.drawable.ic_more_menu_reviews,
BadgeState(
badgeSize = R.dimen.major_150,
backgroundColor = color.color_primary,
textColor = color.color_on_surface_inverted,
backgroundColor = R.color.color_primary,
textColor = org.wordpress.android.mediapicker.R.color.color_on_surface_inverted,
textState = TextState("3", R.dimen.text_minor_80),
animateAppearance = false
)
),
MenuUiButton(string.more_menu_button_coupons, drawable.ic_more_menu_coupons),
MenuUiButton(R.string.more_menu_button_coupons, R.drawable.ic_more_menu_coupons),
),
siteName = "Example Site",
siteUrl = "woocommerce.com",
Expand Down
Loading

0 comments on commit 4057a88

Please sign in to comment.