[PR #1563] [MERGED] [Linked fields] Add Linked Field as a custom field type #2964

Closed
opened 2025-11-26 23:26:30 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1563
Author: @eliykat
Created: 10/6/2021
Status: Merged
Merged: 11/8/2021
Merged by: @eliykat

Base: masterHead: linked-fields


📝 Commits (10+)

  • 3d60506 Add linked fields support
  • 1314ddd Fix style, don't show linked field if Secure Note
  • f4f2a8b Undo changes to adding custom field
  • a805eba Finish basic linked fields for Login
  • 3ea35e6 Fix i18n keys on all Linked Fields
  • a77ea0f Use Field.LinkedId to store linked field info
  • b7f97f4 Fix null handling
  • d0f3ef2 Reset Linked Custom Fields if cipherType changes
  • 021384e Reset AndroidManifest.xml
  • 8813ac9 Fix style

📊 Changes

20 files changed (+263 additions, -30 deletions)

View changed files

📝 src/App/Pages/Vault/AddEditPage.xaml (+10 -0)
📝 src/App/Pages/Vault/AddEditPageViewModel.cs (+55 -9)
📝 src/App/Pages/Vault/ViewPage.xaml (+6 -0)
📝 src/App/Pages/Vault/ViewPageViewModel.cs (+26 -2)
📝 src/App/Resources/AppResources.Designer.cs (+15 -1)
📝 src/App/Resources/AppResources.resx (+6 -0)
📝 src/Core/Enums/FieldType.cs (+2 -1)
src/Core/Enums/LinkedIdType.cs (+38 -0)
📝 src/Core/Models/Api/FieldApi.cs (+1 -0)
📝 src/Core/Models/Data/FieldData.cs (+2 -0)
📝 src/Core/Models/Domain/Field.cs (+6 -2)
📝 src/Core/Models/Request/CipherRequest.cs (+2 -1)
📝 src/Core/Models/View/CardView.cs (+17 -2)
📝 src/Core/Models/View/CipherView.cs (+13 -5)
📝 src/Core/Models/View/FieldView.cs (+2 -0)
📝 src/Core/Models/View/IdentityView.cs (+30 -2)
src/Core/Models/View/ItemView.cs (+14 -0)
📝 src/Core/Models/View/LoginView.cs (+12 -2)
📝 src/Core/Models/View/SecureNoteView.cs (+4 -2)
📝 src/Core/Services/CipherService.cs (+2 -1)

📄 Description

Objective

Mobile implementation of https://github.com/bitwarden/browser/pull/1963.

Short version:

  • this adds a new custom field type called "Linked". It "links" the value of a custom field to a default field, so that (in browser) you can effectively autofill a default field using a custom selector.
  • mobile does not autofill custom fields, so the changes here are just to allow the configuration of custom linked fields.

Code changes

These changes follow the same patterns as Angular clients unless noted otherwise.

  • src/Core/Models/View/ItemView.cs: new base class for all item types.
  • src/Core/Enums/LinkedIdType.cs: enum containing the saved values for linked fields (in browser, these are used to associate it with the property it's linked to). In Typescript I could use a separate enum for each cipher type to avoid clashing enum keys, but I couldn't figure out how to make that play nice with C#'s type system. Instead it's just one big enum with prefixes on each key.
  • LoginView, CardView, IdentityView, SecureNoteView: add LinkedFieldOptions, which is just a getter containing the LinkedIds and i18n keys for that cipher type. Secure Notes don't support linked fields so that just returns null, which we test for where required.
    • This is a simpler approach than the Angular clients because we don't have to care about autofilling custom fields
  • Field models (various): add LinkedId property
  • AddEditPage: add the new type when adding a new custom field. It uses a wheel selector to allow you to select from the LinkedFieldOptions.
  • ViewPage: if it's a linked field, display a little "link" symbol next to its value to indicate that it's a pointer and not a literal value

Screenshots

Screen Shot 2021-10-06 at 4 35 32 pm

Screen Shot 2021-10-06 at 4 35 46 pm

Screen Shot 2021-10-06 at 4 35 50 pm


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1563 **Author:** [@eliykat](https://github.com/eliykat) **Created:** 10/6/2021 **Status:** ✅ Merged **Merged:** 11/8/2021 **Merged by:** [@eliykat](https://github.com/eliykat) **Base:** `master` ← **Head:** `linked-fields` --- ### 📝 Commits (10+) - [`3d60506`](https://github.com/bitwarden/android/commit/3d60506885e00575260ec7c5ad5eacf660c6d5e5) Add linked fields support - [`1314ddd`](https://github.com/bitwarden/android/commit/1314ddd313f5553872097ff2c26c908b29b3acf0) Fix style, don't show linked field if Secure Note - [`f4f2a8b`](https://github.com/bitwarden/android/commit/f4f2a8b862a0cee7cc61fc2a0fd80e86c7c7200e) Undo changes to adding custom field - [`a805eba`](https://github.com/bitwarden/android/commit/a805eba5be18868517d0164b2f4d65e83226532b) Finish basic linked fields for Login - [`3ea35e6`](https://github.com/bitwarden/android/commit/3ea35e679824c2f325d81e141ddc4ef3f83810c9) Fix i18n keys on all Linked Fields - [`a77ea0f`](https://github.com/bitwarden/android/commit/a77ea0fc2279e042a2a0dc040c400ad8b1ed77d5) Use Field.LinkedId to store linked field info - [`b7f97f4`](https://github.com/bitwarden/android/commit/b7f97f4ba79742a1877a6798c73d8840cde8433f) Fix null handling - [`d0f3ef2`](https://github.com/bitwarden/android/commit/d0f3ef2083995276fcb48518d1e38e4bc7f7504b) Reset Linked Custom Fields if cipherType changes - [`021384e`](https://github.com/bitwarden/android/commit/021384ec904a209144db7c9ce6b4e66a31eaecca) Reset AndroidManifest.xml - [`8813ac9`](https://github.com/bitwarden/android/commit/8813ac9f620527c135b9035835d9a72bb95dd5c5) Fix style ### 📊 Changes **20 files changed** (+263 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `src/App/Pages/Vault/AddEditPage.xaml` (+10 -0) 📝 `src/App/Pages/Vault/AddEditPageViewModel.cs` (+55 -9) 📝 `src/App/Pages/Vault/ViewPage.xaml` (+6 -0) 📝 `src/App/Pages/Vault/ViewPageViewModel.cs` (+26 -2) 📝 `src/App/Resources/AppResources.Designer.cs` (+15 -1) 📝 `src/App/Resources/AppResources.resx` (+6 -0) 📝 `src/Core/Enums/FieldType.cs` (+2 -1) ➕ `src/Core/Enums/LinkedIdType.cs` (+38 -0) 📝 `src/Core/Models/Api/FieldApi.cs` (+1 -0) 📝 `src/Core/Models/Data/FieldData.cs` (+2 -0) 📝 `src/Core/Models/Domain/Field.cs` (+6 -2) 📝 `src/Core/Models/Request/CipherRequest.cs` (+2 -1) 📝 `src/Core/Models/View/CardView.cs` (+17 -2) 📝 `src/Core/Models/View/CipherView.cs` (+13 -5) 📝 `src/Core/Models/View/FieldView.cs` (+2 -0) 📝 `src/Core/Models/View/IdentityView.cs` (+30 -2) ➕ `src/Core/Models/View/ItemView.cs` (+14 -0) 📝 `src/Core/Models/View/LoginView.cs` (+12 -2) 📝 `src/Core/Models/View/SecureNoteView.cs` (+4 -2) 📝 `src/Core/Services/CipherService.cs` (+2 -1) </details> ### 📄 Description ## Objective Mobile implementation of https://github.com/bitwarden/browser/pull/1963. Short version: * this adds a new custom field type called "Linked". It "links" the value of a custom field to a default field, so that (in browser) you can effectively autofill a default field using a custom selector. * mobile does not autofill custom fields, so the changes here are just to allow the configuration of custom linked fields. ## Code changes These changes follow the same patterns as Angular clients unless noted otherwise. * **src/Core/Models/View/ItemView.cs**: new base class for all item types. * **src/Core/Enums/LinkedIdType.cs**: enum containing the saved values for linked fields (in browser, these are used to associate it with the property it's linked to). In Typescript I could use a separate enum for each cipher type to avoid clashing enum keys, but I couldn't figure out how to make that play nice with C#'s type system. Instead it's just one big enum with prefixes on each key. * **LoginView, CardView, IdentityView, SecureNoteView**: add `LinkedFieldOptions`, which is just a getter containing the LinkedIds and i18n keys for that cipher type. Secure Notes don't support linked fields so that just returns null, which we test for where required. * This is a simpler approach than the Angular clients because we don't have to care about autofilling custom fields * **Field models (various)**: add `LinkedId` property * **AddEditPage**: add the new type when adding a new custom field. It uses a wheel selector to allow you to select from the `LinkedFieldOptions`. * **ViewPage**: if it's a linked field, display a little "link" symbol next to its value to indicate that it's a pointer and not a literal value ## Screenshots ![Screen Shot 2021-10-06 at 4 35 32 pm](https://user-images.githubusercontent.com/31796059/136152537-a0562925-6ae1-4dba-88d4-a57064ca44da.png) ![Screen Shot 2021-10-06 at 4 35 46 pm](https://user-images.githubusercontent.com/31796059/136152548-f081bad0-eada-4b35-8e46-90b338da39ad.png) ![Screen Shot 2021-10-06 at 4 35 50 pm](https://user-images.githubusercontent.com/31796059/136152556-7db1383b-1803-4021-bc6d-9f190cadca37.png) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:26:30 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#2964