05. Application Modules - shenjudev/UNIWatchMate-Android-Sample GitHub Wiki

5.1 Alarms

Reference: AlarmFragment.kt

  • Retrieve Alarm List

    • UNIWatchMate.wmApps.appAlarm.getAlarmList()
      • Retrieves the device alarm list.
  • Observe Alarm Modifications

    • UNIWatchMate.wmApps.appAlarm.observeAlarmList()
      • Listens for modifications to the device's alarms.
  • Update Alarm List

    • UNIWatchMate.wmApps.appAlarm.updateAlarmList()
      • Updates the entire alarm list on the device after deletion or modification.

5.2 Camera Function

Reference: CameraActivity.kt

  • Observe Camera Switching

    • UNIWatchMate.wmApps.appCamera.observeCameraFrontBack()
      • Listens for the device switching between front and back cameras.
  • Observe Flash Switching

    • UNIWatchMate.wmApps.appCamera.observeCameraFlash()
      • Listens for the device switching the flash.
  • Observe Camera Open State

    • UNIWatchMate.wmApps.appCamera.observeCameraOpenState()
      • Listens for device entering or exiting the camera remote control operation.
  • Start Camera Preview

    • UNIWatchMate.wmApps.appCamera.startCameraPreview()
      • Starts camera preview mode on the device.
  • Control Flash Icon Display

    • UNIWatchMate.wmApps.appCamera.cameraFlashSwitch()
      • Controls the flash icon display on the device interface.
  • Control Front/Back Camera Icon Display

    • UNIWatchMate.wmApps.appCamera.cameraBackSwitch()
      • Controls the front/back camera icon display on the device interface.
  • Update Camera Preview

    • UNIWatchMate.wmApps.appCamera.updateCameraPreview()
      • Uploads preview byte data.
  • Open/Close Camera Remote Controller Interface

    • UNIWatchMate.wmApps.appCamera.openCloseCamera()
      • Controls opening or closing the camera remote controller interface on the device.

5.3 Contacts

Reference: ContactsFragment.kt

  • Add Contacts Limit

    • A maximum of 100 contacts can be added.
  • Get Contact List

    • UNIWatchMate.wmApps.appContact.getContactList()
      • Retrieves the contact list on the device.
  • Update Contact List

    • UNIWatchMate.wmApps.appContact.updateContactList()
      • Updates the contact list, used for adding or deleting operations.

5.4 Emergency Contacts

Reference: EmergencyContactFragment.kt

  • Emergency Contact Setup

    • When the emergency contact switch is turned on, emergency contacts need to be set first.
  • Get Current Emergency Contacts

    • UNIWatchMate.wmApps.appContact.observableEmergencyContacts()
      • Retrieves current emergency contacts on the device.
  • Set Emergency Contacts

    • UNIWatchMate.wmApps.appContact.updateEmergencyContact()
      • Sets emergency contacts on the device.
  • WmEmergencyCall Class

    • Includes isEnabled for the emergency contact switch, and emergencyContacts for the emergency contact list.
class WmEmergencyCall(
    var isEnabled: Boolean, // Whether to enable emergency contact
    val emergencyContacts: MutableList<WmContact> // Emergency contacts list
) {}

5.5 Find Function

Reference: OtherFeaturesFragment.kt, MyApplication.kt

  • Find the Device

    • UNIWatchMate.wmApps.appFind.findWatch()
      • Activates the find function on the device.
  • Stop Finding the Device

    • UNIWatchMate.wmApps.appFind.stopFindWatch()
      • Deactivates the find function on the device.
  • Observe Find Phone

    • UNIWatchMate.wmApps.appFind.observeFindMobile()
      • Listens for find phone initiated by the device.
  • Stop Finding the Phone

    • UNIWatchMate.wmApps.appFind.stopFindMobile()
      • Controls the device to stop finding the phone.
  • Observe Stop Find Phone

    • UNIWatchMate.wmApps.appFind.observeStopFindMobile()
      • Listens for stopping find phone initiated by the device.

5.6 Weather Function

Reference: DeviceInfoFragment.kt, MyApplication.kt

  • Push Today's Weather

    • UNIWatchMate.wmApps.appWeather.pushTodayWeather()
      • Uploads today's weather to the device.
  • Push Next 7 Days' Weather

    • UNIWatchMate.wmApps.appWeather.pushSevenDaysWeather()
      • Uploads the next 7 days' weather to the device.
  • Observe Weather Requests

    • UNIWatchMate.wmApps.appWeather.observeWeather()
      • Listens for weather requests from the device.
UNIWatchMate.wmApps.appWeather.observeWeather.asFlow().collect {
    if (it.wmWeatherTime == WmWeatherTime.SEVEN_DAYS) {
        // Handle 7-day weather request
    } else if (it.wmWeatherTime == WmWeatherTime.TODAY) {
        // Handle today's weather request
    }
}

5.7 Sports Function

Reference: SportHomePageFragment.kt

  • Get Fixed Sports List

    • UNIWatchMate.wmApps.appSport.getFixedSportList()
      • Retrieves the fixed sports list from the device.
  • Get Installed Dynamic Sports List

    • UNIWatchMate.wmApps.appSport.getDynamicSportList()
      • Retrieves the installed dynamic sports list from the device.
  • Get Supported Sports List

    • UNIWatchMate.wmApps.appSport.getSupportSportList()
      • Retrieves the list of sports supported by the device.
  • Update Fixed Sports List

    • UNIWatchMate.wmApps.appSport.updateFixedSportList()
      • Updates the fixed sports list on the device after sorting.
  • Update Dynamic Sports List

    • UNIWatchMate.wmApps.appSport.updateDynamicSportList()
      • Updates the dynamic sports list on the device after adding or deleting.

