Compare commits
1 Commits
main
...
cn-master-
Author | SHA1 | Date |
---|---|---|
rxu | ba40e21185 |
|
@ -377,6 +377,7 @@ class DefaultSessionControlController(
|
|||
metrics.track(Event.CollectionRenamePressed)
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
override fun handleSelectTopSite(url: String, type: TopSite.Type) {
|
||||
dismissSearchDialogIfDisplayed()
|
||||
|
||||
|
@ -409,8 +410,18 @@ class DefaultSessionControlController(
|
|||
}
|
||||
event?.let { activity.metrics.track(it) }
|
||||
|
||||
var specialUrl = url
|
||||
if (SupportUtils.isShoppingFesForJD && url == SupportUtils.JD_URL &&
|
||||
SupportUtils.shoppingFesJD.url.isNotEmpty()) {
|
||||
specialUrl = SupportUtils.shoppingFesJD.url
|
||||
}
|
||||
if (SupportUtils.isShoppingFesForPDD && url == SupportUtils.PDD_URL &&
|
||||
SupportUtils.shoppingFesPDD.url.isNotEmpty()) {
|
||||
specialUrl = SupportUtils.shoppingFesPDD.url
|
||||
}
|
||||
|
||||
val tabId = addTabUseCase.invoke(
|
||||
url = appendSearchAttributionToUrlIfNeeded(url),
|
||||
url = appendSearchAttributionToUrlIfNeeded(specialUrl),
|
||||
selectTab = true,
|
||||
startLoading = true
|
||||
)
|
||||
|
|
|
@ -79,10 +79,38 @@ class TopSiteItemViewHolder(
|
|||
favicon_image.setImageDrawable(getDrawable(itemView.context, R.drawable.ic_baidu))
|
||||
}
|
||||
SupportUtils.JD_URL -> {
|
||||
favicon_image.setImageDrawable(getDrawable(itemView.context, R.drawable.ic_jd))
|
||||
if (SupportUtils.isShoppingFesForJD) {
|
||||
favicon_image.setImageDrawable(
|
||||
getDrawable(
|
||||
itemView.context,
|
||||
SupportUtils.shoppingFesJD.icon
|
||||
)
|
||||
)
|
||||
} else {
|
||||
favicon_image.setImageDrawable(
|
||||
getDrawable(
|
||||
itemView.context,
|
||||
R.drawable.ic_jd
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
SupportUtils.PDD_URL -> {
|
||||
favicon_image.setImageDrawable(getDrawable(itemView.context, R.drawable.ic_pdd))
|
||||
if (SupportUtils.isShoppingFesForPDD) {
|
||||
favicon_image.setImageDrawable(
|
||||
getDrawable(
|
||||
itemView.context,
|
||||
SupportUtils.shoppingFesPDD.icon
|
||||
)
|
||||
)
|
||||
} else {
|
||||
favicon_image.setImageDrawable(
|
||||
getDrawable(
|
||||
itemView.context,
|
||||
R.drawable.ic_pdd
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
itemView.context.components.core.icons.loadIntoView(favicon_image, topSite.url)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.mozilla.fenix.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.browser.customtabs.CustomTabColorSchemeParams
|
||||
|
@ -18,6 +19,8 @@ import org.mozilla.fenix.settings.account.AuthIntentReceiverActivity
|
|||
import java.io.UnsupportedEncodingException
|
||||
import java.net.URLEncoder
|
||||
import java.util.Locale
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
object SupportUtils {
|
||||
const val RATE_APP_URL = "market://details?id=" + BuildConfig.APPLICATION_ID
|
||||
|
@ -37,6 +40,33 @@ object SupportUtils {
|
|||
const val GOOGLE_US_URL = "https://www.google.com/webhp?client=firefox-b-1-m&channel=ts"
|
||||
const val GOOGLE_XX_URL = "https://www.google.com/webhp?client=firefox-b-m&channel=ts"
|
||||
|
||||
data class ShoppingFes(
|
||||
val website: String,
|
||||
val shoppingFesName: String = "",
|
||||
val icon: Int,
|
||||
val url: String = "",
|
||||
val startDate: String = "", // Format in "dd/MM/yyyy".
|
||||
val endDate: String = "" // Format in "dd/MM/yyyy".
|
||||
)
|
||||
|
||||
// Initialize these two value with fresh params for every shopping fes.
|
||||
val shoppingFesJD = ShoppingFes("JD", icon = R.drawable.ic_jd)
|
||||
val shoppingFesPDD = ShoppingFes("PDD", icon = R.drawable.ic_pdd)
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
val sdf = SimpleDateFormat("dd/MM/yyyy")
|
||||
val currentDate: String = sdf.format(Date())
|
||||
val isShoppingFesForJD = currentDate.isNotEmpty() &&
|
||||
shoppingFesJD.endDate.isNotEmpty() &&
|
||||
shoppingFesJD.startDate.isNotEmpty() &&
|
||||
sdf.parse(currentDate)!!.before(sdf.parse(shoppingFesJD.endDate)) &&
|
||||
sdf.parse(currentDate)!!.after(sdf.parse(shoppingFesJD.startDate))
|
||||
val isShoppingFesForPDD = currentDate.isNotEmpty() &&
|
||||
shoppingFesPDD.endDate.isNotEmpty() &&
|
||||
shoppingFesPDD.startDate.isNotEmpty() &&
|
||||
sdf.parse(currentDate)!!.before(sdf.parse(shoppingFesPDD.endDate)) &&
|
||||
sdf.parse(currentDate)!!.after(sdf.parse(shoppingFesPDD.startDate))
|
||||
|
||||
enum class SumoTopic(internal val topicStr: String) {
|
||||
FENIX_MOVING("sync-delist"),
|
||||
HELP("faq-android"),
|
||||
|
|
Loading…
Reference in New Issue