Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ class AutomationEndToEndTest : TestCase() {
}
description {
isVisible()
hasText(item.description)
hasText(
targetContext.getString(
item.description,
targetContext.getString(com.itsaky.androidide.R.string.app_name),
),
)
}
grantButton {
isVisible()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ class EndToEndTest : TestCase() {
}
description {
isVisible()
hasText(item.description)
hasText(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMPORTANT: Three things are still unverified, and the PR body lists them under "Not yet done". First, the instrumented tests changed in this PR (EndToEndTest, AutomationEndToEndTest, PermissionScreen) have not been run, so a broken matcher here would break onboarding instrumentation without anyone noticing. Second, the changed screens have not been checked at font scale 1.0 and 2.0, which CLAUDE.md and the ticket's acceptance criteria require. A longer replacement app name is exactly what clips at 2x. Third, the check that a renamed app shows the new name covers only onboarding permissions. Please run these tests, or explicitly waive them, and do the 1.0/2.0 font-scale pass before merge.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three are now done at 214185c, apart from the screens listed at the end.

  • Instrumented tests: I ran EndToEndTest and AutomationEndToEndTest with am instrument on a Galaxy J7 (Android 9). Both pass steps 1 to 20, including step 6, "Verify all permission items", which uses the changed PermissionScreen matchers. Both then fail at step 21.2. That failure is on stage too and has nothing to do with this PR: the scenario waits only 3 s for the "Setting up your project" dialog, which took about 9.5 s to open on the J7, so the dialog stays open and blocks the next step. It's filed as ADFA-7294.
  • Font scale 1.0 and 2.0: I checked these on a Note 20 with CI build C-d-1123-0603: welcome, privacy consent, permissions, editor hint, main screen, the Quick Start title, Preferences, Developer Options, General and About. Every one reads "Code on the Go" at both sizes. Two things are cut off at 2.0, and stage cuts them the same way:
    • The Quick Start toolbar title shows as "Back to Code o…". The text is the same as on stage.
    • The permission card titles show only their last line. That's a stage layout bug, ADFA-7290.
  • A renamed app: with app_name set to Foo & <Bar>, a CI build shows the name exactly as written on all of those screens. So do the first-build dialog and the debugger pairing dialog's HTML. There's no &amp;, and nothing is dropped.
  • Not checked on a device: the crash report screen, the overlay-permission guide, the pairing-success notification, the feedback email subject, the Quick Build messages and other languages. The PR description says why for each.

targetContext.getString(
item.description,
targetContext.getString(com.itsaky.androidide.R.string.app_name),
),
)
}
grantButton {
isVisible()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.itsaky.androidide.screens

import android.view.View
import androidx.test.platform.app.InstrumentationRegistry
import com.itsaky.androidide.R
import com.kaspersky.kaspresso.screens.KScreen
import io.github.kakaocup.kakao.recycler.KRecyclerItem
Expand All @@ -10,24 +11,31 @@ import io.github.kakaocup.kakao.text.KTextView
import org.hamcrest.Matcher

object PermissionScreen : KScreen<PermissionScreen>() {

override val layoutId: Int? = null
override val viewClass: Class<*>? = null

val title = KTextView { withText(R.string.onboarding_title_permissions) }
val subTitle = KTextView { withText(R.string.onboarding_subtitle_permissions) }

val rvPermissions = KRecyclerView(
builder = { withId(R.id.onboarding_items) },
itemTypeBuilder = { itemType(::PermissionItem) }
)

val finishInstallationButton = KButton { withId(R.id.finish_installation_button) }

class PermissionItem(matcher: Matcher<View>) : KRecyclerItem<PermissionItem>(matcher) {

val grantButton = KButton(matcher) { withId(R.id.grant_button) }
val title = KTextView(matcher) { withId(R.id.title) }
val description = KTextView(matcher) { withId(R.id.description) }
}
}
override val layoutId: Int? = null
override val viewClass: Class<*>? = null

val title = KTextView { withText(R.string.onboarding_title_permissions) }

// The subtitle is formatted with the app name, so match the formatted text, not the raw resource.
val subTitle =
KTextView {
val context = InstrumentationRegistry.getInstrumentation().targetContext
withText(context.getString(R.string.onboarding_subtitle_permissions, context.getString(R.string.app_name)))
}

val rvPermissions =
KRecyclerView(
builder = { withId(R.id.onboarding_items) },
itemTypeBuilder = { itemType(::PermissionItem) },
)

val finishInstallationButton = KButton { withId(R.id.finish_installation_button) }

class PermissionItem(
matcher: Matcher<View>,
) : KRecyclerItem<PermissionItem>(matcher) {
val grantButton = KButton(matcher) { withId(R.id.grant_button) }
val title = KTextView(matcher) { withId(R.id.title) }
val description = KTextView(matcher) { withId(R.id.description) }
}
}
23 changes: 19 additions & 4 deletions app/src/main/java/com/itsaky/androidide/actions/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.text.SpannableStringBuilder
import android.text.TextUtils
import android.text.method.LinkMovementMethod
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
Expand Down Expand Up @@ -51,6 +52,7 @@ fun showNotificationPermissionDialog(
context.getString(
R.string.adb_pairing_tutorial_content_notification,
context.getString(R.string.notification_channel_adb_pairing),
context.getString(R.string.app_name),
),
).setPositiveButton(R.string.title_grant) { dialog, _ ->
val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
Expand All @@ -73,7 +75,11 @@ fun showDebuggerNotReadyMessage(context: Context): AlertDialog? =
context.getString(R.string.debugger_not_ready) +
System
.lineSeparator()
.repeat(2) + context.getString(R.string.debugger_error_suggestion_network_restriction),
.repeat(2) +
context.getString(
R.string.debugger_error_suggestion_network_restriction,
context.getString(R.string.app_name),
),
).setPositiveButton(android.R.string.ok, null)
.show()

Expand All @@ -87,6 +93,7 @@ suspend fun handleMissingOverlayPermission(
PermissionsHelper.OverlayPermissionState.UNSUPPORTED -> {
activity.flashError(activity.getString(R.string.permission_overlay_unsupported_hint))
}

PermissionsHelper.OverlayPermissionState.REQUESTABLE -> {
val intent =
Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION).apply {
Expand All @@ -102,6 +109,7 @@ suspend fun handleMissingOverlayPermission(
)
}
}

else -> {}
}
}
Expand Down Expand Up @@ -130,11 +138,18 @@ fun showPairingDialog(
ssb.append(System.lineSeparator())
ssb.append(System.lineSeparator())

ssb.appendOrderedList(*context.resources.getStringArray(R.array.debugger_setup_pairing_steps))
val appName = context.getString(R.string.app_name)
val htmlAppName = TextUtils.htmlEncode(appName)
ssb.appendOrderedList(
*context.resources
.getStringArray(R.array.debugger_setup_pairing_steps)
.map { it.format(htmlAppName) }
.toTypedArray(),
)
ssb.append(System.lineSeparator())

ssb.appendHtmlWithLinks(
context.getString(R.string.debugger_setup_description_footer),
context.getString(R.string.debugger_setup_description_footer, htmlAppName),
launchHelp,
)

Expand Down Expand Up @@ -192,7 +207,7 @@ fun startPairingService(
null,
)
if (mode == AppOpsManager.MODE_ERRORED) {
flashError(context.getString(R.string.err_foreground_service_denial))
flashError(context.getString(R.string.err_foreground_service_denial, context.getString(R.string.app_name)))
}

context.startService(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class InstallFileAction(
}.onFailure { e ->
flashError(
if (e is PluginStillLoadedException) {
getString(R.string.msg_plugin_install_still_loaded, e.pluginId)
getString(R.string.msg_plugin_install_still_loaded, e.pluginId, getString(R.string.app_name))
} else {
getString(R.string.msg_plugin_install_failed, e.message)
},
Expand Down
71 changes: 36 additions & 35 deletions app/src/main/java/com/itsaky/androidide/actions/main/DocsAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,40 @@ import com.itsaky.androidide.resources.R.string
import org.adfa.constants.CONTENT_KEY
import org.adfa.constants.CONTENT_TITLE_KEY

class DocsAction(context: Context) : ActionItem {

override val id: String = ID

companion object {
const val ID = "ide.main.docs"
}

override var label: String = context.getString(R.string.btn_docs)
override var visible: Boolean = true
override var enabled: Boolean = true
override var icon: Drawable? = ContextCompat.getDrawable(context, R.drawable.ic_action_help_outlined)
override var requiresUIThread: Boolean = true
override var location: ActionItem.Location = ActionItem.Location.MAIN_SCREEN
override val order: Int = 7

override fun retrieveTooltipTag(isReadOnlyContext: Boolean): String = TooltipTag.MAIN_HELP

override fun prepare(data: ActionData) {
super.prepare(data)
if (data.get(Context::class.java) == null) {
markInvisible()
}
}

override suspend fun execAction(data: ActionData): Any {
val context = data.get(Context::class.java) ?: return false
val intent =
Intent(context, HelpActivity::class.java).apply {
putExtra(CONTENT_KEY, context.getString(string.docs_url))
putExtra(CONTENT_TITLE_KEY, context.getString(string.back_to_cogo))
}
context.startActivity(intent)
return true
}
class DocsAction(
context: Context,
) : ActionItem {
override val id: String = ID

companion object {
const val ID = "ide.main.docs"
}

override var label: String = context.getString(R.string.btn_docs)
override var visible: Boolean = true
override var enabled: Boolean = true
override var icon: Drawable? = ContextCompat.getDrawable(context, R.drawable.ic_action_help_outlined)
override var requiresUIThread: Boolean = true
override var location: ActionItem.Location = ActionItem.Location.MAIN_SCREEN
override val order: Int = 7

override fun retrieveTooltipTag(isReadOnlyContext: Boolean): String = TooltipTag.MAIN_HELP

override fun prepare(data: ActionData) {
super.prepare(data)
if (data.get(Context::class.java) == null) {
markInvisible()
}
}

override suspend fun execAction(data: ActionData): Any {
val context = data.get(Context::class.java) ?: return false
val intent =
Intent(context, HelpActivity::class.java).apply {
putExtra(CONTENT_KEY, context.getString(string.docs_url))
putExtra(CONTENT_TITLE_KEY, context.getString(string.back_to_cogo, context.getString(string.app_name)))
}
context.startActivity(intent)
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DeepLinkActivity : Activity() {
// URI is looked at, and reordering it just to enrich a metric would put parsing ahead of
// the check that exists to stop this activity acting on anything at all.
analyticsManager.trackDeepLink(DeepLinkMetric(DeepLinkDepth.UNKNOWN, DeepLinkOutcome.SETUP_INCOMPLETE))
Toast.makeText(this, getString(string.msg_deeplink_setup_incomplete), Toast.LENGTH_LONG).show()
Toast.makeText(this, getString(string.msg_deeplink_setup_incomplete, getString(string.app_name)), Toast.LENGTH_LONG).show()
// FLAG_ACTIVITY_NEW_TASK, matching the success branch below. A sender that starts this
// trampoline without it -- an in-app WebView host, another app's explicit intent, `am start`
// -- puts this activity in the *caller's* task, and an unflagged start here would run the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import com.itsaky.androidide.utils.dpToPx
import com.itsaky.androidide.utils.flashError
import com.itsaky.androidide.utils.flashMessage
import com.itsaky.androidide.utils.getOrStoreInitialPadding
import com.itsaky.androidide.utils.getStringWithAppName
import com.itsaky.androidide.utils.isAtLeastR
import com.itsaky.androidide.utils.isDeepLinkTargetOfOpenProject
import com.itsaky.androidide.viewmodel.ApkInstallationViewModel
Expand Down Expand Up @@ -1482,7 +1483,7 @@ abstract class BaseEditorActivity :
newMaterialDialogBuilder(this)
.setPositiveButton(android.R.string.ok, null)
.setTitle(string.title_first_build)
.setMessage(string.msg_first_build)
.setMessage(getString(string.msg_first_build, getString(string.app_name)))
.setCancelable(false)
.create()
.show()
Expand Down Expand Up @@ -1879,7 +1880,7 @@ abstract class BaseEditorActivity :
val indentChild = 140

fun appendHierarchicalText(textRes: Int) {
val text = getString(textRes)
val text = getStringWithAppName(textRes, getString(string.app_name))
text.split("\n").forEach { line ->
val trimmed = line.trimStart()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ abstract class ProjectHandlerActivity :
}

QuickBuildNotice.RELOAD_CRASHED -> {
flashError(getString(string.quick_build_reload_crashed))
flashError(getString(string.quick_build_reload_crashed, getString(string.app_name)))
}

QuickBuildNotice.RELINK_STUCK -> {
Expand Down Expand Up @@ -703,7 +703,7 @@ abstract class ProjectHandlerActivity :
QuickBuildClobberConfirmation.NeededForUnknownAppId -> {
awaitBuildTypeSwitchConfirmation(
getString(string.quick_build_switch_unknown_app_title),
getString(string.quick_build_switch_unknown_app_message),
getString(string.quick_build_switch_unknown_app_message, getString(string.app_name)),
)
}

Expand Down Expand Up @@ -1073,7 +1073,7 @@ abstract class ProjectHandlerActivity :
private suspend fun confirmUnknownOccupantSwitch(): Boolean =
awaitBuildTypeSwitchConfirmation(
getString(string.quick_build_switch_unknown_app_title),
getString(string.quick_build_switch_unknown_app_message),
getString(string.quick_build_switch_unknown_app_message, getString(string.app_name)),
)

private fun projectRealApplicationId(): String? {
Expand Down Expand Up @@ -1203,7 +1203,7 @@ abstract class ProjectHandlerActivity :
}.onFailure { error ->
flashError(
if (error is PluginStillLoadedException) {
getString(string.msg_plugin_install_still_loaded, error.pluginId)
getString(string.msg_plugin_install_still_loaded, error.pluginId, getString(string.app_name))
} else {
getString(
string.msg_plugin_install_failed,
Expand Down Expand Up @@ -2548,19 +2548,35 @@ abstract class ProjectHandlerActivity :
?: (result.cause as? SocketException?).let { err ->
val msg = err?.message ?: ""
when {
msg.contains("EPERM") -> getString(string.debugger_error_errno_eperm)
msg.contains("ECONNREFUSED") -> getString(string.debugger_error_errno_econnrefused)
else -> null
msg.contains("EPERM") -> {
getString(string.debugger_error_errno_eperm, getString(string.app_name))
}

msg.contains("ECONNREFUSED") -> {
getString(string.debugger_error_errno_econnrefused, getString(string.app_name))
}

else -> {
null
}
}
}
?: (result.cause as? ErrnoException? ?: result.cause?.cause as? ErrnoException?)?.let { err ->
when (err.errno) {
OsConstants.EPERM -> getString(string.debugger_error_errno_eperm)
OsConstants.ECONNREFUSED -> getString(string.debugger_error_errno_econnrefused)
else -> getString(R.string.debugger_error_errno, err.errno)
OsConstants.EPERM -> {
getString(string.debugger_error_errno_eperm, getString(string.app_name))
}

OsConstants.ECONNREFUSED -> {
getString(string.debugger_error_errno_econnrefused, getString(string.app_name))
}

else -> {
getString(R.string.debugger_error_errno, err.errno)
}
}
}
?: getString(R.string.debugger_error_debugger_startup_failure)
?: getString(R.string.debugger_error_debugger_startup_failure, getString(R.string.app_name))

append(msg)
append(System.lineSeparator())
Expand All @@ -2570,7 +2586,7 @@ abstract class ProjectHandlerActivity :
append(System.lineSeparator())
}

append(getString(R.string.debugger_error_suggestion_network_restriction))
append(getString(R.string.debugger_error_suggestion_network_restriction, getString(R.string.app_name)))
}

withContext(Dispatchers.Main) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.itsaky.androidide.R
import com.itsaky.androidide.databinding.LayoutOnboardingPermissionItemBinding
import com.itsaky.androidide.models.OnboardingPermissionItem
import com.itsaky.androidide.utils.dpToPx
import com.itsaky.androidide.utils.getStringWithAppName

/**
* @author Akash Yadav
Expand Down Expand Up @@ -68,7 +69,7 @@ class OnboardingPermissionsAdapter(

binding.infoContent.apply {
title.setText(permission.title)
description.setText(permission.description)
description.setText(context.getStringWithAppName(permission.description, context.getString(R.string.app_name)))
title.setTextColor(if (permission.isSupportedOnDevice) holder.titleColor else holder.disabledTitleColor)
description.setTextColor(if (permission.isSupportedOnDevice) holder.descriptionColor else holder.disabledDescriptionColor)
}
Expand Down
Loading
Loading