Skip to content

Add device name editing along with device model - #3111

Closed
audriu wants to merge 1 commit into
BasedHardware:mainfrom
audriu:2824-rename-my-Omi-device
Closed

audriu wants to merge 1 commit into
BasedHardware:mainfrom
audriu:2824-rename-my-Omi-device

Conversation

@audriu

@audriu audriu commented Oct 5, 2025 •

Copy link
Copy Markdown
Contributor

Device Rename Feature - Summary of Changes

Fixes #2824

Overview

This PR implements the ability for users to rename their Omi device after connection. The custom "Device Name" is stored in local storage and persists across app sessions. The app now distinguishes between:

  • Device Name: User's custom name (editable, defaults to Product Name)
  • Product Name: Original Bluetooth device name (read-only, from BT messages)

Both are displayed throughout the app, with the custom Device Name shown prominently while preserving the original Product Name for reference.

Key Distinction

Before This PR:

  • Only showed "Product Name" from Bluetooth device
  • No way to personalize device identification
  • Example: Always shows "Omi DevKit" or "Friend"

After This PR:

  • Device Name (top display): User's custom name → Falls back to Product Name if not set
    • Example: "My Work Omi" (custom) or "Omi DevKit" (default)
  • Product Name (info section): Original Bluetooth name from device
    • Example: Always shows "Omi DevKit" or "Friend" (from BT messages)

This allows users to personalize their device while maintaining technical reference to the actual product.

Features Added

1. Custom Device Name Storage

  • Custom device names are stored per device ID in SharedPreferences
  • Names persist across app restarts and device reconnections
  • Support for multiple devices with unique custom names
  • Automatic cleanup when device is unpaired
  • Defaults to Product Name if not set by user

2. Device Rename UI

  • Added edit functionality in Device Settings page
  • Added edit functionality in Home Device page (two locations):
    • Main device title (with edit icon)
    • Device Name row in info section (with arrow)
  • Cross-platform dialog (iOS/Android) for renaming
  • Input validation to prevent empty names
  • Success feedback on save
  • Immediate UI refresh after renaming

3. Display Name Integration

  • Top-level displays (home screen, device title) use custom Device Name
  • Device info sections show both Device Name (custom) and Product Name (original)
  • Product Name always shows the original Bluetooth device name from BT messages
  • Seamless fallback to original Product Name if no custom name exists
  • Consistent user experience across all screens

Files Modified

app/lib/backend/preferences.dart

Changes:

  • Added setCustomDeviceName(String deviceId, String customName) method
  • Added getCustomDeviceName(String deviceId) method
  • Added clearCustomDeviceName(String deviceId) method

Purpose: Store and retrieve custom device names per device ID in local storage

app/lib/backend/schema/bt_device/bt_device.dart

Changes:

  • Added getDisplayName() method to BtDevice class

Purpose: Provides a unified method to get the display name (custom name if set, otherwise original device name)

app/lib/pages/settings/change_device_name_widget.dart (NEW FILE)

Changes:

  • Created new widget for device rename dialog
  • Platform-specific UI (iOS: CupertinoAlertDialog, Android: AlertDialog)
  • Input validation and error handling
  • Success notification on save

Purpose: Provides the UI for users to rename their device

app/lib/pages/settings/device_settings.dart

Changes:

  • Added import for change_device_name_widget.dart
  • Made "Device Name" field tappable with edit icon (shows custom name)
  • Added "Product Name" field (read-only, shows original BT device name)
  • Updated to use getDisplayName() method for Device Name
  • Added custom name cleanup on disconnect/unpair

Purpose: Integrate rename functionality into device settings, display both Device Name and Product Name, and ensure cleanup on device removal

app/lib/pages/home/device.dart

Changes:

  • Added import for change_device_name_widget.dart
  • Made main device title tappable with edit icon (shows rename dialog)
  • Made "Device Name" row in info section tappable with arrow (shows rename dialog)
  • Updated top-level device displays to use getDisplayName() method
  • Added "Device Name" field in info section (shows custom name via getDisplayName())
  • Restored "Product Name" field to show original device.name from BT
  • Added custom name cleanup on unpair
  • Both edit points trigger setState to refresh UI immediately

