Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6947bd2 authored by Qinmei Du's avatar Qinmei Du Committed by Android (Google) Code Review
Browse files

Merge "Update more options screen"

parents 8536574a 75dc9f71
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ class CredentialEntryUi(
  val userName: CharSequence,
  val displayName: CharSequence?,
  val icon: Icon?,
  val usageData: CharSequence?,
  // TODO: add last used.
) {
  companion object {
@@ -38,18 +39,21 @@ class CredentialEntryUi(
      var title: String? = null
      var subTitle: String? = null
      var icon: Icon? = null
      var usageData: String? = null

      items.forEach {
        if (it.hasHint(Entry.HINT_ICON)) {
          icon = it.icon
        } else if (it.hasHint(Entry.HINT_SUBTITLE)) {
        } else if (it.hasHint(Entry.HINT_SUBTITLE) && it.subType == null) {
          subTitle = it.text.toString()
        } else if (it.hasHint(Entry.HINT_TITLE)) {
          title = it.text.toString()
        } else if (it.hasHint(Entry.HINT_SUBTITLE) && it.subType == Slice.SUBTYPE_MESSAGE) {
          usageData = it.text.toString()
        }
      }
      // TODO: fail NPE more elegantly.
      return CredentialEntryUi(title!!, subTitle, icon)
      return CredentialEntryUi(title!!, subTitle, icon, usageData)
    }
  }
}
+18 −9
Original line number Diff line number Diff line
@@ -92,30 +92,38 @@ class CredentialManagerRepo(
      ProviderData(
        "com.google",
        listOf<Entry>(
          newEntry(1, "elisa.beckett@gmail.com", "Elisa Backett"),
          newEntry(2, "elisa.work@google.com", "Elisa Backett Work"),
          newEntry(1, "elisa.beckett@gmail.com", "Elisa Backett",
            "20 passwords and 7 passkeys saved"),
          newEntry(2, "elisa.work@google.com", "Elisa Backett Work",
            "20 passwords and 7 passkeys saved"),
        ),
        listOf<Entry>(
          newEntry(3, "Go to Settings", ""),
          newEntry(4, "Switch Account", ""),
          newEntry(3, "Go to Settings", "",
            "20 passwords and 7 passkeys saved"),
          newEntry(4, "Switch Account", "",
            "20 passwords and 7 passkeys saved"),
        ),
        null
      ),
      ProviderData(
        "com.dashlane",
        listOf<Entry>(
          newEntry(5, "elisa.beckett@dashlane.com", "Elisa Backett"),
          newEntry(6, "elisa.work@dashlane.com", "Elisa Backett Work"),
          newEntry(5, "elisa.beckett@dashlane.com", "Elisa Backett",
            "20 passwords and 7 passkeys saved"),
          newEntry(6, "elisa.work@dashlane.com", "Elisa Backett Work",
            "20 passwords and 7 passkeys saved"),
        ),
        listOf<Entry>(
          newEntry(7, "Manage Accounts", "Manage your accounts in the dashlane app"),
          newEntry(7, "Manage Accounts", "Manage your accounts in the dashlane app",
            "20 passwords and 7 passkeys saved"),
        ),
        null
      ),
      ProviderData(
        "com.lastpass",
        listOf<Entry>(
          newEntry(8, "elisa.beckett@lastpass.com", "Elisa Backett"),
          newEntry(8, "elisa.beckett@lastpass.com", "Elisa Backett",
            "20 passwords and 7 passkeys saved"),
        ),
        listOf<Entry>(),
        null
@@ -124,7 +132,7 @@ class CredentialManagerRepo(
    )
  }

  private fun newEntry(id: Int, title: String, subtitle: String): Entry {
  private fun newEntry(id: Int, title: String, subtitle: String, usageData: String): Entry {
    val slice = Slice.Builder(
      Entry.CREDENTIAL_MANAGER_ENTRY_URI, SliceSpec(Entry.VERSION, 1)
    )
@@ -134,6 +142,7 @@ class CredentialManagerRepo(
        Icon.createWithResource(context, R.drawable.ic_passkey),
        null,
        listOf(Entry.HINT_ICON))
      .addText(usageData, Slice.SUBTYPE_MESSAGE, listOf(Entry.HINT_SUBTITLE))
      .build()
    return Entry(
      id,
+2 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ class GetFlowUtils {
          title = credentialEntryUi.userName.toString(),
          subtitle = credentialEntryUi.displayName?.toString() ?: "Unknown display name",
          id = it.entryId,
          usageData = credentialEntryUi.usageData?.toString() ?: "Unknown usageData",
        )
      }
    }
@@ -99,6 +100,7 @@ class CreateFlowUtils {
          title = saveEntryUi.title.toString(),
          subtitle = saveEntryUi.subTitle?.toString() ?: "Unknown subtitle",
          id = it.entryId,
          usageData = saveEntryUi.usageData?.toString() ?: "Unknown usageData",
        )
      }
    }
+6 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ class SaveEntryUi(
  val title: CharSequence,
  val subTitle: CharSequence?,
  val icon: Icon?,
  val usageData: CharSequence?,
  // TODO: add
) {
  companion object {
@@ -38,18 +39,21 @@ class SaveEntryUi(
      var title: String? = null
      var subTitle: String? = null
      var icon: Icon? = null
      var usageData: String? = null

      items.forEach {
        if (it.hasHint(Entry.HINT_ICON)) {
          icon = it.icon
        } else if (it.hasHint(Entry.HINT_SUBTITLE)) {
        } else if (it.hasHint(Entry.HINT_SUBTITLE) && it.subType == null) {
          subTitle = it.text.toString()
        } else if (it.hasHint(Entry.HINT_TITLE)) {
          title = it.text.toString()
        } else if (it.hasHint(Entry.HINT_SUBTITLE) && it.subType == Slice.SUBTYPE_MESSAGE) {
          usageData = it.text.toString()
        }
      }
      // TODO: fail NPE more elegantly.
      return SaveEntryUi(title!!, subTitle, icon)
      return SaveEntryUi(title!!, subTitle, icon, usageData)
    }
  }
}
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ data class CreateOptionInfo(
  val title: String,
  val subtitle: String,
  val id: Int,
  val usageData: String
)

/** The name of the current screen. */
@@ -39,4 +40,5 @@ enum class CreateScreenState {
  PROVIDER_SELECTION,
  CREATION_OPTION_SELECTION,
  MORE_OPTIONS_SELECTION,
  MORE_OPTIONS_ROW_INTRO,
}
Loading