From 79ae1595808af459c921722715c32eeb87658ae5 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 3 Jul 2023 13:27:37 +0200 Subject: [PATCH 1/6] Build: Move android related gradle properties to its own group --- gradle.properties | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2a0e00caf..9da0c58ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,11 +11,12 @@ # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m org.gradle.jvmargs=-Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -android.enableJetifier=false -android.useAndroidX=true - - # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects - org.gradle.parallel=true +org.gradle.parallel=true + +# AztecAndroid-Android properties. + +android.enableJetifier=false +android.useAndroidX=true From 8b668e403ada9144b1730839d479b9b7b4160e21 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 3 Jul 2023 13:33:10 +0200 Subject: [PATCH 2/6] Build: Automatically migrate to non-transitive r classes The changes in this commit was automatically applied on triggering the "Refactor" -> "Migration to Non-Transitive R Classes..." migration process via AS. --- .../aztec/demo/pages/EditLinkPage.kt | 7 ++--- .../wordpress/aztec/demo/pages/EditorPage.kt | 28 +++++++++---------- .../org/wordpress/aztec/demo/MainActivity.kt | 8 +++--- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt index c9f892252..65ecfa1f8 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt @@ -9,7 +9,6 @@ import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import org.wordpress.aztec.demo.BasePage -import org.wordpress.aztec.demo.R class EditLinkPage : BasePage() { @@ -24,9 +23,9 @@ class EditLinkPage : BasePage() { get() = onView(withText("Insert link")) init { - urlField = onView(withId(R.id.linkURL)) - nameField = onView(withId(R.id.linkText)) - openInNewWindowCheckbox = onView(withId(R.id.openInNewWindow)) + urlField = onView(withId(org.wordpress.aztec.R.id.linkURL)) + nameField = onView(withId(org.wordpress.aztec.R.id.linkText)) + openInNewWindowCheckbox = onView(withId(org.wordpress.aztec.R.id.openInNewWindow)) okButton = onView(withId(android.R.id.button1)) cancelButton = onView(withId(android.R.id.button2)) removeButton = onView(withId(android.R.id.button3)) diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt index 37518486a..ea3a854a4 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt @@ -58,20 +58,20 @@ class EditorPage : BasePage() { undoButton = onView(withId(R.id.undo)) redoButton = onView(withId(R.id.redo)) - openMediaToolbarButton = onView(withId(R.id.format_bar_button_media_collapsed)) - closeMediaToolbarButton = onView(withId(R.id.format_bar_button_media_expanded)) - headingButton = onView(withId(R.id.format_bar_button_heading)) - listButton = onView(withId(R.id.format_bar_button_list)) - quoteButton = onView(withId(R.id.format_bar_button_quote)) - boldButton = onView(withId(R.id.format_bar_button_bold)) - italicsButton = onView(withId(R.id.format_bar_button_italic)) - linkButton = onView(withId(R.id.format_bar_button_link)) - underlineButton = onView(withId(R.id.format_bar_button_underline)) - strikethroughButton = onView(withId(R.id.format_bar_button_strikethrough)) - horizontalRuleButton = onView(withId(R.id.format_bar_button_horizontal_rule)) - moreRuleButton = onView(withId(R.id.format_bar_button_more)) - pageButton = onView(withId(R.id.format_bar_button_page)) - htmlButton = onView(withId(R.id.format_bar_button_html)) + openMediaToolbarButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_media_collapsed)) + closeMediaToolbarButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_media_expanded)) + headingButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_heading)) + listButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_list)) + quoteButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_quote)) + boldButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_bold)) + italicsButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_italic)) + linkButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_link)) + underlineButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_underline)) + strikethroughButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_strikethrough)) + horizontalRuleButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_horizontal_rule)) + moreRuleButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_more)) + pageButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_page)) + htmlButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_html)) photoButton = onView(allOf(withId(android.R.id.title), withText("Photo from device"))) galleryButton = onView(withId(R.id.media_bar_button_gallery)) diff --git a/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt b/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt index 69ba305ea..52a68af92 100644 --- a/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt +++ b/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt @@ -489,7 +489,7 @@ open class MainActivity : AppCompatActivity(), aztec.visualEditor.setCalypsoMode(false) aztec.sourceEditor?.setCalypsoMode(false) - aztec.visualEditor.setBackgroundSpanColor(ContextCompat.getColor(this, R.color.blue_dark)) + aztec.visualEditor.setBackgroundSpanColor(ContextCompat.getColor(this, org.wordpress.aztec.R.color.blue_dark)) aztec.sourceEditor?.displayStyledAndFormattedHtml(EXAMPLE) @@ -704,7 +704,7 @@ open class MainActivity : AppCompatActivity(), startActivityForResult(intent, REQUEST_MEDIA_PHOTO) } catch (exception: ActivityNotFoundException) { AppLog.e(AppLog.T.EDITOR, exception.message) - ToastUtils.showToast(this, getString(R.string.error_chooser_photo), ToastUtils.Duration.LONG) + ToastUtils.showToast(this, getString(org.wordpress.aztec.R.string.error_chooser_photo), ToastUtils.Duration.LONG) } } } @@ -719,7 +719,7 @@ open class MainActivity : AppCompatActivity(), startActivityForResult(intent, REQUEST_MEDIA_VIDEO) } catch (exception: ActivityNotFoundException) { AppLog.e(AppLog.T.EDITOR, exception.message) - ToastUtils.showToast(this, getString(R.string.error_chooser_video), ToastUtils.Duration.LONG) + ToastUtils.showToast(this, getString(org.wordpress.aztec.R.string.error_chooser_video), ToastUtils.Duration.LONG) } } } @@ -819,7 +819,7 @@ open class MainActivity : AppCompatActivity(), val mediaPending = aztec.visualEditor.getAllElementAttributes(uploadingPredicate).isNotEmpty() if (mediaPending) { - ToastUtils.showToast(this, R.string.media_upload_dialog_message) + ToastUtils.showToast(this, org.wordpress.aztec.R.string.media_upload_dialog_message) } else { aztec.toolbar.toggleEditorMode() } From 5d98cf08ed9b3fc6d3c6053bdece55c78e5123fb Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 3 Jul 2023 13:38:27 +0200 Subject: [PATCH 3/6] Refactor: Optimize imports on res for aztec R --- .../aztec/demo/pages/EditLinkPage.kt | 7 +++-- .../wordpress/aztec/demo/pages/EditorPage.kt | 29 ++++++++++--------- .../org/wordpress/aztec/demo/MainActivity.kt | 13 +++++---- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt index 65ecfa1f8..c1f22a764 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt @@ -9,6 +9,7 @@ import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import org.wordpress.aztec.demo.BasePage +import org.wordpress.aztec.R as AztecR class EditLinkPage : BasePage() { @@ -23,9 +24,9 @@ class EditLinkPage : BasePage() { get() = onView(withText("Insert link")) init { - urlField = onView(withId(org.wordpress.aztec.R.id.linkURL)) - nameField = onView(withId(org.wordpress.aztec.R.id.linkText)) - openInNewWindowCheckbox = onView(withId(org.wordpress.aztec.R.id.openInNewWindow)) + urlField = onView(withId(AztecR.id.linkURL)) + nameField = onView(withId(AztecR.id.linkText)) + openInNewWindowCheckbox = onView(withId(AztecR.id.openInNewWindow)) okButton = onView(withId(android.R.id.button1)) cancelButton = onView(withId(android.R.id.button2)) removeButton = onView(withId(android.R.id.button3)) diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt index ea3a854a4..c9d5b09c7 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt @@ -1,5 +1,7 @@ package org.wordpress.aztec.demo.pages +import android.view.KeyEvent +import android.view.View import androidx.test.espresso.DataInteraction import androidx.test.espresso.Espresso.onData import androidx.test.espresso.Espresso.onView @@ -12,8 +14,6 @@ import androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import android.view.KeyEvent -import android.view.View import org.hamcrest.Matcher import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.hasToString @@ -22,6 +22,7 @@ import org.wordpress.aztec.demo.Actions import org.wordpress.aztec.demo.BasePage import org.wordpress.aztec.demo.Matchers import org.wordpress.aztec.demo.R +import org.wordpress.aztec.R as AztecR class EditorPage : BasePage() { private var editor: ViewInteraction @@ -58,20 +59,20 @@ class EditorPage : BasePage() { undoButton = onView(withId(R.id.undo)) redoButton = onView(withId(R.id.redo)) - openMediaToolbarButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_media_collapsed)) - closeMediaToolbarButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_media_expanded)) - headingButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_heading)) - listButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_list)) - quoteButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_quote)) - boldButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_bold)) - italicsButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_italic)) - linkButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_link)) - underlineButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_underline)) - strikethroughButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_strikethrough)) - horizontalRuleButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_horizontal_rule)) + openMediaToolbarButton = onView(withId(AztecR.id.format_bar_button_media_collapsed)) + closeMediaToolbarButton = onView(withId(AztecR.id.format_bar_button_media_expanded)) + headingButton = onView(withId(AztecR.id.format_bar_button_heading)) + listButton = onView(withId(AztecR.id.format_bar_button_list)) + quoteButton = onView(withId(AztecR.id.format_bar_button_quote)) + boldButton = onView(withId(AztecR.id.format_bar_button_bold)) + italicsButton = onView(withId(AztecR.id.format_bar_button_italic)) + linkButton = onView(withId(AztecR.id.format_bar_button_link)) + underlineButton = onView(withId(AztecR.id.format_bar_button_underline)) + strikethroughButton = onView(withId(AztecR.id.format_bar_button_strikethrough)) + horizontalRuleButton = onView(withId(AztecR.id.format_bar_button_horizontal_rule)) moreRuleButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_more)) pageButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_page)) - htmlButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_html)) + htmlButton = onView(withId(AztecR.id.format_bar_button_html)) photoButton = onView(allOf(withId(android.R.id.title), withText("Photo from device"))) galleryButton = onView(withId(R.id.media_bar_button_gallery)) diff --git a/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt b/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt index 52a68af92..4a5769fbb 100644 --- a/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt +++ b/app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt @@ -70,6 +70,7 @@ import org.wordpress.aztec.util.AztecLog import org.xml.sax.Attributes import java.io.File import java.util.Random +import org.wordpress.aztec.R as AztecR open class MainActivity : AppCompatActivity(), AztecText.OnImeBackListener, @@ -489,7 +490,7 @@ open class MainActivity : AppCompatActivity(), aztec.visualEditor.setCalypsoMode(false) aztec.sourceEditor?.setCalypsoMode(false) - aztec.visualEditor.setBackgroundSpanColor(ContextCompat.getColor(this, org.wordpress.aztec.R.color.blue_dark)) + aztec.visualEditor.setBackgroundSpanColor(ContextCompat.getColor(this, AztecR.color.blue_dark)) aztec.sourceEditor?.displayStyledAndFormattedHtml(EXAMPLE) @@ -704,7 +705,7 @@ open class MainActivity : AppCompatActivity(), startActivityForResult(intent, REQUEST_MEDIA_PHOTO) } catch (exception: ActivityNotFoundException) { AppLog.e(AppLog.T.EDITOR, exception.message) - ToastUtils.showToast(this, getString(org.wordpress.aztec.R.string.error_chooser_photo), ToastUtils.Duration.LONG) + ToastUtils.showToast(this, getString(AztecR.string.error_chooser_photo), ToastUtils.Duration.LONG) } } } @@ -719,7 +720,7 @@ open class MainActivity : AppCompatActivity(), startActivityForResult(intent, REQUEST_MEDIA_VIDEO) } catch (exception: ActivityNotFoundException) { AppLog.e(AppLog.T.EDITOR, exception.message) - ToastUtils.showToast(this, getString(org.wordpress.aztec.R.string.error_chooser_video), ToastUtils.Duration.LONG) + ToastUtils.showToast(this, getString(AztecR.string.error_chooser_video), ToastUtils.Duration.LONG) } } } @@ -819,7 +820,7 @@ open class MainActivity : AppCompatActivity(), val mediaPending = aztec.visualEditor.getAllElementAttributes(uploadingPredicate).isNotEmpty() if (mediaPending) { - ToastUtils.showToast(this, org.wordpress.aztec.R.string.media_upload_dialog_message) + ToastUtils.showToast(this, AztecR.string.media_upload_dialog_message) } else { aztec.toolbar.toggleEditorMode() } @@ -858,8 +859,8 @@ open class MainActivity : AppCompatActivity(), private fun showMediaUploadDialog() { val builder = AlertDialog.Builder(this) - builder.setMessage(getString(org.wordpress.aztec.R.string.media_upload_dialog_message)) - builder.setPositiveButton(getString(org.wordpress.aztec.R.string.media_upload_dialog_positive), null) + builder.setMessage(getString(AztecR.string.media_upload_dialog_message)) + builder.setPositiveButton(getString(AztecR.string.media_upload_dialog_positive), null) mediaUploadDialog = builder.create() mediaUploadDialog!!.show() } From 90dd2306f8e5ebae5839997002f4e9e654a19692 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 3 Jul 2023 13:40:29 +0200 Subject: [PATCH 4/6] Refactor: Optimize imports on res for wp components R --- .../kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt index c9d5b09c7..2b7405883 100644 --- a/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt +++ b/app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt @@ -23,6 +23,7 @@ import org.wordpress.aztec.demo.BasePage import org.wordpress.aztec.demo.Matchers import org.wordpress.aztec.demo.R import org.wordpress.aztec.R as AztecR +import org.wordpress.aztec.plugins.wpcomments.R as WPCommentsR class EditorPage : BasePage() { private var editor: ViewInteraction @@ -70,8 +71,8 @@ class EditorPage : BasePage() { underlineButton = onView(withId(AztecR.id.format_bar_button_underline)) strikethroughButton = onView(withId(AztecR.id.format_bar_button_strikethrough)) horizontalRuleButton = onView(withId(AztecR.id.format_bar_button_horizontal_rule)) - moreRuleButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_more)) - pageButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_page)) + moreRuleButton = onView(withId(WPCommentsR.id.format_bar_button_more)) + pageButton = onView(withId(WPCommentsR.id.format_bar_button_page)) htmlButton = onView(withId(AztecR.id.format_bar_button_html)) photoButton = onView(allOf(withId(android.R.id.title), withText("Photo from device"))) From 1847206ae5e4c28d5843ff492be413836f382602 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 3 Jul 2023 13:41:01 +0200 Subject: [PATCH 5/6] Build: Enable non transitive resources for the project --- gradle.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradle.properties b/gradle.properties index 9da0c58ea..a288b9792 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,3 +20,5 @@ org.gradle.parallel=true android.enableJetifier=false android.useAndroidX=true + +android.nonTransitiveRClass=true From f2dcd9ce1216ede18631b29398073298f781e87f Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 3 Jul 2023 18:20:02 +0200 Subject: [PATCH 6/6] Deps: Extract automattic publish to s3 version to settings build gradle --- settings.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index e049ee25c..80899eb9f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,12 +1,13 @@ pluginManagement { gradle.ext.kotlinVersion = '1.6.10' gradle.ext.agpVersion = '7.2.1' + gradle.ext.automatticPublishToS3Version = '0.7.0' plugins { id "com.android.library" version gradle.ext.agpVersion id "com.android.application" version gradle.ext.agpVersion id "org.jetbrains.kotlin.android" version gradle.ext.kotlinVersion - id "com.automattic.android.publish-to-s3" version "0.7.0" + id "com.automattic.android.publish-to-s3" version gradle.ext.automatticPublishToS3Version } repositories { maven {