Mobile Development 17 min read

Meta-Life Data Hub on HarmonyOS 6: Share Kit, Anti-Peep & Light Field UI Implementation

The Xiangji app, rebuilt on HarmonyOS 6, demonstrates how Share Kit enables cross-device metadata sharing, Device Security Kit provides automatic anti-peep privacy protection, UI Design Kit delivers light field visual effects, and HdsNavigation simplifies responsive navigation—together forming a meta-life data hub that transcends traditional file management.

51CTO HarmonyOS Developer Community
51CTO HarmonyOS Developer Community
51CTO HarmonyOS Developer Community
Meta-Life Data Hub on HarmonyOS 6: Share Kit, Anti-Peep & Light Field UI Implementation

Project Background and Positioning

The Xiangji (响记) application, originally a university graduation project, was rebuilt on HarmonyOS 6 and won the HarmonyOS incentive award and innovation scene award. The app positions itself as a "meta-life data transfer station and memory bank" , moving beyond traditional file managers like Documents. Unlike conventional file-container logic that requires manual upload of PDFs or Word documents, Xiangji handles heterogeneous metadata — web links, temporary images, voice memos — without format conversion, creating a closed loop of collect–organize–share .

Core Differentiation: Metadata vs. File Containers

Traditional file managers focus on CRUD and classification of files, forcing users to convert scattered information into files (screenshots, copy-paste) before management. Xiangji leverages HarmonyOS system-level sharing (tap-to-share, drag-and-drop, AirDrop-like transfer) to act as a universal data hub. Users share any data type directly into Xiangji via the system share sheet, eliminating context switching between apps for annotation, scheduling, or forwarding.

Technical Implementation: Share Kit as Data Backbone

System Share Handling

All sharing flows — same-device app-to-app, cross-device tap-to-share (碰一碰), and proximity-based AirDrop (隔空传送) — rely on the unified systemShare.SharedData structure. The app registers supported data types in src/main/module.json5 under skills:

"abilities": [
  {
    "name": "EntryAbility",
    "srcEntry": "./ets/entryability/EntryAbility.ets",
    "skills": [
      {
        "actions": ["ohos.want.action.sendData"],
        "uris": [
          {"scheme": "file", "utd": "general.text", "maxFileSupported": 1},
          {"scheme": "file", "utd": "general.png", "maxFileSupported": 1},
          {"scheme": "file", "utd": "general.jpeg", "maxFileSupported": 1}
        ]
      }
    ]
  }
]

On launch, the UIAbility processes incoming Want parameters via systemShare.getSharedData(want), converting each SharedData record into the app's internal SelfSaveData model. The conversion distinguishes plain text (handled by solvePlainTextData) from other types ( solveData), with error logging via BusinessError.

import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { systemShare } from '@kit.ShareKit';
import { BusinessError } from '@kit.BasicServicesKit';

export default class EntryAbility extends UIAbility {
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    solveSharedData(want);
  }
}

function solveSharedData(want: Want) {
  let srRecords: systemShare.SharedData = await systemShare.getSharedData(want);
  let res: Array<SelfSaveData> = [];
  try {
    for (let srr of srRecords) {
      let m: SelfSaveData = new SelfSaveData();
      let utd = srr.getType();
      if (uniformTypeDescriptor.getTypeDescriptor(utd).belongsTo(uniformTypeDescriptor.UniformDataType.PLAIN_TEXT)) {
        m.solvePlainTextData(...);
      } else {
        m.solveData(...);
      }
      res.push(m);
    }
    console.warn(`sharedRecord to selfSaveData add success len:${res.length}`);
  } catch (e) {
    console.error(`sharedRecord to selfSaveData failed:${JSON.stringify(e as BusinessError)}`);
  }
  return res;
}
System share handling effect
System share handling effect

Cross-Device Tap-to-Share (Phone ↔ PC/2-in-1)

HarmonyOS 6 extends Share Kit with harmonyShare for PC/2-in-1 reception. The receiver registers a dataReceive listener, declares supported UTDs (OBJECT, FILE) with high counts, and processes incoming SharedData using the same conversion logic:

import { uniformTypeDescriptor as utd } from '@kit.ArkData';
import { systemShare, harmonyShare } from '@kit.ShareKit';
import { common } from '@kit.AbilityKit';

export async function harmonyShareDataReceive(windowClass: window.Window) {
  if (canIUse("SystemCapability.Collaboration.HarmonyShare") && deviceInfo.deviceType == "2in1") {
    harmonyShare.on('dataReceive', {
      windowId: windowClass.getWindowProperties().id,
      capabilities: [
        { utd: uniformTypeDescriptor.UniformDataType.OBJECT, maxSupportedCount: 999 },
        { utd: uniformTypeDescriptor.UniformDataType.FILE, maxSupportedCount: 999 }
      ]
    }, (receivableTarget: harmonyShare.ReceivableTarget) => {
      receivableTarget.receive(fileUri.getUriFromPath(globalContext.getContext().filesDir), {
        onDataReceived: (srRecords: systemShare.SharedData) => {
          // same conversion logic as above
        },
        onResult: (resultCode: harmonyShare.ShareResultCode) => {}
      });
    });
  }
}
Cross-device tap-to-share effect
Cross-device tap-to-share effect

Device Security Kit: Automatic Anti-Peep Protection