Purpose: Display custom device name prominently while preserving original product name for reference, and provide easy access to rename functionality

Technical Implementation

Storage Strategy

// Store custom name with device ID as key
SharedPreferencesUtil().setCustomDeviceName(deviceId, customName);

// Retrieve custom name for device
String customName = SharedPreferencesUtil().getCustomDeviceName(deviceId);

// Clear custom name on unpair
SharedPreferencesUtil().clearCustomDeviceName(deviceId);

Display Logic

// In BtDevice class
String getDisplayName() {
  final customName = SharedPreferencesUtil().getCustomDeviceName(id);
  if (customName.isNotEmpty) {
    return customName;
  }
  return name; // Falls back to original Product Name
}

Usage Throughout App

// Top-level displays (title, home screen)
Text(device.getDisplayName())  // Shows custom name or Product Name

// Device info sections show both:
'Device Name': device.getDisplayName()  // Custom name (editable)
'Product Name': device.name             // Original BT name (read-only)

User Flow

  1. Setting a Custom Name:

    • Option A - From Device Settings:
      • User navigates to Settings → Device Settings
      • Taps on "Device Name" row (shows edit icon)
    • Option B - From Home Device Page:
      • User navigates to the device page
      • Taps on the main device title (shows edit icon next to name)
      • OR taps on "Device Name" row in info section (shows arrow)
    • Both options:
      • Enter desired name in dialog
      • Save and see confirmation message
      • Custom name immediately reflects throughout the app
  2. Viewing Custom Name:

    • Home screen shows custom Device Name prominently
    • Device info page shows both:
      • Device Name: Custom name (or Product Name if not set)
      • Product Name: Original Bluetooth device name
    • Device settings shows both Device Name and Product Name
    • Title and main displays use Device Name (custom or default)
    • Product Name always preserved from original BT messages
  3. Persistence:

    • Custom name survives app restarts
    • Custom name persists through disconnect/reconnect cycles
    • Custom name is cleared only when device is unpaired
  4. Multiple Devices:

    • Each device can have its own unique custom name
    • Names are stored per device ID
    • No conflicts between multiple paired devices

Testing Recommendations

Manual Testing Checklist

  • Connect an Omi device
  • Test Device Settings rename:
    • Navigate to Device Settings
    • Tap "Device Name" and rename device
    • Verify name updates in Device Settings
  • Test Home Device page rename (title):
    • Navigate to Device page
    • Tap on main device title (with edit icon)
    • Rename device
    • Verify name updates immediately
  • Test Home Device page rename (info section):
    • Tap on "Device Name" row in info section
    • Rename device
    • Verify name updates immediately
  • Verify name updates on Home screen
  • Verify "Product Name" still shows original BT name
  • Disconnect device
  • Reconnect device
  • Verify custom name persists
  • Close and restart app
  • Verify custom name persists after restart
  • Unpair device
  • Reconnect same device
  • Verify custom name is shown
  • Set new custom name from each location
  • Test with multiple devices (if available)

Edge Cases to Test

  • Empty name input (should show error)
  • Very long device names (50+ characters)
  • Special characters in device names
  • Spaces and emojis in device names
  • Switching between multiple paired devices

@aaravgarg

Copy link
Copy Markdown
Contributor

ready for review?

@aaravgarg

Copy link
Copy Markdown
Contributor

pls attach a demo showing the functionality @audriu

@audriu

audriu commented Oct 6, 2025

Copy link
Copy Markdown
Contributor Author
Screen_Recording_20251006_084243_Omi.Dev.mp4

Please see attached.

@aaravgarg

aaravgarg commented Oct 6, 2025 •

Copy link
Copy Markdown
Contributor

Screen_Recording_20251006_084243_Omi.Dev.mp4
Please see attached.

Where are you storing the name of device?

I see no firmware changes

@audriu

audriu commented Oct 6, 2025

Copy link
Copy Markdown
Contributor Author

For now, this only stores the device name in the app so users can manage the names of their Omi devices locally.

@aaravgarg

Copy link
Copy Markdown
Contributor

But what if I connect through a new phone?

It should store in local onboard storage of omi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rename my Omi device ($300)

2 participants