Skip to content

Commit 5d98cf0

Browse files
committed
Refactor: Optimize imports on res for aztec R
1 parent 8b668e4 commit 5d98cf0

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditLinkPage.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.test.espresso.assertion.ViewAssertions
99
import androidx.test.espresso.matcher.ViewMatchers.withId
1010
import androidx.test.espresso.matcher.ViewMatchers.withText
1111
import org.wordpress.aztec.demo.BasePage
12+
import org.wordpress.aztec.R as AztecR
1213

1314
class EditLinkPage : BasePage() {
1415

@@ -23,9 +24,9 @@ class EditLinkPage : BasePage() {
2324
get() = onView(withText("Insert link"))
2425

2526
init {
26-
urlField = onView(withId(org.wordpress.aztec.R.id.linkURL))
27-
nameField = onView(withId(org.wordpress.aztec.R.id.linkText))
28-
openInNewWindowCheckbox = onView(withId(org.wordpress.aztec.R.id.openInNewWindow))
27+
urlField = onView(withId(AztecR.id.linkURL))
28+
nameField = onView(withId(AztecR.id.linkText))
29+
openInNewWindowCheckbox = onView(withId(AztecR.id.openInNewWindow))
2930
okButton = onView(withId(android.R.id.button1))
3031
cancelButton = onView(withId(android.R.id.button2))
3132
removeButton = onView(withId(android.R.id.button3))

app/src/androidTest/kotlin/org/wordpress/aztec/demo/pages/EditorPage.kt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.wordpress.aztec.demo.pages
22

3+
import android.view.KeyEvent
4+
import android.view.View
35
import androidx.test.espresso.DataInteraction
46
import androidx.test.espresso.Espresso.onData
57
import androidx.test.espresso.Espresso.onView
@@ -12,8 +14,6 @@ import androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView
1214
import androidx.test.espresso.assertion.ViewAssertions.matches
1315
import androidx.test.espresso.matcher.ViewMatchers.withId
1416
import androidx.test.espresso.matcher.ViewMatchers.withText
15-
import android.view.KeyEvent
16-
import android.view.View
1717
import org.hamcrest.Matcher
1818
import org.hamcrest.Matchers.allOf
1919
import org.hamcrest.Matchers.hasToString
@@ -22,6 +22,7 @@ import org.wordpress.aztec.demo.Actions
2222
import org.wordpress.aztec.demo.BasePage
2323
import org.wordpress.aztec.demo.Matchers
2424
import org.wordpress.aztec.demo.R
25+
import org.wordpress.aztec.R as AztecR
2526

2627
class EditorPage : BasePage() {
2728
private var editor: ViewInteraction
@@ -58,20 +59,20 @@ class EditorPage : BasePage() {
5859
undoButton = onView(withId(R.id.undo))
5960
redoButton = onView(withId(R.id.redo))
6061

61-
openMediaToolbarButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_media_collapsed))
62-
closeMediaToolbarButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_media_expanded))
63-
headingButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_heading))
64-
listButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_list))
65-
quoteButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_quote))
66-
boldButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_bold))
67-
italicsButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_italic))
68-
linkButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_link))
69-
underlineButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_underline))
70-
strikethroughButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_strikethrough))
71-
horizontalRuleButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_horizontal_rule))
62+
openMediaToolbarButton = onView(withId(AztecR.id.format_bar_button_media_collapsed))
63+
closeMediaToolbarButton = onView(withId(AztecR.id.format_bar_button_media_expanded))
64+
headingButton = onView(withId(AztecR.id.format_bar_button_heading))
65+
listButton = onView(withId(AztecR.id.format_bar_button_list))
66+
quoteButton = onView(withId(AztecR.id.format_bar_button_quote))
67+
boldButton = onView(withId(AztecR.id.format_bar_button_bold))
68+
italicsButton = onView(withId(AztecR.id.format_bar_button_italic))
69+
linkButton = onView(withId(AztecR.id.format_bar_button_link))
70+
underlineButton = onView(withId(AztecR.id.format_bar_button_underline))
71+
strikethroughButton = onView(withId(AztecR.id.format_bar_button_strikethrough))
72+
horizontalRuleButton = onView(withId(AztecR.id.format_bar_button_horizontal_rule))
7273
moreRuleButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_more))
7374
pageButton = onView(withId(org.wordpress.aztec.plugins.wpcomments.R.id.format_bar_button_page))
74-
htmlButton = onView(withId(org.wordpress.aztec.R.id.format_bar_button_html))
75+
htmlButton = onView(withId(AztecR.id.format_bar_button_html))
7576