5.8 Notification Function

Reference: DeviceInfoFragment.kt

  • Send Notifications
    • UNIWatchMate?.wmApps?.appNotification?.sendNotification()
      • Sends notifications to the device.

5.9 Dials

Reference: DialHomePageFragment.kt

  • Delete Dials

    • UNIWatchMate.wmApps.appDial.deleteDial(alarms[position])
      • Deletes dials from the device.
  • Sync Installed Dials List

    • UNIWatchMate.wmApps.appDial.syncDialList()
      • Syncs the installed dials list with the device.
  • Get Dial Cover

    • UNIWatchMate.wmApps.appDial.parseDialThumpJp
      • Retrieves the dial cover from the device.
  • Install Dials

    • Demonstrates transferring the dial cover, followed by the dial file to install dials.
// Example code for dial installation
val dialCoverArray = UNIWatchMate.wmApps.appDial.parseDialThumpJpg(dialPath)
// Add to list
coverList.add(File(coverPath))
dialList.add(File(dialPath))
// Transfer dial thumbnail
UNIWatchMate.wmTransferFile.startTransfer(FileType.DIAL_COVER, coverList).asFlow().collect {
    // Callback for successful transfer
    callBack.callBack(it)
}
// Transfer dial file
UNIWatchMate.wmTransferFile.startTransfer(FileType.DIAL, dialList).asFlow().collect {
    // Callback for successful transfer
    callBack.callBack(it)
}

5.10 Language

Reference: LanguageListFragment.kt

  • Set Device Language
    • UNIWatchMate.wmApps.appLanguage.setLanguage()
      • Sets the language of the device based on the selected option.
      UNIWatchMate.wmApps.appLanguage.setLanguage(wmLanguages[position]).await()
  • Sync Language List
    • UNIWatchMate.wmApps.appLanguage.syncLanguageList()
      • Retrieves the list of languages supported by the device and synchronizes it.

5.11 Music Control

Reference: MyApplication.kt

  • Observe Music Control Operations
    • UNIWatchMate.wmApps.appMusicControl.observableMusicControl()
      • Listens for music control operations initiated from the device, such as play, pause, next song, previous song, volume up, and volume down.
      enum class WmMusicControlType(val type: Byte) {
          PREV_SONG(0),
          NEXT_SONG(1),
          PLAY(2),
          PAUSE(3),
          VOLUME_UP(4),
          VOLUME_DOWN(5)
      }

5.12 Time Settings

Reference: DeviceFragment.kt

  • Set Device Time
    • UNIWatchMate.wmApps.appDateTime.setDateTime()
      • Sets the device's time to the current time. The SDK internally determines the time value if null is passed.
      UNIWatchMate.wmApps.appDateTime.setDateTime(null).await()

5.13 Widgets Setting

Reference: WidgetFragment

  • Set Device Widgets

    • UNIWatchMate.wmApps.appWidget.updateWidgetList(widgets: List<WmWidget>)
  • ObserveWidgetList

    • UNIWatchMate.wmApps.appWidget.observeWidgetList()
  • GetWidgetList

    • UNIWatchMate.wmApps.appWidget.getWidgetList()

5.14 PhoneCall Action

Reference: MyApplication

  • observePhoneHangUp

    • UNIWatchMate.wmApps.appPhone.observePhoneHangUp
  • sendPhoneCallAction

    • UNIWatchMate.wmApps.appPhone.sendPhoneCallAction(action = AbAppPhone.PhoneAction.CALL)

5.15 Map Navigation

5.16 Muslim

Reference: MuslimWorshipActivity.kt, NameOfAllahActivity, TasbihReminderActivity

  • getAllAhList

    • UNIWatchMate.wmApps.appMuslim.getAllAhList()
  • observeAllahList

    • UNIWatchMate.wmApps.appMuslim.observeAllahList()
  • updateAllahList

    • UNIWatchMate.wmApps.appMuslim.updateAllahList(allahCollect: WmAllahCollect)
  • getPrayReminder

    • UNIWatchMate.wmApps.appMuslim.getPrayReminder
  • setPrayReminder

    • UNIWatchMate.wmApps.appMuslim.setPrayReminder(wmPrayReminder: WmPrayReminder)
  • observePrayReminder

    • UNIWatchMate.wmApps.appMuslim.observePrayReminder
  • getRosaryReminder

    • UNIWatchMate.wmApps.appMuslim.getRosaryReminder
  • setRosaryReminder

    • UNIWatchMate.wmApps.appMuslim.setRosaryReminder(wmRosaryReminder: WmRosaryReminder)
  • setTimeCalculateType

    • UNIWatchMate.wmApps.appMuslim.setTimeCalculateType(calculateType: WmMuslimCalculateType)
  • getTimeCalculateType

    • UNIWatchMate.wmApps.appMuslim.getTimeCalculateType()
  • getPrayTimes

    • UNIWatchMate.wmApps.appMuslim.getPrayTimes(wmMuslimCalcParam: WmMuslimCalcParam)

5.17 QuickReply

Reference: MyApplication

  • observeQuickReply
    • UNIWatchMate.wmApps.appQuickReply.observeQuickReply
⚠️ **GitHub.com Fallback** ⚠️