Traditional privacy modes rely on passive password gates. Xiangji integrates dlpAntiPeep from Device Security Kit to actively detect shoulder-surfing and blur sensitive content. The implementation checks the system switch, subscribes to dlpAntiPeep events, and applies a custom mask layer on the window when DlpAntiPeepStatus.HIDE fires:

import { dlpAntiPeep } from '@kit.DeviceSecurityKit';
import { window } from '@kit.ArkUI';
import { common } from '@kit.AbilityKit';

export function openDlp(uIContext: UIContext) {
  if (canIUse("SystemCapability.Security.DlpAntiPeep")) {
    try {
      dlpAntiPeep.isDlpAntiPeepSwitchOn().then((value) => {
        if (value) {
          dlpAntiPeep.on('dlpAntiPeep', async (dlpAntiPeepStatus: dlpAntiPeep.DlpAntiPeepStatus) => {
            if (dlpAntiPeepStatus == dlpAntiPeep.DlpAntiPeepStatus.HIDE) {
              try {
                let windowClass: window.Window = await window.getLastWindow(uIContext);
                let windowId: number = windowClass.getWindowProperties().id;
                await dlpAntiPeep.setAntiPeepMaskLayer(windowId);
              } catch (error) {
                console.error(`setAntiPeepMaskLayer failed. error code is ${JSON.stringify(error)}`);
              }
            }
          });
        }
      }).catch((err: BusinessError) => {
        console.error(`isDlpAntiPeepSwitchOn fialed catch:`, JSON.stringify(err));
      });
    } catch (err) {
      console.error(`isDlpAntiPeepSwitchOn fialed`, JSON.stringify(err));
    }
  }
}
Anti-peep effect
Anti-peep effect

This adds proactive privacy with only dozens of lines, reducing development cost while guarding data in real time.

UI Design Kit: Light Field Visual Effects

HarmonyOS 6's UI Design Kit introduces hdsEffect for point-light illumination. Xiangji uses PointLightIlluminatedType and PointLightSourceType to toggle border-only vs. border-plus-content glow and bright vs. none source states, creating immersive feedback on interactive elements:

import { hdsEffect } from '@kit.UIDesignKit';

@State isLight_0: boolean = false;

build() {
  Column() {
    Stack() {
      SymbolGlyph($r("sys.symbol.ohos_photo"))
        .fontSize(24)
    }
    .hoverEffect(HoverEffect.Highlight)
    .width(40)
    .height(40)
    .borderRadius(20)
    .backgroundBlurStyle(BlurStyle.Thin)
    .onClick(() => {})
    .visualEffect(new hdsEffect.HdsEffectBuilder()
      .pointLight({
        illuminatedType: this.isLight_0 ? hdsEffect.PointLightIlluminatedType.BORDER_CONTENT : hdsEffect.PointLightIlluminatedType.BORDER,
        sourceType: this.isLight_0 ? hdsEffect.PointLightSourceType.BRIGHT : hdsEffect.PointLightSourceType.NONE
      })
      .buildEffect()
    )
  }
  .width('100%')
  .height('100%')
}
Light field visual effect
Light field visual effect

HdsNavigation: Responsive Navigation with Built-in Visuals

Multi-device adaptation traditionally requires separate navigation layouts per form factor. The HdsNavigation component from UI Design Kit provides out-of-the-box dynamic effects (flowing light), strict HarmonyOS Design System compliance (layered icons, Symbol resources, light/shadow), and configurable width ranges. Unlike the base Navigation component which demands custom title/tool bars, HdsNavigation exposes a titleBar property with scrollEffectOpts for gradient blur, transition blur, or standard blur — all cross-device consistent:

import { HdsNavigation, HdsNavigationAttribute, ScrollEffectType } from '@kit.UIDesignKit';
import { LengthMetrics } from '@kit.ArkUI';

@Entry
@Component
struct Index {
  build() {
    HdsNavigation() {
      // content area
    }.titleBar({
      style: {
        scrollEffectOpts: {
          enableScrollEffect: true,
          scrollEffectType: ScrollEffectType.GRADIENT_BLUR
        }
      },
      content: {
        title: { mainTitle: '主标题', subTitle: '子标题' }
      }
    })
  }
}
HdsNavigation dynamic blur effect
HdsNavigation dynamic blur effect

This cut Xiangji's multi-end navigation development cycle dramatically while delivering polished visuals.

Development Retrospective

The team concludes that premium UX stems not from disruptive features but from precise pain-point insight and microscopic technical refinements. HarmonyOS 6 kits — Device Security Kit, UI Design Kit, Share Kit — appear as independent modules, yet when fused with real scenarios they produce a compounding experience greater than the sum of parts. The OS absorbs complexity (cross-device transport, anti-peep detection, design-system-consistent components), freeing developers to polish user-facing details. This ecosystem model lowers entry barriers for small-to-medium apps, enabling a virtuous cycle of resource concentration on UX. Xiangji will continue deepening HarmonyOS integration, optimizing data-flow efficiency, privacy, and interaction granularity, believing every subtle technical refinement builds the foundation for ultimate user experience.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

HarmonyOS 6HdsNavigationanti-peep privacycross-device sharingDevice Security Kitmeta-life data hubShare KitUI Design Kit
51CTO HarmonyOS Developer Community
Written by

51CTO HarmonyOS Developer Community

The HarmonyOS Developer Community is a learning-oriented community for developers to learn, communicate, ask questions, and share.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.