7677
photoButton = onView(allOf(withId(android.R.id.title), withText("Photo from device")))
7778
galleryButton = onView(withId(R.id.media_bar_button_gallery))

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import org.wordpress.aztec.util.AztecLog
7070
import org.xml.sax.Attributes
7171
import java.io.File
7272
import java.util.Random
73+
import org.wordpress.aztec.R as AztecR
7374

7475
open class MainActivity : AppCompatActivity(),
7576
AztecText.OnImeBackListener,
@@ -489,7 +490,7 @@ open class MainActivity : AppCompatActivity(),
489490
aztec.visualEditor.setCalypsoMode(false)
490491
aztec.sourceEditor?.setCalypsoMode(false)
491492

492-
aztec.visualEditor.setBackgroundSpanColor(ContextCompat.getColor(this, org.wordpress.aztec.R.color.blue_dark))
493+
aztec.visualEditor.setBackgroundSpanColor(ContextCompat.getColor(this, AztecR.color.blue_dark))
493494

494495
aztec.sourceEditor?.displayStyledAndFormattedHtml(EXAMPLE)
495496

@@ -704,7 +705,7 @@ open class MainActivity : AppCompatActivity(),
704705
startActivityForResult(intent, REQUEST_MEDIA_PHOTO)
705706
} catch (exception: ActivityNotFoundException) {
706707
AppLog.e(AppLog.T.EDITOR, exception.message)
707-
ToastUtils.showToast(this, getString(org.wordpress.aztec.R.string.error_chooser_photo), ToastUtils.Duration.LONG)
708+
ToastUtils.showToast(this, getString(AztecR.string.error_chooser_photo), ToastUtils.Duration.LONG)
708709
}
709710
}
710711
}
@@ -719,7 +720,7 @@ open class MainActivity : AppCompatActivity(),
719720
startActivityForResult(intent, REQUEST_MEDIA_VIDEO)
720721
} catch (exception: ActivityNotFoundException) {
721722
AppLog.e(AppLog.T.EDITOR, exception.message)
722-
ToastUtils.showToast(this, getString(org.wordpress.aztec.R.string.error_chooser_video), ToastUtils.Duration.LONG)
723+
ToastUtils.showToast(this, getString(AztecR.string.error_chooser_video), ToastUtils.Duration.LONG)
723724
}
724725
}
725726
}
@@ -819,7 +820,7 @@ open class MainActivity : AppCompatActivity(),
819820
val mediaPending = aztec.visualEditor.getAllElementAttributes(uploadingPredicate).isNotEmpty()
820821

821822
if (mediaPending) {
822-
ToastUtils.showToast(this, org.wordpress.aztec.R.string.media_upload_dialog_message)
823+
ToastUtils.showToast(this, AztecR.string.media_upload_dialog_message)
823824
} else {
824825
aztec.toolbar.toggleEditorMode()
825826
}
@@ -858,8 +859,8 @@ open class MainActivity : AppCompatActivity(),
858859

859860
private fun showMediaUploadDialog() {
860861
val builder = AlertDialog.Builder(this)
861-
builder.setMessage(getString(org.wordpress.aztec.R.string.media_upload_dialog_message))
862-
builder.setPositiveButton(getString(org.wordpress.aztec.R.string.media_upload_dialog_positive), null)
862+
builder.setMessage(getString(AztecR.string.media_upload_dialog_message))
863+
builder.setPositiveButton(getString(AztecR.string.media_upload_dialog_positive), null)
863864
mediaUploadDialog = builder.create()
864865
mediaUploadDialog!!.show()
865866
}

0 commit comments

Comments
 (0)