Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Gradle to 5.4.1 & Gradle plugin to 3.5.1 #10583

Merged
merged 16 commits into from Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions WordPress/build.gradle
Expand Up @@ -182,13 +182,16 @@ dependencies {
exclude group: 'com.android.support', module: 'support-core-utils'
})

implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.android.installreferrer:installreferrer:1.0'
implementation 'com.github.chrisbanes.photoview:library:1.2.4'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.automattic:rest:1.0.7'
implementation ('com.automattic:rest:1.0.7') {
exclude group: 'com.mcxiaoke.volley'
}
implementation 'org.wordpress:graphview:3.4.0'
implementation 'org.wordpress:persistentedittext:1.0.2'
implementation 'org.wordpress:emailchecker2:1.1.0'
Expand All @@ -206,8 +209,8 @@ dependencies {
implementation 'com.github.bumptech.glide:volley-integration:4.6.1@aar'

testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.6.1'
testImplementation 'org.robolectric:shadows-multidex:3.6.1'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.robolectric:shadows-multidex:4.3'
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
testImplementation 'org.assertj:assertj-core:3.11.1'
Expand Down Expand Up @@ -260,7 +263,9 @@ dependencies {
implementation ('com.github.indexos.media-for-mobile:android:43a9026f0973a2f0a74fa813132f6a16f7499c3a')

implementation project(path:':libs:utils:WordPressUtils')
implementation project(path:':libs:networking:WordPressNetworking')
implementation (project(path:':libs:networking:WordPressNetworking')) {
exclude group: "com.android.volley"
}
implementation project(path:':libs:analytics:WordPressAnalytics')
implementation project(path:':libs:editor:WordPressEditor')
implementation (project(path:':libs:login:WordPressLoginFlow')) {
Expand Down
134 changes: 51 additions & 83 deletions WordPress/lint-baseline.xml

Large diffs are not rendered by default.

Expand Up @@ -17,6 +17,7 @@ import org.wordpress.android.login.BuildConfig
import org.wordpress.android.ui.accounts.HelpActivity.Origin
import org.wordpress.android.ui.notifications.utils.NotificationsUtils
import org.wordpress.android.ui.prefs.AppPrefs
import org.wordpress.android.util.currentLocale
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.AppLog.T
import org.wordpress.android.util.DeviceUtils
Expand Down Expand Up @@ -457,7 +458,7 @@ private fun getNetworkInformation(context: Context): String {
return listOf(
"${ZendeskConstants.networkTypeLabel} $networkType",
"${ZendeskConstants.networkCarrierLabel} $carrierName",
"${ZendeskConstants.networkCountryCodeLabel} ${countryCodeLabel.toUpperCase()}"
"${ZendeskConstants.networkCountryCodeLabel} ${countryCodeLabel.toUpperCase(context.currentLocale)}"
).joinToString(separator = "\n")
}

Expand Down
@@ -1,6 +1,7 @@
package org.wordpress.android.ui.news

import org.wordpress.android.util.analytics.AnalyticsUtils
import java.util.Locale
import javax.inject.Inject

import javax.inject.Singleton
Expand All @@ -12,14 +13,14 @@ class NewsTracker @Inject constructor() {
}

fun trackNewsCardShown(origin: NewsCardOrigin, version: Int) {
AnalyticsUtils.trackNewsCardShown(origin.name.toLowerCase(), version)
AnalyticsUtils.trackNewsCardShown(origin.name.toLowerCase(Locale.ROOT), version)
}

fun trackNewsCardDismissed(origin: NewsCardOrigin, version: Int) {
AnalyticsUtils.trackNewsCardDismissed(origin.name.toLowerCase(), version)
AnalyticsUtils.trackNewsCardDismissed(origin.name.toLowerCase(Locale.ROOT), version)
}

fun trackNewsCardExtendedInfoRequested(origin: NewsCardOrigin, version: Int) {
AnalyticsUtils.trackNewsCardExtendedInfoRequested(origin.name.toLowerCase(), version)
AnalyticsUtils.trackNewsCardExtendedInfoRequested(origin.name.toLowerCase(Locale.ROOT), version)
}
}
Expand Up @@ -20,9 +20,11 @@ import org.wordpress.android.ui.pages.PageItem.Empty
import org.wordpress.android.ui.pages.PageItem.Page
import org.wordpress.android.ui.pages.PageItem.ParentPage
import org.wordpress.android.ui.reader.utils.ReaderUtils
import org.wordpress.android.util.currentLocale
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.DisplayUtils
import org.wordpress.android.util.ImageUtils
import org.wordpress.android.util.capitalizeWithLocaleWithoutLint
import org.wordpress.android.util.getDrawableFromAttribute
import org.wordpress.android.util.image.ImageManager
import org.wordpress.android.util.image.ImageType
Expand Down Expand Up @@ -54,6 +56,7 @@ sealed class PageItemViewHolder(internal val parent: ViewGroup, @LayoutRes layou
const val FEATURED_IMAGE_THUMBNAIL_SIZE_DP = 40
}

@ExperimentalStdlibApi
override fun onBind(pageItem: PageItem) {
(pageItem as Page).let { page ->
val indentWidth = DisplayUtils.dpToPx(parent.context, 16 * page.indent)
Expand All @@ -67,7 +70,8 @@ sealed class PageItemViewHolder(internal val parent: ViewGroup, @LayoutRes layou
page.title

val date = if (page.date == Date(0)) Date() else page.date
time.text = DateTimeUtils.javaDateToTimeSpan(date, parent.context).capitalize()
time.text = DateTimeUtils.javaDateToTimeSpan(date, parent.context)
.capitalizeWithLocaleWithoutLint(parent.context.currentLocale)

if (page.labels.isNotEmpty()) {
labels.text = page.labels.map { parent.context.getString(it) }.sorted()
Expand Down
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.posts

import androidx.collection.LongSparseArray
import org.wordpress.android.fluxc.Dispatcher
import org.wordpress.android.fluxc.generated.MediaActionBuilder
import org.wordpress.android.fluxc.model.MediaModel
Expand All @@ -12,17 +13,17 @@ import org.wordpress.android.fluxc.store.MediaStore.MediaPayload
* you see fit.
*/
class PostListFeaturedImageTracker(private val dispatcher: Dispatcher, private val mediaStore: MediaStore) {
private val featuredImageMap = HashMap<Long, String>()
private val featuredImageArray = LongSparseArray<String>()

fun getFeaturedImageUrl(site: SiteModel, featuredImageId: Long): String? {
if (featuredImageId == 0L) {
return null
}
featuredImageMap[featuredImageId]?.let { return it }
featuredImageArray[featuredImageId]?.let { return it }
mediaStore.getSiteMediaWithId(site, featuredImageId)?.let { media ->
// This should be a pretty rare case, but some media seems to be missing url
return if (media.url != null) {
featuredImageMap[featuredImageId] = media.url
featuredImageArray.put(featuredImageId, media.url)
media.url
} else null
}
Expand All @@ -36,6 +37,6 @@ class PostListFeaturedImageTracker(private val dispatcher: Dispatcher, private v
}

fun invalidateFeaturedMedia(featuredImageIds: List<Long>) {
featuredImageIds.forEach { featuredImageMap.remove(it) }
featuredImageIds.forEach { featuredImageArray.remove(it) }
}
}
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.posts

import androidx.collection.SparseArrayCompat
import org.wordpress.android.fluxc.model.PostModel
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.fluxc.store.UploadStore
Expand All @@ -15,10 +16,10 @@ class PostListUploadStatusTracker(
private val uploadStore: UploadStore,
private val uploadActionUseCase: UploadActionUseCase
) {
private val uploadStatusMap = HashMap<Int, PostListItemUploadStatus>()
private val uploadStatusArray = SparseArrayCompat<PostListItemUploadStatus>()

fun getUploadStatus(post: PostModel, siteModel: SiteModel): PostListItemUploadStatus {
uploadStatusMap[post.id]?.let { return it }
uploadStatusArray[post.id]?.let { return it }
val uploadError = uploadStore.getUploadErrorForPost(post)
val isUploadingOrQueued = UploadService.isPostUploadingOrQueued(post)
val hasInProgressMediaUpload = UploadService.hasInProgressMediaUploadsForPost(post)
Expand All @@ -34,11 +35,11 @@ class PostListUploadStatusTracker(
isEligibleForAutoUpload = uploadActionUseCase.isEligibleForAutoUpload(siteModel, post),
uploadWillPushChanges = uploadActionUseCase.uploadWillPushChanges(post)
)
uploadStatusMap[post.id] = newStatus
uploadStatusArray.put(post.id, newStatus)
return newStatus
}

fun invalidateUploadStatus(localPostIds: List<Int>) {
localPostIds.forEach { uploadStatusMap.remove(it) }
localPostIds.forEach { uploadStatusArray.remove(it) }
}
}
Expand Up @@ -155,7 +155,10 @@ private val PostListDiffItemCallback = object : DiffUtil.ItemCallback<PostListIt
return true
}
if (oldItem is LoadingItem && newItem is LoadingItem) {
return oldItem.localOrRemoteId == newItem.localOrRemoteId
return when (oldItem.localOrRemoteId) {
is LocalId -> oldItem.localOrRemoteId.value == (newItem.localOrRemoteId as? LocalId)?.value
is RemoteId -> oldItem.localOrRemoteId.value == (newItem.localOrRemoteId as? RemoteId)?.value
}
}
if (oldItem is PostListItemUiState && newItem is PostListItemUiState) {
return oldItem.data == newItem.data
Expand Down
Expand Up @@ -2,6 +2,7 @@ package org.wordpress.android.ui.sitecreation.misc

import org.wordpress.android.analytics.AnalyticsTracker
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -110,14 +111,14 @@ class SiteCreationTracker @Inject constructor(val tracker: AnalyticsTrackerWrapp
}

fun trackErrorShown(errorContext: String, errorType: SiteCreationErrorType, errorDescription: String? = null) {
trackErrorShown(errorContext, errorType.toString().toLowerCase(), errorDescription)
trackErrorShown(errorContext, errorType.toString().toLowerCase(Locale.ROOT), errorDescription)
}

fun trackErrorShown(errorContext: String, errorType: String, errorDescription: String? = null) {
tracker.track(
AnalyticsTracker.Stat.ENHANCED_SITE_CREATION_ERROR_SHOWN,
errorContext,
errorType.toLowerCase(),
errorType.toLowerCase(Locale.ROOT),
errorDescription ?: ""
)
}
Expand Down
Expand Up @@ -38,6 +38,7 @@ import org.wordpress.android.ui.sitecreation.verticals.SiteCreationVerticalsView
import org.wordpress.android.ui.utils.UiString.UiStringText
import org.wordpress.android.util.NetworkUtilsWrapper
import org.wordpress.android.viewmodel.SingleLiveEvent
import java.util.Locale
import javax.inject.Inject
import javax.inject.Named
import kotlin.coroutines.CoroutineContext
Expand Down Expand Up @@ -263,7 +264,7 @@ class SiteCreationVerticalsViewModel @Inject constructor(
val onItemTapped = {
tracker.trackVerticalSelected(model.name, model.verticalId, model.isUserInputVertical)
_verticalSelected.value = if (model.isUserInputVertical) {
model.name.toLowerCase()
model.name.toLowerCase(Locale.ROOT)
} else {
model.verticalId
}
Expand Down
Expand Up @@ -54,6 +54,7 @@ class MostPopularInsightsUseCase
return listOf(buildTitle(), Empty())
}

@ExperimentalStdlibApi
override fun buildUiModel(domainModel: InsightsMostPopularModel): List<BlockListItem> {
val items = mutableListOf<BlockListItem>()
items.add(buildTitle())
Expand Down
Expand Up @@ -4,6 +4,7 @@ import android.text.format.DateFormat
import android.text.format.DateUtils
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.LocaleManagerWrapper
import org.wordpress.android.util.capitalizeWithLocaleWithoutLint
import org.wordpress.android.viewmodel.ContextProvider
import java.text.SimpleDateFormat
import java.util.Calendar
Expand All @@ -13,6 +14,7 @@ class DateUtils @Inject constructor(
private val contextProvider: ContextProvider,
private val localeManagerWrapper: LocaleManagerWrapper
) {
@ExperimentalStdlibApi
fun getWeekDay(dayOfTheWeek: Int): String {
val c = Calendar.getInstance()
c.firstDayOfWeek = Calendar.MONDAY
Expand All @@ -28,7 +30,7 @@ class DateUtils @Inject constructor(
}

val formatter = SimpleDateFormat("EEEE", localeManagerWrapper.getLocale())
return formatter.format(c.time).capitalize()
return formatter.format(c.time).capitalizeWithLocaleWithoutLint(localeManagerWrapper.getLocale())
}

fun getHour(hour: Int): String {
Expand Down
Expand Up @@ -5,6 +5,8 @@ import android.util.TypedValue
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.os.ConfigurationCompat
import java.util.Locale

@ColorRes
fun Context.getColorResIdFromAttribute(@AttrRes attribute: Int) =
Expand All @@ -19,3 +21,7 @@ fun Context.getColorFromAttribute(@AttrRes attribute: Int) =
theme.resolveAttribute(attribute, it, true)
it.data
}

// https://developer.android.com/reference/android/content/res/Configuration.html#locale
val Context.currentLocale: Locale
get() = ConfigurationCompat.getLocales(resources.configuration)[0]
@@ -0,0 +1,20 @@
package org.wordpress.android.util

import android.annotation.SuppressLint
import java.util.Locale

/**
* This is a wrapper method for Kotlin's [String.capitalize] method.
*
* Even though we are passing a locale to the [String.capitalize] method, we still get a lint error stating that we are
* passing a default locale to it. Instead of littering the code with a lot of suppressed lint calls, this wrapper is
* created so we can suppress it in one place. Hopefully we can remove this method soon and just replace all the callers
* with the [String.capitalize] call.
*
* The [capitalizeWithLocaleWithoutLint] is chosen to communicate this issue with the caller.
*/
@ExperimentalStdlibApi
@SuppressLint("DefaultLocale")
fun String.capitalizeWithLocaleWithoutLint(locale: Locale): String {
return this.capitalize(locale)
}
@@ -1,6 +1,6 @@
package org.wordpress.android;

import android.os.Build;
import android.os.Build.VERSION_CODES;

import org.junit.After;
import org.junit.Assert;
Expand All @@ -14,7 +14,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(application = TestApplication.class, sdk = Build.VERSION_CODES.JELLY_BEAN)
@Config(application = TestApplication.class, sdk = VERSION_CODES.LOLLIPOP)
public class RobolectricSetupTest {
@Rule
public ExpectedException exception = ExpectedException.none();
Expand Down
Expand Up @@ -44,6 +44,7 @@ class MostPopularInsightsUseCaseTest : BaseUnitTest() {
private val hour = 20
private val highestHourPercent = 25.5
private val hourString = "8:00 PM"
@ExperimentalStdlibApi
@InternalCoroutinesApi
@Before
fun setUp() {
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Expand Up @@ -9,14 +9,14 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.automattic.android:fetchstyle:1.1'
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}

plugins {
id 'com.gradle.build-scan' version '1.16'
id 'com.gradle.build-scan' version '2.0.2'
}

apply plugin: 'com.automattic.android.fetchstyle'
Expand Down Expand Up @@ -97,14 +97,14 @@ subprojects {
buildScan {
// Always run Gradle scan on CI builds
if (System.getenv('CI')) {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
tag 'CI'
publishAlways()
}
}

ext {
daggerVersion = '2.22.1'
fluxCVersion = '1.5.1-beta-1'
fluxCVersion = '1.5.1-beta-2'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Tue Jan 22 14:59:58 GMT 2019
#Mon Sep 30 15:10:36 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
2 changes: 1 addition & 1 deletion libs/analytics/WordPressAnalytics/build.gradle
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.novoda:bintray-release:0.8.1'
}
}
Expand Down