Skip to content

Commit

Permalink
Update to AGP 7 (#1900)
Browse files Browse the repository at this point in the history
Co-authored-by: Craig Russell <CDRussell@users.noreply.github.com>
  • Loading branch information
joshliebe and CDRussell authored May 2, 2022
1 parent 4d5defb commit 169e927
Show file tree
Hide file tree
Showing 37 changed files with 119 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.duckduckgo.app.bookmarks.model.SavedSite
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ViewSavedSiteEmptyHintBinding
import com.duckduckgo.app.browser.databinding.ViewSavedSiteEntryBinding
import com.duckduckgo.app.browser.favicon.FaviconManager
Expand Down Expand Up @@ -150,7 +151,7 @@ sealed class BookmarkScreenViewHolders(itemView: View) : RecyclerView.ViewHolder

private fun loadFavicon(url: String) {
lifecycleOwner.lifecycleScope.launch {
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(R.id.image))
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(CommonR.id.image))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.duckduckgo.app.bookmarks.model.SavedSite.Favorite
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ViewSavedSiteEmptyHintBinding
import com.duckduckgo.app.browser.databinding.ViewSavedSiteEntryBinding
import com.duckduckgo.app.browser.databinding.ViewSavedSiteSectionTitleBinding
Expand Down Expand Up @@ -172,7 +173,7 @@ sealed class FavoritesScreenViewHolders(itemView: View) : RecyclerView.ViewHolde

private fun loadFavicon(url: String) {
lifecycleOwner.lifecycleScope.launch {
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(R.id.image))
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(CommonR.id.image))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.duckduckgo.app.bookmarks.ui.bookmarkfolders.BookmarkFoldersActivity.C
import com.duckduckgo.app.bookmarks.ui.bookmarkfolders.BookmarkFoldersActivity.Companion.KEY_CURRENT_FOLDER
import com.duckduckgo.app.bookmarks.ui.bookmarkfolders.EditBookmarkFolderDialogFragment
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.DialogFragmentSavedSiteBinding
import com.duckduckgo.app.global.view.TextChangedWatcher
import com.duckduckgo.mobile.android.ui.view.showKeyboard
Expand Down Expand Up @@ -138,7 +139,7 @@ abstract class SavedSiteDialogFragment : DialogFragment() {
}

private fun configureUpNavigation(toolbar: Toolbar) {
toolbar.setNavigationIcon(R.drawable.ic_back_24)
toolbar.setNavigationIcon(CommonR.drawable.ic_back_24)
toolbar.setNavigationOnClickListener {
dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.duckduckgo.app.bookmarks.model.BookmarkFolderItem
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ItemBookmarkFolderBinding
import com.duckduckgo.mobile.android.ui.view.toPx

Expand Down Expand Up @@ -76,7 +77,7 @@ class FolderViewHolder(
binding.iconContainer.setBackgroundResource(R.drawable.selected_icon_background)
} else {
binding.icon.setImageResource(R.drawable.ic_folder)
binding.iconContainer.setBackgroundResource(R.drawable.list_item_image_background)
binding.iconContainer.setBackgroundResource(CommonR.drawable.list_item_image_background)
}

itemView.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.duckduckgo.app.cta.ui.DaxDialogCta
import com.duckduckgo.mobile.android.ui.view.toPx
import com.duckduckgo.app.privacy.renderer.TrackersRenderer
import com.duckduckgo.app.trackerdetection.model.Entity
import com.duckduckgo.mobile.android.R as CommonR

interface TrackersAnimatorListener {
fun onAnimationFinished()
Expand Down Expand Up @@ -197,7 +198,7 @@ class BrowserTrackersAnimatorHelper {
private fun createTextView(context: Context): AppCompatTextView {
val textView = AppCompatTextView(context)
textView.gravity = Gravity.CENTER
TextViewCompat.setTextAppearance(textView, R.style.UnknownTrackerText)
TextViewCompat.setTextAppearance(textView, CommonR.style.UnknownTrackerText)
textView.layoutParams = getParams()

return textView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ViewFireproofTitleBinding
import com.duckduckgo.app.browser.databinding.ViewFireproofWebsiteDescriptionBinding
import com.duckduckgo.app.browser.databinding.ViewFireproofWebsiteEmptyHintBinding
Expand Down Expand Up @@ -233,7 +234,7 @@ sealed class FireproofWebSiteViewHolder(itemView: View) : RecyclerView.ViewHolde

private fun loadFavicon(url: String) {
lifecycleOwner.lifecycleScope.launch {
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(R.id.image))
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(CommonR.id.image))
}
}

Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/duckduckgo/app/global/view/DaxDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import android.view.ViewGroup
import androidx.core.content.ContextCompat.getColor
import androidx.fragment.app.DialogFragment
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ContentDaxDialogBinding
import com.duckduckgo.mobile.android.ui.viewbinding.viewBinding

Expand Down Expand Up @@ -102,7 +103,7 @@ class TypewriterDaxDialog : DialogFragment(R.layout.content_dax_dialog), DaxDial
}

override fun getTheme(): Int {
return R.style.DaxDialogFragment
return CommonR.style.DaxDialogFragment
}

override fun onStart() {
Expand Down Expand Up @@ -184,7 +185,7 @@ class TypewriterDaxDialog : DialogFragment(R.layout.content_dax_dialog), DaxDial
}

context?.let {
val toolbarColor = if (toolbarDimmed) getColor(it, R.color.dimmed) else getColor(it, android.R.color.transparent)
val toolbarColor = if (toolbarDimmed) getColor(it, CommonR.color.dimmed) else getColor(it, android.R.color.transparent)
with(binding) {
toolbarDialogLayout.setBackgroundColor(toolbarColor)
hiddenText.text = daxText.html(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import androidx.core.net.toUri
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.global.baseHost
import okio.ByteString.Companion.encodeUtf8
import java.io.File
Expand Down Expand Up @@ -77,8 +77,8 @@ fun generateDefaultDrawable(
private val letter
get() = baseHost.firstOrNull()?.toString()?.toUpperCase(Locale.getDefault()) ?: ""

private val faviconDefaultCornerRadius = context.resources.getDimension(R.dimen.savedSiteGridItemCornerRadiusFavicon)
private val faviconDefaultSize = context.resources.getDimension(R.dimen.savedSiteGridItemFavicon)
private val faviconDefaultCornerRadius = context.resources.getDimension(CommonR.dimen.savedSiteGridItemCornerRadiusFavicon)
private val faviconDefaultSize = context.resources.getDimension(CommonR.dimen.savedSiteGridItemFavicon)

private val palette = listOf(
"#94B3AF",
Expand All @@ -104,7 +104,7 @@ fun generateDefaultDrawable(
}

private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = getColor(context, R.color.white)
color = getColor(context, CommonR.color.white)
typeface = Typeface.SANS_SERIF
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.core.view.doOnDetach
import androidx.core.view.isVisible
import com.airbnb.lottie.RenderMode
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.IncludeDaxDialogCtaBinding
import com.duckduckgo.app.browser.databinding.SheetFireClearDataBinding
import com.duckduckgo.app.cta.ui.CtaViewModel
Expand Down Expand Up @@ -164,7 +165,7 @@ class FireDialog(
}

private fun playAnimation() {
window?.navigationBarColor = ContextCompat.getColor(context, R.color.black)
window?.navigationBarColor = ContextCompat.getColor(context, CommonR.color.black)
setCancelable(false)
setCanceledOnTouchOutside(false)
binding.fireAnimationView.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ActivityAppIconsBinding
import com.duckduckgo.app.global.DuckDuckGoActivity
import com.duckduckgo.di.scopes.ActivityScope
Expand Down Expand Up @@ -52,7 +53,7 @@ class ChangeIconActivity : DuckDuckGoActivity() {

private fun configureRecycler() {
binding.appIconsList.layoutManager = GridLayoutManager(this, 4)
binding.appIconsList.addItemDecoration(ItemOffsetDecoration(this, R.dimen.changeAppIconListPadding))
binding.appIconsList.addItemDecoration(ItemOffsetDecoration(this, CommonR.dimen.changeAppIconListPadding))
binding.appIconsList.adapter = iconsAdapter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.browser.databinding.ViewLocationPermissionsDescriptionBinding
import com.duckduckgo.app.browser.databinding.ViewLocationPermissionsDividerBinding
import com.duckduckgo.app.browser.databinding.ViewLocationPermissionsEmptyHintBinding
Expand Down Expand Up @@ -272,7 +273,7 @@ sealed class LocationPermissionsViewHolder(itemView: View) : RecyclerView.ViewHo

private fun loadFavicon(url: String) {
lifecycleOwner.lifecycleScope.launch {
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(R.id.image))
faviconManager.loadToViewFromLocalOrFallback(url = url, view = itemView.findViewById(CommonR.id.image))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.vpn.R as VpnR
import com.duckduckgo.app.di.AppCoroutineScope
import com.duckduckgo.app.global.plugins.PluginPoint
import com.duckduckgo.app.notification.model.Channel
Expand Down Expand Up @@ -78,7 +79,7 @@ class NotificationRegistrar @Inject constructor(
)
val APP_TP_WAITLIST = Channel(
"com.duckduckgo.apptp",
R.string.atp_WaitlistActivityWaitlistTitle,
VpnR.string.atp_WaitlistActivityWaitlistTitle,
NotificationManagerCompat.IMPORTANCE_HIGH
)
// Do not add new channels here, instead follow https://app.asana.com/0/1125189844152671/1201842645469204
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.duckduckgo.app.notification.model
import android.content.Context
import android.os.Bundle
import androidx.annotation.StringRes
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.APP_LAUNCH
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CANCEL
import com.duckduckgo.app.notification.NotificationRegistrar
Expand Down Expand Up @@ -57,11 +57,11 @@ class AppFeatureNotificationSpecification(
override val channel = NotificationRegistrar.ChannelType.TUTORIALS
override val systemId = NotificationRegistrar.NotificationId.AppFeature
override val name = "AppFeature"
override val icon = R.drawable.notification_logo
override val icon = CommonR.drawable.notification_logo
override val launchButton: String? = null
override val closeButton: String? = null
override val autoCancel = true
override val title: String = context.getString(titleRes)
override val description: String = context.getString(descriptionRes)
override val color: Int = R.color.ic_launcher_red_background
override val color: Int = CommonR.color.ic_launcher_red_background
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package com.duckduckgo.app.notification.model

import android.content.Context
import android.os.Bundle
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.vpn.R as VpnR
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CANCEL
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.APPTP_WAITLIST_CODE
import com.duckduckgo.app.notification.NotificationRegistrar
Expand Down Expand Up @@ -54,14 +55,14 @@ class AppTPWaitlistCodeNotification(
class AppTPWaitlistCodeSpecification(context: Context) : NotificationSpec {
override val channel = NotificationRegistrar.ChannelType.APP_TP_WAITLIST
override val systemId = NotificationRegistrar.NotificationId.EmailWaitlist
override val name = context.getString(R.string.atp_WaitlistNotificationTitle)
override val icon = R.drawable.notification_logo
override val title: String = context.getString(R.string.atp_WaitlistNotificationTitle)
override val description: String = context.getString(R.string.atp_WaitlistNotificationDescription)
override val name = context.getString(VpnR.string.atp_WaitlistNotificationTitle)
override val icon = CommonR.drawable.notification_logo
override val title: String = context.getString(VpnR.string.atp_WaitlistNotificationTitle)
override val description: String = context.getString(VpnR.string.atp_WaitlistNotificationDescription)
override val launchButton: String? = null
override val closeButton: String? = null
override val pixelSuffix = "atpc"
override val autoCancel = true
override val bundle: Bundle = Bundle()
override val color: Int = R.color.ic_launcher_red_background
override val color: Int = CommonR.color.ic_launcher_red_background
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.notification.model
import android.content.Context
import android.os.Bundle
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CANCEL
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CLEAR_DATA_LAUNCH
import com.duckduckgo.app.notification.NotificationRegistrar
Expand Down Expand Up @@ -69,5 +70,5 @@ class ClearDataSpecification(context: Context) : NotificationSpec {
override val pixelSuffix = "cd"
override val autoCancel = true
override val bundle: Bundle = Bundle()
override val color: Int = R.color.cornflowerBlue
override val color: Int = CommonR.color.cornflowerBlue
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.notification.model
import android.content.Context
import android.os.Bundle
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.email.db.EmailDataStore
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CANCEL
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.EMAIL_WAITLIST_CODE
Expand Down Expand Up @@ -58,13 +59,13 @@ class EmailWaitlistCodeSpecification(
override val channel = NotificationRegistrar.ChannelType.EMAIL_WAITLIST
override val systemId = NotificationRegistrar.NotificationId.EmailWaitlist
override val name = context.getString(R.string.waitlistNotificationTitle)
override val icon = R.drawable.notification_logo
override val icon = CommonR.drawable.notification_logo
override val title: String = context.getString(R.string.waitlistNotificationTitle)
override val description: String = context.getString(R.string.waitlistNotificationDescription)
override val launchButton: String? = null
override val closeButton: String? = null
override val pixelSuffix = "ec"
override val autoCancel = true
override val bundle: Bundle = Bundle()
override val color: Int = R.color.ic_launcher_red_background
override val color: Int = CommonR.color.ic_launcher_red_background
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.notification.model
import android.content.Context
import android.os.Bundle
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.APP_LAUNCH
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CANCEL
import com.duckduckgo.app.notification.NotificationRegistrar
Expand Down Expand Up @@ -62,7 +63,7 @@ class PrivacyProtectionNotificationSpecification(
override val closeButton: String? = null
override val autoCancel = true
override val bundle: Bundle = Bundle()
override val color: Int = R.color.cornflowerBlue
override val color: Int = CommonR.color.cornflowerBlue

override val title: String = when {
trackers < TRACKER_THRESHOLD && upgrades < UPGRADE_THRESHOLD -> context.getString(R.string.privacyProtectionNotificationDefaultTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.duckduckgo.app.notification.model
import android.content.Context
import android.os.Bundle
import androidx.annotation.StringRes
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.WEBSITE
import com.duckduckgo.app.notification.NotificationHandlerService.NotificationEvent.CANCEL
import com.duckduckgo.app.notification.NotificationRegistrar
Expand Down Expand Up @@ -61,13 +61,13 @@ open class WebsiteNotificationSpecification(
override val channel = NotificationRegistrar.ChannelType.TUTORIALS
override val systemId = NotificationRegistrar.NotificationId.Article
override val name = "Website"
override val icon = R.drawable.notification_logo
override val icon = CommonR.drawable.notification_logo
override val launchButton: String? = null
override val closeButton: String? = null
override val autoCancel = true
override val title: String = context.getString(titleRes)
override val description: String = context.getString(descriptionRes)
override val color: Int = R.color.ic_launcher_red_background
override val color: Int = CommonR.color.ic_launcher_red_background

companion object {
const val WEBSITE_KEY = "websiteKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.app.browser.R
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.app.global.view.html
import com.duckduckgo.di.scopes.FragmentScope
import dagger.android.support.AndroidSupportInjection
Expand Down Expand Up @@ -152,8 +153,8 @@ class WelcomePage : OnboardingPageFragment() {
ctaText = it.getString(R.string.onboardingDaxText)
hiddenTextCta.text = ctaText.html(it)
dialogTextCta.textInDialog = ctaText.html(it)
dialogTextCta.setTextColor(ContextCompat.getColor(it, R.color.grayishBrown))
cardView.backgroundTintList = ContextCompat.getColorStateList(it, R.color.white)
dialogTextCta.setTextColor(ContextCompat.getColor(it, CommonR.color.grayishBrown))
cardView.backgroundTintList = ContextCompat.getColorStateList(it, CommonR.color.white)
}
triangle.setImageResource(R.drawable.ic_triangle_bubble_white)
}
Expand Down
Loading

0 comments on commit 169e927

Please sign in to comment.