diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 3d10048afd7ddfd468be99b621caf8669ddddf09..2070f9634a477f7fee56b29f6c0425a91f66f7ac 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -46,6 +46,8 @@ export default class EntryAbility extends UIAbility { const bottomRectHeight = avoidAreaBottom.bottomRect.height; AppStorage.setOrCreate('topRectHeight', px2vp(topRectHeight)); AppStorage.setOrCreate('bottomRectHeight', px2vp(bottomRectHeight)); + let uiContext: UIContext | undefined = windowStage.getMainWindowSync().getUIContext() + AppStorage.setOrCreate('uiContext', uiContext); }); } diff --git a/entry/src/main/ets/utils/CustomFunction.ets b/entry/src/main/ets/utils/CustomFunction.ets index 94c12c592ed580bc8bae44c298b067c11be246a5..75499565666c798b9acf42b39dbdd85e4ffeb5f1 100644 --- a/entry/src/main/ets/utils/CustomFunction.ets +++ b/entry/src/main/ets/utils/CustomFunction.ets @@ -20,6 +20,7 @@ import { fileIo as fs, picker } from '@kit.CoreFileKit'; import { Constants } from '../common/Constants'; import { WebDownloadManager } from './WebDownloadManager'; import { hilog } from '@kit.PerformanceAnalysisKit'; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); /** * Copies a URI to the system clipboard. @@ -34,7 +35,7 @@ export function copyLink(uri: string) { hilog.error(0x000, Constants.TAG, JSON.stringify(err)); return; } - promptAction.showToast({ + uiContext!.getPromptAction().showToast({ message: $r('app.string.copy_success') }) }) @@ -60,14 +61,14 @@ export async function saveVideoToGallery( let documentPicker = new picker.DocumentViewPicker(context); documentPicker.save(documentSaveOptions).then(async (uris: Array) => { if (uris.length === 0) { - promptAction.showToast({ message: $r('app.string.user_cancelled_authorization') }) + uiContext!.getPromptAction().showToast({ message: $r('app.string.user_cancelled_authorization') }) return; } openDownloadDialog(); // open dialog const path = await webDownloadManager.start(Constants.INDEX_WEB_CONTROLLER, context.filesDir, uri); closeDownloadDialog(); // close dialog webDownloadManager.clearProgress(); - promptAction.showToast({ message: $r('app.string.download_success') }) + uiContext!.getPromptAction().showToast({ message: $r('app.string.download_success') }) const targetFile = fs.openSync(uris[0], fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); const sourceFile = fs.openSync(path, fs.OpenMode.READ_ONLY); let buf = new ArrayBuffer(1024);