From 58f813b45e5b153c6eb7513dbd17131b856fcb1d Mon Sep 17 00:00:00 2001 From: zwx1148770 Date: Fri, 18 Mar 2022 17:03:15 +0800 Subject: [PATCH] note update Signed-off-by: zwx1148770 --- OAT.xml | 2 + .../src/main/ets/default/CusDialogComp.ets | 202 ++++++++++++----- .../src/main/ets/default/FolderListComp.ets | 93 ++++---- .../src/main/ets/default/NoteContentComp.ets | 211 ++++++++++++------ .../ets/default/NoteContentCompPortrait.ets | 77 ++++--- .../src/main/ets/default/NoteListComp.ets | 100 +++++---- .../main/resources/base/element/color.json | 80 ------- .../main/resources/base/element/float.json | 136 ----------- .../ets/default/access/MediaLibraryAccess.ets | 82 +++++++ .../main/ets/default/baseUtil/DateUtil.ets | 4 +- .../default/baseUtil/FakerRdbStoreUtil.ets | 6 +- .../main/ets/default/baseUtil/FolderUtil.ets | 2 +- .../baseUtil/GlobalResourceManager.ets | 13 +- .../main/ets/default/baseUtil/LayoutUtil.ets | 2 +- .../src/main/ets/default/baseUtil/LogUtil.ets | 56 +---- .../main/ets/default/baseUtil/NoteUtil.ets | 13 +- .../ets/default/baseUtil/OperationUtils.ets | 95 ++++++++ .../ets/default/baseUtil/RdbStoreUtil.ets | 142 ++++++++++-- .../ets/default/constants/StyleConstants.ets | 1 + .../default/model/searchModel/SearchModel.ets | 4 +- product/pc/src/main/ets/MainAbility/app.ets | 8 +- .../main/resources/base/element/string.json | 30 ++- .../main/resources/en_US/element/string.json | 168 ++++++++++++++ .../main/resources/zh_CN/element/string.json | 168 ++++++++++++++ product/phone/src/main/config.json | 14 ++ product/phone/src/main/ets/AbilityStage.ts | 15 -- .../src/main/ets/MainAbility/MainAbility.ts | 31 ++- .../src/main/ets/MainAbility/WebViewUtil.ets | 35 +++ .../phone/src/main/ets/MainAbility/app.ets | 17 +- .../main/ets/MainAbility/pages/MyNoteHome.ets | 55 ++++- .../main/ets/MainAbility/pages/NoteHome.ets | 8 +- .../MainAbility/pages/NoteHomePortrait.ets | 4 +- .../main/resources/base/element/string.json | 12 + .../src/main/resources/base/media/search.svg | 2 +- .../main/resources/en_US/element/string.json | 168 ++++++++++++++ .../main/resources/rawfile/editor_style.css | 2 +- .../src/main/resources/rawfile/rich_editor.js | 12 +- .../main/resources/zh_CN}/element/string.json | 28 +++ product/tablet/src/main/config.json | 22 +- product/tablet/src/main/ets/AbilityStage.ts | 15 -- .../src/main/ets/MainAbility/MainAbility.ts | 37 +-- .../src/main/ets/MainAbility/WebViewUtil.ets | 2 +- .../tablet/src/main/ets/MainAbility/app.ets | 17 +- .../main/ets/MainAbility/pages/MyNoteHome.ets | 57 ++++- .../main/ets/MainAbility/pages/NoteHome.ets | 49 ++-- .../MainAbility/pages/NoteHomePortrait.ets | 4 +- .../main/resources/base/element/string.json | 14 +- .../src/main/resources/base/media/search.svg | 2 +- .../main/resources/en_US/element/string.json | 168 ++++++++++++++ .../main/resources/rawfile/editor_style.css | 2 +- .../src/main/resources/rawfile/rich_editor.js | 12 +- .../main/resources/zh_CN/element/string.json | 168 ++++++++++++++ signature/notes.p7b | Bin 0 -> 3426 bytes 53 files changed, 1980 insertions(+), 687 deletions(-) delete mode 100644 common/component/src/main/resources/base/element/color.json delete mode 100644 common/component/src/main/resources/base/element/float.json create mode 100644 common/utils/src/main/ets/default/access/MediaLibraryAccess.ets create mode 100644 common/utils/src/main/ets/default/baseUtil/OperationUtils.ets create mode 100644 product/pc/src/main/resources/en_US/element/string.json create mode 100644 product/pc/src/main/resources/zh_CN/element/string.json create mode 100644 product/phone/src/main/ets/MainAbility/WebViewUtil.ets create mode 100644 product/phone/src/main/resources/en_US/element/string.json rename {common/component/src/main/resources/base => product/phone/src/main/resources/zh_CN}/element/string.json (85%) create mode 100644 product/tablet/src/main/resources/en_US/element/string.json create mode 100644 product/tablet/src/main/resources/zh_CN/element/string.json create mode 100644 signature/notes.p7b diff --git a/OAT.xml b/OAT.xml index d7a659e..75df75e 100644 --- a/OAT.xml +++ b/OAT.xml @@ -25,6 +25,8 @@ + + diff --git a/common/component/src/main/ets/default/CusDialogComp.ets b/common/component/src/main/ets/default/CusDialogComp.ets index 0b01437..959e2da 100644 --- a/common/component/src/main/ets/default/CusDialogComp.ets +++ b/common/component/src/main/ets/default/CusDialogComp.ets @@ -20,7 +20,9 @@ import {SysDefFolderUuid, DeleteFileType, FolderType} from '../../../../../../co import GlobalResourceManager from '../../../../../../common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets' import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets' import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets' +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +const TAG = "CusDialogComp" @CustomDialog export struct NewOrEditFolderDialog { newOrEditFolderDialogCtl: CustomDialogController @@ -72,6 +74,9 @@ export struct NewOrEditFolderDialog { .margin({ left: 64 }) .fontColor("#FA2A2D") .visibility((this.isExisted && this.inputName != this.oriInputName) ? Visibility.Visible : Visibility.None) + Divider().height(1) + .margin({ left: 64, right: 24 }) + .color($r("app.color.divider_color_182431")) // button group Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) { Text($r("app.string.cancel")) @@ -571,7 +576,7 @@ export struct EditContentDialog { this.inSetValue = value this.fontSize = value + 20 this.confirm("javascript:RICH_EDITOR.execFontSize('" + this.fontSize + "')") - console.info('value:' + value + 'mode:' + mode.toString()) + LogUtil.info(TAG, 'value:' + value + 'mode:' + mode.toString()) }) .width('88%') Image($r('app.media.font_large')) @@ -682,69 +687,159 @@ export struct EditContentDialogPortrait { }) } .height(48) + .padding({ left: 24, right: 24 }) - Row({ space: 34 }) { - Image($r('app.media.action_bold')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setBold()") - }) - Image($r('app.media.format_italic')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setItalic()") - }) - Image($r('app.media.underline')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setUnderline()") - }) - Image($r('app.media.right_justify')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setJustifyRight()") - }) - Image($r('app.media.mid_justify')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setJustifyCenter()") - }) - Image($r('app.media.left_justify')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setJustifyLeft()") - }) + Row({ space: 16 }) { + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.action_bold')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setBold()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.format_italic')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setItalic()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.underline')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setUnderline()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.right_justify')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setJustifyRight()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.mid_justify')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setJustifyCenter()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.left_justify')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setJustifyLeft()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) } .height(48) Divider().vertical(false).color($r("app.color.divider_color_e4e4e4")) - Row({ space: 34 }) { + Row({ space: 16 }) { - Image($r('app.media.suojin')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setIndent()") - }) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.suojin')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setIndent()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) - Image($r('app.media.suojin_back')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setOutdent()") - }) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.suojin_back')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setOutdent()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) - Image($r("app.media.format_menulist_number")).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setNumbers()") - }) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r("app.media.format_menulist_number")) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setNumbers()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) - Image($r("app.media.format_menulist_alphabet")).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setABC()") - }) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r("app.media.format_menulist_alphabet")) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setABC()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) - Image($r('app.media.format_menubullte2')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setBullets()") - }) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.format_menubullte2')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setBullets()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) - Image($r('app.media.format_menubullte1')).height(24).width(24) - .onClick(() => { - this.confirm("javascript:RICH_EDITOR.setSquare()") - }) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.format_menubullte1')) + .height(24) + .width(24) + .onClick(() => { + this.confirm("javascript:RICH_EDITOR.setSquare()") + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) } .height(48) @@ -765,6 +860,7 @@ export struct EditContentDialogPortrait { } } .height(48) + .padding({ left: 24, right: 24 }) Divider().vertical(false).color($r("app.color.divider_color_e4e4e4")) @@ -786,7 +882,7 @@ export struct EditContentDialogPortrait { this.inSetValue = value this.fontSize = value + 20 this.confirm("javascript:RICH_EDITOR.execFontSize('" + this.fontSize + "')") - console.info('value:' + value + 'mode:' + mode.toString()) + LogUtil.info(TAG, 'value:' + value + 'mode:' + mode.toString()) }) .width('79%') Image($r('app.media.font_large')).height(24).width(24).margin({ top: 7 }) @@ -794,11 +890,11 @@ export struct EditContentDialogPortrait { .alignItems(VerticalAlign.Top) .padding({ top: 5 }) .height(72) + .padding({ left: 24, right: 24 }) } .width(360) .height(266) .backgroundColor($r("app.color.color_ffffff")) .borderRadius(36) - .padding({ left: 24, right: 24 }) } } \ No newline at end of file diff --git a/common/component/src/main/ets/default/FolderListComp.ets b/common/component/src/main/ets/default/FolderListComp.ets index c133304..a1f6d7f 100644 --- a/common/component/src/main/ets/default/FolderListComp.ets +++ b/common/component/src/main/ets/default/FolderListComp.ets @@ -21,7 +21,7 @@ import StyleConstants from '../../../../../../common/utils/src/main/ets/default/ import RdbStoreUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets' import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets' import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets' -import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' // Folder list component @Component @@ -33,45 +33,40 @@ export struct FolderListComp { TAG = "FolderListComp" build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { Column() { - Column() { - Image($r("app.media.suojin")) - .height(24) - .width(24) - .onClick(() => { - if (this.sectionStatus == 1) { - this.expandStatus = !this.expandStatus - } else { - this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) - // 迁移 - console.log("FolderListComp, set continue section") - AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - console.log("FolderListComp, set continue section success") - } - }) - }.alignItems(HorizontalAlign.Start) - .width("100%") - .margin({ top: 28 }) - .padding({ left: 24 }) + Image($r("app.media.suojin")) + .height(24) + .width(24) + .onClick(() => { + if (this.sectionStatus == 1) { + this.expandStatus = !this.expandStatus + } else { + this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) + // 迁移 + LogUtil.info(this.TAG, "FolderListComp, set continue section") + AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) + LogUtil.info(this.TAG, "FolderListComp, set continue section success") + } + }) + }.alignItems(HorizontalAlign.Start) + .width("100%") + .margin({ top: 28 }) + .padding({ left: 24 }) - NoteAndCreateComp() + NoteAndCreateComp() // center - Column() { - List() { - ForEach(this.AllFolderArray, (folderItem: FolderData) => { - ListItem() { - if (!FolderUtil.isBottomFixedFolder(folderItem)) { - FolderItemComp({ folderItem: folderItem, controllerShow: this.controllerShow }) - } - } - }, folderItem => folderItem.name.toString()) + List() { + ForEach(this.AllFolderArray, (folderItem: FolderData) => { + ListItem() { + if (!FolderUtil.isBottomFixedFolder(folderItem)) { + FolderItemComp({ folderItem: folderItem, controllerShow: this.controllerShow }) + } } - }.width('100%') - .padding({ left: 12, right: 12 }) - .height(7 * 56) // 列表最多显示7个 每个的高度为56 - } - + }, folderItem => folderItem.name.toString()) + }.width('100%') + .padding({ left: 12, right: 12 }) + Blank() Column() { FolderItemComp({ folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.MyFavorites), @@ -81,10 +76,12 @@ export struct FolderListComp { folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.RecentDeletes), controllerShow: this.controllerShow }) - }.margin({ bottom: 48 }) + } .width("100%") .padding({ left: 12, right: 12 }) } + .padding({ bottom: 48 }) + .height("100%") } aboutToAppear(): void{ @@ -165,7 +162,7 @@ struct FolderItemComp { controllerShow: WebController private isLongPress: boolean = false TAG = "FolderListComp" -// Folder Edit Dialog + // Folder Edit Dialog folderEditDialogCtl: CustomDialogController = new CustomDialogController({ builder: NewOrEditFolderDialog({ editFolderUuid: this.folderItem.uuid, @@ -176,7 +173,7 @@ struct FolderItemComp { autoCancel: false, customStyle: true, }) -// Folder Edit Dialog for portrait model + // Folder Edit Dialog for portrait model folderEditDialogCtlBottom: CustomDialogController = new CustomDialogController({ builder: NewOrEditFolderDialog({ editFolderUuid: this.folderItem.uuid, @@ -187,7 +184,7 @@ struct FolderItemComp { autoCancel: false, customStyle: true, }) -// Folder Edit Callback + // Folder Edit Callback onEditConfirm(color:string, name:string) { this.folderItem.color = color this.folderItem.name = name @@ -197,21 +194,21 @@ struct FolderItemComp { predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid) RdbStoreUtil.update(this.folderItem.toFolderObject(), predicates_folder, null) } -// Folder Delete Dialog + // Folder Delete Dialog folderDeleteDialogCtl: CustomDialogController = new CustomDialogController({ builder: DeleteDialog({ onConfirm: this.onDeleteConfirm.bind(this), deleteFileType: DeleteFileType.FolderData }), alignment: DialogAlignment.Center, autoCancel: false, customStyle: true, }) -// Folder Delete Dialog for portrait model + // Folder Delete Dialog for portrait model folderDeleteDialogCtlBottom: CustomDialogController = new CustomDialogController({ builder: DeleteDialog({ onConfirm: this.onDeleteConfirm.bind(this), deleteFileType: DeleteFileType.FolderData }), alignment: DialogAlignment.Bottom, autoCancel: false, customStyle: true, }) -// Folder Delete Callback + // Folder Delete Callback onDeleteConfirm() { let currentFolder = FolderUtil.getFolderData(this.AllFolderArray, this.folderItem.uuid) let index = this.AllFolderArray.indexOf(currentFolder) @@ -239,24 +236,24 @@ struct FolderItemComp { let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueFolder', continueFolder) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("onDeleteConfirm, set continue folder and note success") + LogUtil.info(this.TAG, "onDeleteConfirm, set continue folder and note success") } } -// Folder Create Dialog + // Folder Create Dialog folderCreateDialogCtl: CustomDialogController = new CustomDialogController({ builder: NewOrEditFolderDialog({ confirm: this.onCreateConfirm.bind(this), dialogType: 0 }), alignment: DialogAlignment.Center, autoCancel: false, customStyle: true, }) -// Folder Create Dialog for portrait model + // Folder Create Dialog for portrait model folderCreateDialogCtlBottom: CustomDialogController = new CustomDialogController({ builder: NewOrEditFolderDialog({ confirm: this.onCreateConfirm.bind(this), dialogType: 0 }), alignment: DialogAlignment.Bottom, autoCancel: false, customStyle: true, }) -// Folder Create Callback + // Folder Create Callback onCreateConfirm(color:string, name:string) { let folderData = new FolderData(0, name, new Date().getTime() + "", color, FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime()) // 新的的笔记本都是自定义类型 type为1 this.AllFolderArray.push(folderData) @@ -373,7 +370,7 @@ struct FolderItemComp { AppStorage.SetOrCreate('ContinueFolder', continueFolder) AppStorage.SetOrCreate('ContinueNote', continueNote) AppStorage.SetOrCreate('ContinueSection', 3) - console.log("FolderItemComp, set continue folder and note success") + LogUtil.info(this.TAG, "FolderItemComp, set continue folder and note success") } }) } diff --git a/common/component/src/main/ets/default/NoteContentComp.ets b/common/component/src/main/ets/default/NoteContentComp.ets index f1d0e0d..83b5684 100644 --- a/common/component/src/main/ets/default/NoteContentComp.ets +++ b/common/component/src/main/ets/default/NoteContentComp.ets @@ -24,10 +24,14 @@ import FolderUtil from '../../../../../../common/utils/src/main/ets/default/base import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets' import prompt from '@system.prompt' import featureAbility from '@ohos.ability.featureAbility' -import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import OperationUtils from '../../../../../../common/utils/src/main/ets/default/baseUtil/OperationUtils.ets' +import mediaquery from '@ohos.mediaquery' const TAG = "NoteContentComp" +var timeId : number + // Note content component @Component export struct NoteContentComp { @@ -44,34 +48,36 @@ export struct NoteContentComp { private context = getContext(this) noteContent = { callbackhtml: (html) => { - LogUtil.info(TAG, 'html content is:' + html) LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid) this.selectedNoteData.content_text = html this.selectedNoteData.modified_time = new Date().getTime() + // updata note image + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) - LogUtil.info(TAG, 'update note success:' + this.selectedNoteData) + LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("callbackhtml, set continue note success") + LogUtil.info(TAG, "callbackhtml, set continue note success") return "AceString" }, callbackhtmlSave: (html) => { - LogUtil.info(TAG, 'html content is:' + html) LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid) this.selectedNoteData.content_text = html this.selectedNoteData.modified_time = new Date().getTime() + // updata note image + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) - LogUtil.info(TAG, 'update note success:' + this.selectedNoteData) + LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("callbackhtml, set continue note success") + LogUtil.info(TAG, "callbackhtml, set continue note success") // 删除空白笔记 if(NoteUtil.deleteEmptyNote(this.selectedNoteData,this.AllNoteArray,this.controllerShow)) { this.selectedNoteData = this.AllNoteArray[0] @@ -79,12 +85,29 @@ export struct NoteContentComp { this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"}) } return "AceString" + }, + + callbackScheduledSave: (html) => { + LogUtil.info(TAG, 'callbackScheduledSave') + this.selectedNoteData.content_text = html + this.selectedNoteData.modified_time = new Date().getTime() + // updata note image + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text) + let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) + predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) + RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) + LogUtil.info(TAG, 'callbackScheduledSave, update note success:' + this.selectedNoteData.uuid) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, 'callbackScheduledSave, set continue note success') } + } build() { Stack({ alignContent: Alignment.Bottom }) { - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, + Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap, alignItems: ItemAlign.Start, alignContent: FlexAlign.SpaceAround }) { Column() { ToolBarComp({ controllerShow: this.controllerShow }) @@ -102,14 +125,13 @@ export struct NoteContentComp { this.controllerShow.registerJavaScriptProxy({ obj: this.noteContent, name: "callBackToApp", // html--> name.method - methodList: ["callbackhtml","callbackhtmlSave"], + methodList: ["callbackhtml", "callbackhtmlSave", "callbackScheduledSave"], }) LogUtil.info(TAG, "finish register") this.controllerShow.refresh() this.editContentFlag = true } LogUtil.info(TAG, "finish loadurl") - console.log('onPageEnd:' + e.url) this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) // 初次加载为为小屏预览模式 if (this.sectionStatus != 1) { @@ -131,9 +153,14 @@ export struct NoteContentComp { this.sectionStatus = 1 this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" }) this.editModel = !this.editModel + // 添加定时器:5s自动保存 + timeId = setInterval(() => { + this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) + }, 5000) + LogUtil.info(TAG, "NoteContentComp, setInterval timeId : " + timeId) // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - console.log("NoteContentComp, set continue section success") + LogUtil.info(TAG, "NoteContentComp, set continue section success") } }) } @@ -164,6 +191,7 @@ export struct NoteContentOverViewComp { @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] @Consume('EditModel') editModel: boolean @Consume('SectionStatus') sectionStatus: number + @Consume('RefreshFlag') refreshFlag: number editTitleDialogCtl: CustomDialogController = new CustomDialogController({ builder: EditTitleDialog({ confirm: this.confirm.bind(this), dialogType: 0 }), alignment: DialogAlignment.Center, @@ -188,6 +216,10 @@ export struct NoteContentOverViewComp { } .onClick(() => { this.selectedNoteData.folder_uuid = item.uuid + let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) + predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) + RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) + this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) }) }, noteItem => noteItem.uuid) }.listDirection(Axis.Vertical) @@ -210,7 +242,7 @@ export struct NoteContentOverViewComp { this.editTitleDialogCtl.open() // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - console.log("NoteContentOverViewComp, set continue section success") + LogUtil.info(TAG, "NoteContentComp, set continue section success") }) }.height(40) .width(StyleConstants.PERCENTAGE_100) @@ -218,7 +250,7 @@ export struct NoteContentOverViewComp { Row() { Text(DateUtil.formateDateForNoteContent(new Date(this.selectedNoteData.modified_time))) .fontSize(12) - .padding({ top: 4, bottom: 4 }) + .padding({ top: 4, bottom: 4 }).fontColor('#A3A7AD') Row() { Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid))) .fontSize(12) @@ -289,7 +321,7 @@ export struct ToolBarComp { // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("ToolBarComp, onDeleteConfirm, set continue note success") + LogUtil.info(TAG, "NoteContentOverViewComp, set continue section success") } editContentDialogCtl: CustomDialogController = new CustomDialogController({ @@ -300,7 +332,6 @@ export struct ToolBarComp { }) confirm(excuteJs: string) { - prompt.showToast({ message: excuteJs, duration: 2000 }) this.controllerShow.runJavaScript({ script: excuteJs }) } @@ -331,15 +362,21 @@ export struct ToolBarComp { LogUtil.info(TAG, "close note" + this.selectedNoteData.uuid) this.controllerShow.runJavaScript({ script: "save_html_content()" }) this.sectionStatus = this.lastSectionStatus + this.sectionStatus = mediaquery.matchMediaSync('(width < 2000)').matches ? 2 : 3 + // 清除定时器 + if (timeId != undefined) { + LogUtil.info(TAG, "zoom, clearInterval timeId : " + timeId) + clearInterval(timeId) + } } else { this.sectionStatus = 3 } } this.editModel = !this.editModel // 迁移 - console.log("ToolBarComp, set continue section") + LogUtil.info(TAG, "ToolBarComp, set continue section") AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - console.log("ToolBarComp, set continue section success") + LogUtil.info(TAG, "ToolBarComp, set continue section success") }) .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) } @@ -371,7 +408,7 @@ export struct ToolBarComp { // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("recover, set continue note success") + LogUtil.info(TAG, "recover, set continue note success") }) }.width(72) .visibility(this.portraitModel ? Visibility.None : Visibility.Visible) @@ -399,59 +436,92 @@ export struct ToolBarComp { LogUtil.info(TAG, "note is empty,save note failed") prompt.showToast({ message: $r('app.string.empty_note'), duration: 2000 }) } + // 清除定时器 + if (timeId != undefined) { + LogUtil.info(TAG, "tick_thin, clearInterval timeId : " + timeId) + clearInterval(timeId) + } }) }.width(120) } else if (this.editModel == true) { - Row({ space: StyleConstants.SPACE_24 }) { - Image($r('app.media.circle_tick1')) - .height(24) - .width(24) - .onClick(() => { - // 清单 - this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" }) - }) - Image($r('app.media.styles')) - .height(24) - .width(24) - .onClick(() => { - if (this.portraitModel) { - this.editContentDialogCtl.open() - } else { - this.editContentDialogCtl.open() - } - }) - Image($r('app.media.picture_white')) - .height(24) - .width(24) - .onClick(() => { - console.info('test select single select!') - this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImage()" }) - }) - Image($r('app.media.tick_thick')) - .height(24) - .width(24) - .onClick(() => { - // 保存笔记信息到数据库 - this.controllerShow.runJavaScript({ script: "get_html_content()" }) - if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") { - LogUtil.info(TAG, "note is empty,save note failed") - prompt.showToast({ message: $r('app.string.empty_note'), duration: 2000 }) - } - }) - Image($r('app.media.undo')) - .height(24) - .width(24) - .onClick(() => { - - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" }) - }) - Image($r('app.media.todo')) - .height(24) - .width(24) - .onClick(() => { - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" }) - }) - }.width(268) + Row({ space: StyleConstants.SPACE_6 }) { + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.circle_tick1')) + .height(24) + .width(24) + .onClick(() => { + // 清单 + this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" }) + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.styles')) + .height(24) + .width(24) + .onClick(() => { + if (this.portraitModel) { + this.editContentDialogCtl.open() + } else { + this.editContentDialogCtl.open() + } + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.picture_white')).height(24).width(24) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.tick_thick')) + .height(24) + .width(24) + .onClick(() => { + // 保存笔记信息到数据库 + this.controllerShow.runJavaScript({ script: "get_html_content()" }) + if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") { + LogUtil.info(TAG, "note is empty,save note failed") + } + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.undo')) + .height(24) + .width(24) + .onClick(() => { + + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" }) + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.todo')) + .height(24) + .width(24) + .onClick(() => { + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" }) + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + }.width(274) } else { Row({ space: StyleConstants.SPACE_24 }) { Image(this.selectedNoteData.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel')) @@ -466,10 +536,11 @@ export struct ToolBarComp { RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) { this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites) + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("ToolBarComp, set continue note success") + LogUtil.info(TAG, "ToolBarComp, set continue note success") } }) Image($r('app.media.delete')) @@ -527,7 +598,7 @@ export struct DeleteNoteComp { // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("DeleteNoteComp, onDeleteConfirm, set continue note success") + LogUtil.info(TAG, "DeleteNoteComp, onDeleteConfirm, set continue note success") } build() { diff --git a/common/component/src/main/ets/default/NoteContentCompPortrait.ets b/common/component/src/main/ets/default/NoteContentCompPortrait.ets index 2359d03..6fbd3d7 100644 --- a/common/component/src/main/ets/default/NoteContentCompPortrait.ets +++ b/common/component/src/main/ets/default/NoteContentCompPortrait.ets @@ -25,7 +25,8 @@ import FolderUtil from '../../../../../../common/utils/src/main/ets/default/base import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets' import prompt from '@system.prompt' import featureAbility from '@ohos.ability.featureAbility'; -import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import OperationUtils from '../../../../../../common/utils/src/main/ets/default/baseUtil/OperationUtils.ets' const TAG = "NoteContentComp" @@ -45,14 +46,15 @@ export struct NoteContentCompPortrait { private context = getContext(this) noteContent = { callbackhtml: (html) => { - LogUtil.info(TAG, 'html content is:' + html) LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid) this.selectedNoteData.content_text = html this.selectedNoteData.modified_time = new Date().getTime() + // updata note image + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) - LogUtil.info(TAG, 'update note success:' + this.selectedNoteData) + LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid) return "AceString"; } } @@ -84,7 +86,6 @@ export struct NoteContentCompPortrait { this.editContentFlag = true } LogUtil.info(TAG, "finish loadurl") - console.log('onPageEnd:' + e.url) // 初次进入预览模式 this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) this.controllerShow.runJavaScript({ @@ -232,39 +233,54 @@ export struct ToolBarComp { if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) { this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites) // 迁移 - console.log("ToolBarComp, set continue note") + LogUtil.info(TAG, "ToolBarComp, set continue note") let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) - console.log("ToolBarComp, continueNote : " + continueNote) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("ToolBarComp, set continue note success") + LogUtil.info(TAG, "ToolBarComp, set continue note success") } }) }.width(36) .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) } else { - Row({ space: StyleConstants.SPACE_24 }) { - Image($r('app.media.undo')).height(24).width(24) - .onClick(() => { - this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.undo()" }) - }) - Image($r('app.media.todo')).height(24).width(24) - .onClick(() => { - this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.redo()" }) - }) - Image($r('app.media.tick_thin')).height(24).width(24) - .onClick(() => { - // 保存笔记信息到数据库 - this.controllerShow.runJavaScript({ script: "get_html_content()" }) - if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") { - LogUtil.info(TAG, "note is empty,save note failed") - prompt.showToast({ message: $r('app.string.empty_note'), duration: 2000 }) - } - // 进入预览模式 - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) - this.editModel = false - }) + Row({ space: StyleConstants.SPACE_6 }) { + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.undo')).height(24).width(24) + .onClick(() => { + this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.undo()" }) + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.todo')).height(24).width(24) + .onClick(() => { + this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.redo()" }) + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.tick_thin')).height(24).width(24) + .onClick(() => { + // 保存笔记信息到数据库 + this.controllerShow.runJavaScript({ script: "get_html_content()" }) + if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") { + LogUtil.info(TAG, "note is empty,save note failed") + } + // 进入预览模式 + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) + this.editModel = false + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) } - .width(120) + .width(130) .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) } } @@ -407,8 +423,7 @@ export struct EditNoteCompForPortrait { Image($r('app.media.picture_white')) .width(24) .height(24) - .onClick(() => { - }) + Text($r("app.string.photo")) .fontSize(10).fontColor('#182431') .padding({ top: 5 }) diff --git a/common/component/src/main/ets/default/NoteListComp.ets b/common/component/src/main/ets/default/NoteListComp.ets index 3524ada..528cc18 100644 --- a/common/component/src/main/ets/default/NoteListComp.ets +++ b/common/component/src/main/ets/default/NoteListComp.ets @@ -24,7 +24,7 @@ import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUt import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets' import StyleConstants from '../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets' import SearchModel from '../../../../../../common/utils/src/main/ets/default/model/searchModel/SearchModel.ets' -import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' const TAG = "NoteListComp" @@ -78,22 +78,24 @@ struct NoteOverViewComp { build() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { - Image($r("app.media.suojin_back")) - .height(24) - .width(24) - .margin({ right: this.sectionStatus != 3 ? 24 : 0 }) // 两分栏时缩进图片与右边有个24的间距 - .visibility(this.sectionStatus != 3 ? Visibility.Visible : Visibility.None) - .onClick(() => { - if (this.sectionStatus == 1) { - this.expandStatus = !this.expandStatus - } else { - this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) - // 迁移 - console.log("NoteOverViewComp, set continue section") - AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - console.log("NoteOverViewComp, set continue section success") - } - }) + Column() { + Image($r("app.media.suojin_back")) + .height(24) + .width(24) + .margin({ right: this.sectionStatus != 3 ? 24 : 0 }) // 两分栏时缩进图片与右边有个24的间距 + .visibility(this.sectionStatus != 3 ? Visibility.Visible : Visibility.None) + .onClick(() => { + if (this.sectionStatus == 1) { + this.expandStatus = !this.expandStatus + } else { + this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) + // 迁移 + LogUtil.info(TAG, "NoteOverViewComp, set continue section") + AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) + LogUtil.info(TAG, "NoteOverViewComp, set continue section success") + } + }) + }.alignItems(HorizontalAlign.Center) Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, @@ -103,13 +105,16 @@ struct NoteOverViewComp { Text(FolderUtil.getFolderText(this.selectedFolderData)) .fontSize(30) .fontColor('#182431') + .fontWeight(FontWeight.Bold) + .textOverflow({ overflow: TextOverflow.Ellipsis }) Row() { Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString()) .fontSize(14) - .fontColor('#182431') + .fontColor('#A3A7AD') Text($r("app.string.noteslist")) .fontSize(14) - .fontColor('#182431') + .fontColor('#A3A7AD') + .textOverflow({ overflow: TextOverflow.Ellipsis }) } .visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible) }.visibility(this.longpress ? Visibility.None : Visibility.Visible) @@ -127,6 +132,7 @@ struct NoteOverViewComp { .fontSize(20) .fontColor('#182431') .margin({ left: 16 }) + .textOverflow({ overflow: TextOverflow.Ellipsis }) }.alignItems(VerticalAlign.Center) .visibility(this.longpress ? Visibility.Visible : Visibility.None) }.padding({ top: 8, bottom: 8 }) @@ -174,19 +180,21 @@ export struct NoteItemComp { }), item => { if (item.data.type == 0) { - Span(item.data.text).fontColor('#182431').fontSize(16) + Span(item.data.text).fontColor('#182431').fontSize(16).fontWeight(FontWeight.Medium) } else if (item.data.type == 1) { - Span(item.data.text).fontColor(Color.Blue).fontSize(16) + Span(item.data.text).fontColor(Color.Blue).fontSize(16).fontWeight(FontWeight.Medium) } }, item => item.index) - } + }.textOverflow({ overflow: TextOverflow.Ellipsis }) } Row({ space: 4 }) { Text(DateUtil.formateDateForNoteTitle(new Date(this.noteItem.modified_time))) .fontSize(14) - .fontColor('#182431') + .fontColor('#99182431') + .fontWeight(FontWeight.Regular) + .textOverflow({ overflow: TextOverflow.Ellipsis }) Image($r("app.media.favorite")) .height(16) .width(16) @@ -201,11 +209,14 @@ export struct NoteItemComp { }.width(240) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Image(this.noteItem.content_img) - .height(48) - .width(48) - .borderRadius(12) - .border({ width: 0.5, color: '#19182431' }) + Stack({ alignContent: Alignment.Center }) { + Image(this.noteItem.content_img) + .height(48) + .width(48) + .borderRadius(12) + .border({ width: 0.5, color: '#19182431' }) + .visibility(this.noteItem.content_img ? Visibility.Visible : Visibility.None) + } Stack({ alignContent: Alignment.Center }) { Image($r("app.media.unChecked")) .height(24) @@ -247,7 +258,7 @@ export struct NoteItemComp { // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("NoteItemComp, set continue note success") + LogUtil.info(TAG, "NoteItemComp, set continue note success") } if(this.portraitModel == false) { this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) @@ -294,10 +305,11 @@ export struct NoteItemListComp { } else { this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) } + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("doSearch, set continue note success") + LogUtil.info(TAG, "doSearch, set continue note success") this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) }) } @@ -349,8 +361,7 @@ export struct NoteItemListComp { }.listDirection(Axis.Vertical) .edgeEffect(EdgeEffect.Spring) } - .backgroundColor(this.search && this.inputKeyword.length == 0 ? $r("app.color.notecontent_color_000000") : $r("app.color.notelist_bgcolor_f1f3f5")) - .opacity(this.search && this.inputKeyword.length == 0 ? StyleConstants.OPACITY_10 : StyleConstants.OPACITY_100) + .backgroundColor($r("app.color.notelist_bgcolor_f1f3f5")) .height('100%') } .height('80%') @@ -387,7 +398,9 @@ export struct OperateNoteComp { predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid) RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null) }) + this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid) this.longpress = false + this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray) } @@ -427,7 +440,7 @@ export struct OperateNoteComp { // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("OperateNoteComp, set continue note success") + LogUtil.info(TAG, "OperateNoteComp, set continue note success") } build() { @@ -528,7 +541,12 @@ export struct AddNoteComp { .height(24) .margin({ right: 12 }) .onClick(() => { - let noteData = new NoteData(0, "标题", new Date().getTime() + "", this.selectedFolderData.uuid, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0) + let noteData + if (this.selectedFolderData.uuid == SysDefFolderUuid.AllNotes) { + noteData = new NoteData(0, "标题", new Date().getTime() + "", SysDefFolderUuid.UnClassified, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0) + } else { + noteData = new NoteData(0, "标题", new Date().getTime() + "", this.selectedFolderData.uuid, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0) + } this.AllNoteArray.push(noteData) RdbStoreUtil.insert(TableName.NoteTable, noteData.toNoteObject(), null) @@ -551,7 +569,7 @@ export struct AddNoteComp { let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - console.log("addNote, set continue note and section success") + LogUtil.info(TAG, "addNote, set continue note and section success") }) .visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible) } @@ -577,6 +595,7 @@ export struct SearchComp { Image($r('app.media.search')).width(18).height(18) TextInput({ text: this.inputKeyword, placeholder: $r('app.string.searchNote') }) .backgroundColor($r("app.color.color_ffffff")) + .caretColor('#F86D05') .onChange((value: string) => { LogUtil.info(TAG, "Search value: " + value) this.inputKeyword = value @@ -585,11 +604,12 @@ export struct SearchComp { this.search = true }) } - .width(this.search ? 344 : 384) - .height(52) - .padding({ left: 12, right: 12, top: 6, bottom: 6 }) + .height(40) + .padding({ left: 6, right: 12, top: 9, bottom: 9 }) .borderRadius(20) .backgroundColor($r("app.color.color_ffffff")) + .border({ width: 1.5, color: $r("app.color.divider_color_e4e4e4") }) + .margin({ right: this.search ? 40 : 0 }) } } } @@ -618,7 +638,9 @@ export struct OperateNoteCompForPortrait { predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid) RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null) }) + this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid) this.longpress = false + this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray) } @@ -655,7 +677,7 @@ export struct OperateNoteCompForPortrait { // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - console.log("OperateNoteCompForPortrait, set continue note success") + LogUtil.info(TAG, "OperateNoteCompForPortrait, set continue note success") } build() { diff --git a/common/component/src/main/resources/base/element/color.json b/common/component/src/main/resources/base/element/color.json deleted file mode 100644 index 6e15ec2..0000000 --- a/common/component/src/main/resources/base/element/color.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "color": [ - { - "name": "color_ffffff", - "value": "#ffffff" - }, - { - "name": "delete_color_fa2a2d", - "value": "#fa2a2d" - }, - { - "name": "cancel_color_4fb4e3", - "value": "#4fb4e3" - }, - { - "name": "divider_color_e4e4e4", - "value": "#cce4e4e4" - }, - { - "name": "divider_color_182431", - "value": "#182431" - }, - { - "name": "button_color_419fff", - "value": "#419fff" - }, - { - "name": "button_color_fb4447", - "value": "#fb4447" - }, - { - "name": "text_color_3f97e9", - "value": "#3f97e9" - }, - { - "name": "text_color_f86d05", - "value": "#f86d05" - }, - { - "name": "folder_color_182431", - "value": "#182431" - }, - { - "name": "folder_color_f86d05", - "value": "#f86d05" - }, - { - "name": "folder_color_ffffff", - "value": "#ffffff" - }, - { - "name": "folder_color_19ffffff", - "value": "#19ffffff" - }, - { - "name": "folder_color_19182431", - "value": "#19182431" - }, - { - "name": "notecontent_color_ffffff", - "value": "#ffffff" - }, - { - "name": "notecontent_color_000000", - "value": "#000000" - }, - { - "name": "folderlist_bgcolor_f1f3f5", - "value": "#f1f3f5" - }, - { - "name": "notelist_bgcolor_f1f3f5", - "value": "#f1f3f5" - }, - { - "name": "notelist_bgcolor_000000", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/common/component/src/main/resources/base/element/float.json b/common/component/src/main/resources/base/element/float.json deleted file mode 100644 index fe803f0..0000000 --- a/common/component/src/main/resources/base/element/float.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "float": [ - { - "name": "wh_value_1", - "value": "1" - }, - { - "name": "wh_value_4", - "value": "4" - }, - { - "name": "wh_value_5", - "value": "5" - }, - { - "name": "wh_value_8", - "value": "8" - }, - { - "name": "wh_value_10", - "value": "10" - }, - { - "name": "wh_value_14", - "value": "14" - }, - { - "name": "wh_value_16", - "value": "16" - }, - { - "name": "wh_value_20", - "value": "20" - }, - { - "name": "wh_value_24", - "value": "24" - }, - { - "name": "wh_value_30", - "value": "30" - }, - { - "name": "wh_value_40", - "value": "40" - }, - { - "name": "wh_value_50", - "value": "50" - }, - { - "name": "wh_value_60", - "value": "60" - }, - { - "name": "wh_value_65", - "value": "65" - }, - { - "name": "wh_value_70", - "value": "70" - }, - { - "name": "wh_value_80", - "value": "80" - }, - { - "name": "wh_value_100", - "value": "100" - }, - { - "name": "wh_value_120", - "value": "120" - }, - { - "name": "wh_value_130", - "value": "1300" - }, - { - "name": "wh_value_160", - "value": "160" - }, - { - "name": "wh_value_230", - "value": "230" - }, - { - "name": "wh_value_280", - "value": "280" - }, - { - "name": "wh_value_390", - "value": "390" - }, - { - "name": "wh_value_400", - "value": "400" - }, - { - "name": "font_35", - "value": "35" - }, - { - "name": "font_15", - "value": "15" - }, - { - "name": "font_20", - "value": "20" - }, - { - "name": "font_25", - "value": "25" - }, - { - "name": "font_28", - "value": "28" - }, - { - "name": "font_50", - "value": "50" - }, - { - "name": "control_common_font_size", - "value": "20" - }, - { - "name": "slider_text_padding_left", - "value": "5" - }, - { - "name": "volume_border_radius", - "value": "15" - } - ] -} \ No newline at end of file diff --git a/common/utils/src/main/ets/default/access/MediaLibraryAccess.ets b/common/utils/src/main/ets/default/access/MediaLibraryAccess.ets new file mode 100644 index 0000000..3756840 --- /dev/null +++ b/common/utils/src/main/ets/default/access/MediaLibraryAccess.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {LogUtil} from '../baseUtil/LogUtil.ets' +import MediaLib from '@ohos.multimedia.mediaLibrary'; + +const TAG = "MediaLibraryAccess" +export class MediaLibraryAccess { + + static async getFirstObject(fetchOpt, context) { + let album = { + count: 0, + obj: null, + } + try { + // 通过Uri拷贝图片到指定指定的包路径下 + // 1、获取本地路径 + + let fileResult = await MediaLib.getMediaLibrary(context).getFileAssets(fetchOpt) + if (fileResult != undefined) { + album.count = fileResult.getCount(); + if (album.count <= 0) { + return album; + } + + let file = await fileResult.getFirstObject(); + if (file) { + album.obj = file; + return album; + } else { + LogUtil.warn(TAG, 'Failed getFirstObject') + } + } + return album; + } + catch (error) { + LogUtil.error(TAG, `getFirstObject loadData error: ${error}`) + return album; + } + } + + static async openAsset(mode: string, fileAsset: any) { + LogUtil.info(TAG, 'openAsset start') + let fd = await fileAsset.open(mode); + LogUtil.info(TAG, `openAsset end. fd: ${fd}`) + + if (fd <= 0) { + LogUtil.warn(TAG, 'openAsset Fail') + return; + } + + return fd; + } + + static async closeAsset(fd: number, fileAsset: any) { + LogUtil.info(TAG, 'closeAsset start') + + if (fd <= 0) { + LogUtil.warn(TAG, 'closeAsset fd is invalid') + return; + } + + try { + await fileAsset.close(fd) + LogUtil.info(TAG, 'closeAsset end') + + } catch (error) { + LogUtil.warn(TAG, 'closeAsset fail') + } + } +} \ No newline at end of file diff --git a/common/utils/src/main/ets/default/baseUtil/DateUtil.ets b/common/utils/src/main/ets/default/baseUtil/DateUtil.ets index ddc6068..af971c4 100644 --- a/common/utils/src/main/ets/default/baseUtil/DateUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/DateUtil.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import LogUtil from './LogUtil.ets' +import {LogUtil} from './LogUtil.ets' import GlobalResourceManager from './GlobalResourceManager.ets' const TAG = "DateUtil" @@ -38,7 +38,7 @@ export class DateUtil { let nowDate = new Date() let diffMin = Math.floor((nowDate.getTime() - date.getTime()) / 1000 / 60) if (diffMin < 0) { - LogUtil.info("DateUtils, formateDateForNoteTitle : date is error") + LogUtil.info(TAG, "DateUtils, formateDateForNoteTitle : date is error") return this.formateDateForNoteContent(date) } diff --git a/common/utils/src/main/ets/default/baseUtil/FakerRdbStoreUtil.ets b/common/utils/src/main/ets/default/baseUtil/FakerRdbStoreUtil.ets index d385d96..09eb7d1 100644 --- a/common/utils/src/main/ets/default/baseUtil/FakerRdbStoreUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/FakerRdbStoreUtil.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import LogUtil from '../../common/baseUtil/LogUtil.ets' +import {LogUtil} from '../../common/baseUtil/LogUtil.ets' import SysDefData from '../../model/databaseModel/SysDefData.ets' import FolderData from '../../model/databaseModel/FolderData.ets' import NoteData from '../../model/databaseModel/NoteData.ets' @@ -52,10 +52,10 @@ export default { AppStorage.SetOrCreate('AllNoteArray', noteDataArray) AppStorage.SetOrCreate('AllFolderArray', folderDataArray) for (let folderData of folderDataArray) { - LogUtil.info(TAG, "folderData : " + JSON.stringify(folderData)) + LogUtil.info(TAG, "folderDataUuid : " + JSON.stringify(folderData.uuid)) } for (let noteData of noteDataArray) { - LogUtil.info(TAG, "noteDataArray : " + JSON.stringify(noteData)) + LogUtil.info(TAG, "noteDataArrayUuid : " + JSON.stringify(noteData.uuid)) } AppStorage.SetOrCreate('DBQueryFinished', 1) } diff --git a/common/utils/src/main/ets/default/baseUtil/FolderUtil.ets b/common/utils/src/main/ets/default/baseUtil/FolderUtil.ets index e875018..33ca980 100644 --- a/common/utils/src/main/ets/default/baseUtil/FolderUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/FolderUtil.ets @@ -18,7 +18,7 @@ import NoteData from '../model/databaseModel/NoteData.ets' import {SysDefFolderUuid, FolderType, Favorite, Delete} from '../model/databaseModel/EnumData.ets' import GlobalResourceManager from './GlobalResourceManager.ets' import StyleConstants from '../constants/StyleConstants.ets' -import LogUtil from './LogUtil.ets' +import {LogUtil} from './LogUtil.ets' const TAG = "FolderUtil" diff --git a/common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets b/common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets index 6f4f1fc..edfa970 100644 --- a/common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets +++ b/common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets @@ -13,6 +13,7 @@ * limitations under the License. */ import Rsm from '@ohos.resourceManager'; +import {LogUtil} from './LogUtil.ets' const TAG = "Note_GlobalResourceManager" @@ -20,7 +21,7 @@ export class GlobalResourceManager { public async getStringByResource(res: any): Promise { let json = JSON.parse(JSON.stringify(res)); let id = json.id; - console.info(TAG, "ResourceID = %d", id) + LogUtil.info(TAG, "ResourceID = %d" + id) return await this.getStringById(id); } @@ -31,16 +32,16 @@ export class GlobalResourceManager { result.getString(id) .then((resource) => { resolve(resource); - console.info('getStringById resolve(resource) : ' + resolve(resource)); - console.info('getStringById resource : ' + resource); - console.info('getStringById resource2 : ' + JSON.stringify(resource)); + LogUtil.info(TAG, 'getStringById resolve(resource) : ' + resolve(resource)); + LogUtil.info(TAG, 'getStringById resource : ' + resource); + LogUtil.info(TAG, 'getStringById resource2 : ' + JSON.stringify(resource)); }) .catch((err) => { - console.info('getStringById err : ' + JSON.stringify(err)); + LogUtil.info(TAG, 'getStringById err : ' + JSON.stringify(err)); }); }); }); - console.info('getStringById promise: ' + JSON.stringify(promise)); + LogUtil.info(TAG, 'getStringById promise: ' + JSON.stringify(promise)); return promise; } } diff --git a/common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets b/common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets index d0c3c43..514e43b 100644 --- a/common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets @@ -19,7 +19,7 @@ import NoteData from '../model/databaseModel/NoteData.ets' import {SysDefFolderUuid, FolderType, Favorite, Delete} from '../model/databaseModel/EnumData.ets' import GlobalResourceManager from './GlobalResourceManager.ets' import StyleConstants from '../constants/StyleConstants.ets' -import LogUtil from './LogUtil.ets' +import {LogUtil} from './LogUtil.ets' import FolderUtil from './FolderUtil.ets' import NoteUtil from './NoteUtil.ets' diff --git a/common/utils/src/main/ets/default/baseUtil/LogUtil.ets b/common/utils/src/main/ets/default/baseUtil/LogUtil.ets index bded946..85689be 100644 --- a/common/utils/src/main/ets/default/baseUtil/LogUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/LogUtil.ets @@ -17,57 +17,19 @@ * Log Util */ export class LogUtil { - getLogFirstStr(tag: string, ...msg) { - let firstStr: string = tag + ", " + msg[0] + " " - try { - throw new Error(); - } catch (e) { - firstStr += e.stack.split('at ')[3].split(' ')[0] - } - return firstStr + static debug(tag: string, msg: string) { + console.debug(tag + ', ' + msg) } - debug(tag: string, ...msg) { - if (msg.length == 0) { - console.debug(tag) - return - } - let firstStr = this.getLogFirstStr(tag, ...msg) - msg.shift() - console.debug(firstStr, ...msg) + static info(tag: string, msg: string) { + console.info(tag + ', ' + msg) } - info(tag: string, ...msg) { - if (msg.length == 0) { - console.debug(tag) - return - } - let firstStr = this.getLogFirstStr(tag, ...msg) - msg.shift() - console.info(firstStr, ...msg) + static warn(tag: string, msg: string) { + console.warn(tag + ', ' + msg) } - warn(tag: string, ...msg) { - if (msg.length == 0) { - console.debug(tag) - return - } - let firstStr = this.getLogFirstStr(tag, ...msg) - msg.shift() - console.warn(firstStr, ...msg) + static error(tag: string, msg: string) { + console.error(tag + ', ' + msg) } - - error(tag: string, ...msg) { - if (msg.length == 0) { - console.debug(tag) - return - } - let firstStr = this.getLogFirstStr(tag, ...msg) - msg.shift() - console.error(firstStr, ...msg) - } -} - -let mLogUtil = new LogUtil(); - -export default mLogUtil as LogUtil \ No newline at end of file +} \ No newline at end of file diff --git a/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets b/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets index 942224e..851a7bd 100644 --- a/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets @@ -18,7 +18,7 @@ import NoteData from '../model/databaseModel/NoteData.ets' import {SysDefFolderUuid, FolderType, Favorite, Delete, TableName, NoteTableColumn,} from '../model/databaseModel/EnumData.ets' import GlobalResourceManager from './GlobalResourceManager.ets' import StyleConstants from '../constants/StyleConstants.ets' -import LogUtil from './LogUtil.ets' +import {LogUtil} from './LogUtil.ets' import FolderUtil from './FolderUtil.ets' import RdbStoreUtil from './RdbStoreUtil.ets' import prompt from '@system.prompt' @@ -138,7 +138,10 @@ export class NoteUtil { LogUtil.info(TAG, "NoteBgColor is ffffff") return $r("app.color.color_ffffff") } - LogUtil.info(TAG, "isSelected %s, folderData.color: %s", isSelected, folderData.color) + if (folderData.color == "#ffffff") { + return "#FFEBE1" + } + LogUtil.info(TAG, "isSelected %s, folderData.color: %s" + isSelected.toString() + folderData.color.toString()) return isSelected ? selectedNoteBgColorMap[folderData.color] : unSelectedNoteBgColorMap[folderData.color] } @@ -155,7 +158,7 @@ export class NoteUtil { LogUtil.info(TAG, "NoteBgColor is ffffff") return $r("app.color.color_ffffff") } - LogUtil.info(TAG, "isSelected %s, folderData.color: %s", folderData.color) + LogUtil.info(TAG, "isSelected %s, folderData.color: %s" + folderData.color.toString()) if (folderData.color == "#ffffff") { return "#ff9516" } @@ -213,7 +216,7 @@ export class NoteUtil { if (noteItemRight.is_top != noteItemLeft.is_top) { return noteItemRight.is_top - noteItemLeft.is_top } - return noteItemRight.created_time - noteItemLeft.created_time + return noteItemRight.modified_time - noteItemLeft.modified_time }) LogUtil.info(TAG, "noteDataArray size " + noteDataArray.length.toString()) return noteDataArray @@ -247,11 +250,9 @@ export class NoteUtil { } deleteEmptyNote(selectedNoteData: NoteData, AllNoteArray: NoteData[],controllerShow: WebController):boolean { - LogUtil.info(TAG, selectedNoteData.content_text) if (selectedNoteData.title == "标题" && selectedNoteData.content_text == "") { // delete note from db noteUtil.removeNoteData(AllNoteArray,selectedNoteData.uuid) - LogUtil.info(TAG, "delete note:" + selectedNoteData.content_text) LogUtil.info(TAG, "delete note:" + selectedNoteData.uuid) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, selectedNoteData.uuid) diff --git a/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets b/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets new file mode 100644 index 0000000..7ece3f5 --- /dev/null +++ b/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {LogUtil} from './LogUtil.ets' +import {MediaLibraryAccess} from '../access/MediaLibraryAccess.ets'; +import fileio from '@ohos.fileio'; + +const TAG = "OperationUtils" +export class OperationUtils { + + + async copy(uri: string):Promise { + try { + let numId = this.getIdByUri(uri) + var context = globalThis.noteContext + let fileAsset = await this.getFileAssetById(numId,context); + if (fileAsset == null || fileAsset == undefined) { + LogUtil.warn(TAG, "Failed to get fileAsset") + return; + } + + let fd = await MediaLibraryAccess.openAsset('RW', fileAsset); + if (fd <= 0) { + LogUtil.warn(TAG, "fd is invaild") + return; + } + LogUtil.info(TAG, 'copyAsset read end!') + + // 通过Uri拷贝图片到指定指定的包路径下 + // 1、获取本地路径 + var dir = context.filesDir + // 2、生成本地文件名 + var time = new Date().getTime() + var imagePath = dir + "/" + time.toString().substr(10) + "_note"+ numId + ".jpg" + // 3、拷贝 + fileio.copyFile(fd, imagePath).then(() => { + LogUtil.info(TAG, "[save]copyFile successfully") + }).catch((err) => { + LogUtil.info(TAG, "[save]copyFile failed : " + err) + }); + // 4、关闭安fd,Asset + fileAsset.close(fd); + await MediaLibraryAccess.closeAsset(fd, fileAsset); + } catch (error) { + LogUtil.info(TAG, "create error: " + error); + return; + } + LogUtil.debug(TAG, 'copy end'); + + return imagePath.toString() + } + + getIdByUri(uri:string): number { + let srcIndex = uri.lastIndexOf('/'); + let srcEnd = uri.length; + let srcId = uri.substring(srcIndex + 1, srcEnd); + let numId = new Number(srcId); + LogUtil.debug(TAG, `getIdByUri numId: ${numId}`); + return numId.valueOf(); + } + + async getFileAssetById(id,context){ + LogUtil.info(TAG, 'getFileAssetById'); + let fetchOpt = { + selections : 'file_id =?', + selectionArgs : [`${id}`], + } + + try { + let result = await MediaLibraryAccess.getFirstObject(fetchOpt,context); + if (result == null) { + LogUtil.info(TAG, 'getFileAssetByUri fail'); + return null; + } + return result.obj; + } catch (error) { + LogUtil.info(TAG, 'getFileAssetById error'); + return null; + } + } +} + +let mOperationUtils = new OperationUtils(); +export default mOperationUtils as OperationUtils; diff --git a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets index f3d1bbd..bedecf3 100644 --- a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets @@ -14,8 +14,10 @@ */ import ohosDataRdb from '@ohos.data.rdb' -import LogUtil from './LogUtil.ets' +import fileio from '@ohos.fileio' +import {LogUtil} from './LogUtil.ets' import FolderUtil from './FolderUtil.ets' +import NoteUtil from './NoteUtil.ets' import SysDefData from '../model/databaseModel/SysDefData.ets' import FolderData from '../model/databaseModel/FolderData.ets' import NoteData from '../model/databaseModel/NoteData.ets' @@ -91,7 +93,7 @@ export default { let isContinue = AppStorage.Get('IsContinue'); LogUtil.info(TAG, "createRdbStore, isContinue is " + isContinue) if (isContinue != undefined && isContinue == 1) { - console.info("RdbStoreUtil createRdbStore, IsContinue true") + LogUtil.info(TAG, "RdbStoreUtil createRdbStore, IsContinue true") let continueFolder: string = AppStorage.Get('ContinueFolder') let continueNote: string = AppStorage.Get('ContinueNote') let continueSection = AppStorage.Get('ContinueSection') @@ -105,6 +107,19 @@ export default { noteObj.content_text, noteObj.content_img, noteObj.note_type, noteObj.is_top, noteObj.is_favorite, noteObj.is_deleted, noteObj.created_time, noteObj.modified_time, noteObj.deleted_time) + // save img to FileDir + LogUtil.info(TAG, "createRdbStore, save img to FileDir") + let srcArray = this.getSrcFromHtml(decodeURI(noteObj.content_text)) + srcArray.forEach((src: string) => { + let lastIndex = src.lastIndexOf('/') + LogUtil.info(TAG, " createRdbStore, lastIndex : " + lastIndex) + if (lastIndex != -1) { + let imgName = src.substring(lastIndex + 1) + this.writeToFileDir(context, imgName) + } + }) + LogUtil.info(TAG, "createRdbStore, save img to FileDir success") + // if not exit this note let exist = false let folderUuid = "" @@ -115,30 +130,41 @@ export default { break } } - console.log("RdbStoreUtil initAppStorage, exist : " + exist) - // 迁移过来的笔记在本地不存在,则保存在未分类文件夹 + LogUtil.info(TAG, "createRdbStore, exist : " + exist) if (!exist) { + // 迁移过来的笔记在本地不存在,则保存在未分类文件夹 noteData.folder_uuid = SysDefFolderUuid.UnClassified noteDataArray.push(noteData) AppStorage.SetOrCreate('AllNoteArray', noteDataArray) this.insert(TableName.NoteTable, noteData.toNoteObject(), null) AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, SysDefFolderUuid.UnClassified)) } else { + // 迁移过来的笔记在本地存在,则进行修改 + for (let i = 0; i < noteDataArray.length; i++) { + if (noteData.created_time == noteDataArray[i].created_time) { + noteDataArray[i] = noteData + LogUtil.info(TAG, "createRdbStore, update noteData in noteDataArray success") + break + } + } + let predicates_note = this.getRdbPredicates(TableName.NoteTable) + predicates_note.equalTo(NoteTableColumn.CreatedTime, noteData.created_time) + this.update(noteData.toNoteObject(), predicates_note, null) AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid)) } AppStorage.SetOrCreate('Note', noteData) AppStorage.SetOrCreate('Section', continueSection) } else { - console.info("RdbStoreUtil createRdbStore, IsContinue false") + LogUtil.info(TAG, "RdbStoreUtil createRdbStore, IsContinue false") AppStorage.SetOrCreate('Folder', AppStorage.Get('AllFolderArray')[0]) - AppStorage.SetOrCreate('Note', AppStorage.Get('AllNoteArray')[0]) + AppStorage.SetOrCreate('Note', NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes)) AppStorage.SetOrCreate('Section', 3) } AppStorage.SetOrCreate('DBQueryFinished', 1) LogUtil.info(TAG, "createRdbStore, set DBQueryFinished 1") }) .catch((err) => { - LogUtil.error(TAG, "createRdbStore, error : " + err) + LogUtil.warn(TAG, "createRdbStore, error : " + err) }) }, @@ -213,6 +239,19 @@ export default { noteObj.content_text, noteObj.content_img, noteObj.note_type, noteObj.is_top, noteObj.is_favorite, noteObj.is_deleted, noteObj.created_time, noteObj.modified_time, noteObj.deleted_time) + // save img to FileDir + LogUtil.info(TAG, "initAppStorage, save img to FileDir") + let srcArray = this.getSrcFromHtml(decodeURI(noteObj.content_text)) + srcArray.forEach((src: string) => { + let lastIndex = src.lastIndexOf('/') + LogUtil.info(TAG, " initAppStorage, lastIndex : " + lastIndex) + if (lastIndex != -1) { + let imgName = src.substring(lastIndex + 1) + this.writeToFileDir(context, imgName) + } + }) + LogUtil.info(TAG, "initAppStorage, save img to FileDir success") + // if not exit this note let exist = false let folderUuid = "" @@ -223,33 +262,86 @@ export default { break } } - console.log("RdbStoreUtil initAppStorage, exist : " + exist) - // 迁移过来的笔记在本地不存在,则保存在未分类文件夹 + LogUtil.info(TAG, "initAppStorage, exist : " + exist) if (!exist) { + // 迁移过来的笔记在本地不存在,则保存在未分类文件夹 noteData.folder_uuid = SysDefFolderUuid.UnClassified noteDataArray.push(noteData) AppStorage.SetOrCreate('AllNoteArray', noteDataArray) this.insert(TableName.NoteTable, noteData.toNoteObject(), null) AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, SysDefFolderUuid.UnClassified)) } else { + // 迁移过来的笔记在本地存在,则进行修改 + for (let i = 0; i < noteDataArray.length; i++) { + if (noteData.created_time == noteDataArray[i].created_time) { + noteDataArray[i] = noteData + LogUtil.info(TAG, "initAppStorage, update noteData in noteDataArray success") + break + } + } + let predicates_note = this.getRdbPredicates(TableName.NoteTable) + predicates_note.equalTo(NoteTableColumn.CreatedTime, noteData.created_time) + this.update(noteData.toNoteObject(), predicates_note, null) AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid)) } AppStorage.SetOrCreate('Note', noteData) AppStorage.SetOrCreate('Section', continueSection) } else { - console.info("RdbStoreUtil initAppStorage, IsContinue false") + LogUtil.info(TAG, "RdbStoreUtil initAppStorage, IsContinue false") AppStorage.SetOrCreate('Folder', AppStorage.Get('AllFolderArray')[0]) - AppStorage.SetOrCreate('Note', AppStorage.Get('AllNoteArray')[0]) + AppStorage.SetOrCreate('Note', NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes)) AppStorage.SetOrCreate('Section', 3) } AppStorage.SetOrCreate('DBQueryFinished', 1) LogUtil.info(TAG, "initAppStorage, set DBQueryFinished 1") }) .catch((err) => { - LogUtil.error(TAG, "initAppStorage, error : " + err) + LogUtil.warn(TAG, "initAppStorage, error : " + err) }) }, + getSrcFromHtml(html: string): any{ + LogUtil.info(TAG, "getSrcFromHtml, html : " + html) + let imgReg = /]+>/g + let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i + let imgArray = html.match(imgReg) + let srcArray = [] + if (imgArray != null) { + for (let i = 0; i < imgArray.length; i++) { + let src = imgArray[i].match(srcReg) + LogUtil.info(TAG, "getSrcFromHtml, src[1] : " + src[1]) + srcArray.push(src[1]) + } + } + LogUtil.info(TAG, "getSrcFromHtml, srcArray : " + srcArray) + return srcArray + }, + + writeToFileDir(context, fileName: string) { + LogUtil.info(TAG, "writeToFileDir fileName : " + fileName) + + let distributedFilesDir = context.distributedFilesDir + let srcPath = distributedFilesDir + "/" + fileName + + let srcFd + try { + srcFd = fileio.openSync(srcPath, 0o2, 0o666) + LogUtil.info(TAG, "open srcPath success : " + srcFd) + } catch (err) { + LogUtil.warn(TAG, "open srcPath failed : " + err) + } + + let filesDir = context.filesDir + let desPath = filesDir + "/" + fileName + + try { + fileio.copyFileSync(srcFd, desPath) + LogUtil.info(TAG, "writeToFileDir, copyFile successfully") + } catch (err) { + LogUtil.warn(TAG, "writeToFileDir, copyFile failed : " + err) + } + }, + /** * insert * @param tableName @@ -263,7 +355,7 @@ export default { callback(rowId) } }).catch((err) => { - LogUtil.error(TAG, "insert error : " + err) + LogUtil.warn(TAG, "insert error : " + err) }) }, @@ -279,7 +371,7 @@ export default { callback(affectedRowCount) } }).catch((err) => { - LogUtil.error(TAG, "delete error : " + err) + LogUtil.warn(TAG, "delete error : " + err) }) }, @@ -296,7 +388,7 @@ export default { callback(affectedRowCount) } }).catch((err) => { - LogUtil.error(TAG, "update error : " + err) + LogUtil.warn(TAG, "update error : " + err) }) }, @@ -313,7 +405,7 @@ export default { callback(resultSet) } }).catch((err) => { - LogUtil.error(TAG, "query error : " + err) + LogUtil.warn(TAG, "query error : " + err) }) }, @@ -323,5 +415,23 @@ export default { */ getRdbPredicates(tableName) { return new ohosDataRdb.RdbPredicates(tableName) + }, + + updataNoteImage(content):string { + let srcArray = this.getSrcFromHtml(decodeURI(content)) + LogUtil.info(TAG, "getSrcFromHtml, srcArray : " + srcArray) + if(srcArray.length == 0) { + return "" + } + if(srcArray[0] == './shuxue.png' || srcArray[0] == './lvyou.png' || srcArray[0] == './cake.png') { + let lastIndex = srcArray[0].lastIndexOf('/') + LogUtil.info(TAG, "lastIndex : " + lastIndex) + let imgName = "" + if (lastIndex != -1) { + imgName = srcArray[0].substring(lastIndex + 1) + } + return "/res/" + imgName + } + return srcArray[0] } } \ No newline at end of file diff --git a/common/utils/src/main/ets/default/constants/StyleConstants.ets b/common/utils/src/main/ets/default/constants/StyleConstants.ets index 094d05b..809fa78 100644 --- a/common/utils/src/main/ets/default/constants/StyleConstants.ets +++ b/common/utils/src/main/ets/default/constants/StyleConstants.ets @@ -17,6 +17,7 @@ export default class StyleConstants { public static PERCENTAGE_100: string = '100%' public static PERCENTAGE_60: string = '60%' public static PERCENTAGE_0: string = '0%' + public static SPACE_6: number = 6 public static SPACE_24: number = 24 public static NOTE_LIST_BACKGROUND: string = "#f1f3f5" public static DELETE_DEADLINE: number = 2592000000 // 30 days (30 * 24 * 60 * 60 * 1000)ms diff --git a/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets b/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets index c963d99..44d3c91 100644 --- a/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets +++ b/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import LogUtil from '../../baseUtil/LogUtil.ets' +import {LogUtil} from '../../baseUtil/LogUtil.ets' import NoteData from '../../model/databaseModel/NoteData.ets' import ohosDataRdb from '@ohos.data.rdb'; import {TableName, NoteTableColumn} from '../../model/databaseModel/EnumData.ets' @@ -42,7 +42,7 @@ export class SearchModel { } let searchData: NoteData[] = []; noteDataArray.forEach((noteData) => { - if (noteData.content_text.toLowerCase().indexOf(query.toLowerCase()) != -1 + if (noteData.content_text.replace(/<[^>]+>/g,"").toLowerCase().indexOf(query.toLowerCase()) != -1 || noteData.title.toLowerCase().indexOf(query.toLowerCase()) != -1) { LogUtil.info(TAG, "uuid " + noteData.uuid) searchData.push(noteData); diff --git a/product/pc/src/main/ets/MainAbility/app.ets b/product/pc/src/main/ets/MainAbility/app.ets index 8fa4678..0f76430 100644 --- a/product/pc/src/main/ets/MainAbility/app.ets +++ b/product/pc/src/main/ets/MainAbility/app.ets @@ -12,11 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' + +const TAG = "app" + export default { onCreate() { - console.info('Application onCreate') + LogUtil.info(TAG, 'Application onCreate') }, onDestroy() { - console.info('Application onDestroy') + LogUtil.info(TAG, 'Application onDestroy') }, } diff --git a/product/pc/src/main/resources/base/element/string.json b/product/pc/src/main/resources/base/element/string.json index 3b06a90..a48ce08 100644 --- a/product/pc/src/main/resources/base/element/string.json +++ b/product/pc/src/main/resources/base/element/string.json @@ -102,7 +102,7 @@ }, { "name": "searchNote", - "value": "搜索笔记" + "value": "搜索笔记..." }, { "name": "chooseFolder", @@ -135,6 +135,34 @@ { "name": "check_all", "value": "多选" + }, + { + "name": "editNoteTitle", + "value": "修改标题" + }, + { + "name": "list", + "value": "清单" + }, + { + "name": "style", + "value": "样式" + }, + { + "name": "photo", + "value": "相册" + }, + { + "name": "title", + "value": "标题" + }, + { + "name": "empty_note", + "value": "笔记内容为空" + }, + { + "name": "restore", + "value": "已恢复" } ] } \ No newline at end of file diff --git a/product/pc/src/main/resources/en_US/element/string.json b/product/pc/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..a7618c3 --- /dev/null +++ b/product/pc/src/main/resources/en_US/element/string.json @@ -0,0 +1,168 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "Notepad" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "note", + "value": "Notes" + }, + { + "name": "allNotes", + "value": "All notes" + }, + { + "name": "unClassified", + "value": "No category" + }, + { + "name": "recentDeletes", + "value": "Recently deleted" + }, + { + "name": "myFavorites", + "value": "My favourites" + }, + { + "name": "create", + "value": "NEW" + }, + { + "name": "createFolder", + "value": "New Folder" + }, + { + "name": "editFolder", + "value": "Edit Folder" + }, + { + "name": "deleteFolder", + "value": "Delete Folder" + }, + { + "name": "createNote", + "value": "New note" + }, + { + "name": "cancel", + "value": "CANCEL" + }, + { + "name": "save", + "value": "SAVE" + }, + { + "name": "delete", + "value": "DELETE" + }, + { + "name": "name", + "value": "名称" + }, + { + "name": "delete_tips", + "value": "Do you want to delete this folder and its contents?" + }, + { + "name": "deleteNote", + "value": "Delete this note?" + }, + { + "name": "deleteNoteComplete", + "value": "Permanently delete this note?" + }, + { + "name": "deleteAllNote", + "value": "Delete all note?" + }, + { + "name": "deletePartNote", + "value": "Delete %d notes?" + }, + { + "name": "selected", + "value": "%d item selected" + }, + { + "name": "none_selected", + "value": "None selected" + }, + { + "name": "noteslist", + "value": "notes" + }, + { + "name": "Empty_page", + "value": "No notes" + }, + { + "name": "searchNote", + "value": "Search notes" + }, + { + "name": "chooseFolder", + "value": "Select folder" + }, + { + "name": "category_already_exist", + "value": "The folder name already exists." + }, + { + "name": "input_placeholder", + "value": "Name" + }, + { + "name": "permanently_delete_tips", + "value": "notes will be permanently deleted after the number of days shown (up to 30 days)." + }, + { + "name": "set_top", + "value": "Top" + }, + { + "name": "move", + "value": "Move" + }, + { + "name": "recover", + "value": "Restore" + }, + { + "name": "check_all", + "value": "Select all" + }, + { + "name": "editNoteTitle", + "value": "Modify the title" + }, + { + "name": "list", + "value": "Checklist" + }, + { + "name": "style", + "value": "Style" + }, + { + "name": "photo", + "value": "Gallery" + }, + { + "name": "title", + "value": "Title" + }, + { + "name": "empty_note", + "value": "The note content is empty." + }, + { + "name": "restore", + "value": "Note Restored" + } + ] +} \ No newline at end of file diff --git a/product/pc/src/main/resources/zh_CN/element/string.json b/product/pc/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..a48ce08 --- /dev/null +++ b/product/pc/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,168 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "备忘录" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "note", + "value": "笔记" + }, + { + "name": "allNotes", + "value": "全部笔记" + }, + { + "name": "unClassified", + "value": "未分类" + }, + { + "name": "recentDeletes", + "value": "最近删除" + }, + { + "name": "myFavorites", + "value": "我的收藏" + }, + { + "name": "create", + "value": "新建" + }, + { + "name": "createFolder", + "value": "新建文件夹" + }, + { + "name": "editFolder", + "value": "编辑文件夹" + }, + { + "name": "deleteFolder", + "value": "删除文件夹" + }, + { + "name": "createNote", + "value": "新建笔记" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "save", + "value": "保存" + }, + { + "name": "delete", + "value": "删除" + }, + { + "name": "name", + "value": "名称" + }, + { + "name": "delete_tips", + "value": "是否删除此文件夹及其中的内容?" + }, + { + "name": "deleteNote", + "value": "是否删除此笔记?" + }, + { + "name": "deleteNoteComplete", + "value": "此笔记将被永久删除,无法恢复。是否删除?" + }, + { + "name": "deleteAllNote", + "value": "是否删除全部笔记?" + }, + { + "name": "deletePartNote", + "value": "是否删除%d条笔记?" + }, + { + "name": "selected", + "value": "已选择%d项" + }, + { + "name": "none_selected", + "value": "未选择" + }, + { + "name": "noteslist", + "value": "条笔记" + }, + { + "name": "Empty_page", + "value": "没有笔记" + }, + { + "name": "searchNote", + "value": "搜索笔记..." + }, + { + "name": "chooseFolder", + "value": "请选择文件夹" + }, + { + "name": "category_already_exist", + "value": "文件夹名称已存在" + }, + { + "name": "input_placeholder", + "value": "名称" + }, + { + "name": "permanently_delete_tips", + "value": "笔记删除前会显示剩余天数(最长30天),之后将永久删除" + }, + { + "name": "set_top", + "value": "置顶" + }, + { + "name": "move", + "value": "移到" + }, + { + "name": "recover", + "value": "恢复" + }, + { + "name": "check_all", + "value": "多选" + }, + { + "name": "editNoteTitle", + "value": "修改标题" + }, + { + "name": "list", + "value": "清单" + }, + { + "name": "style", + "value": "样式" + }, + { + "name": "photo", + "value": "相册" + }, + { + "name": "title", + "value": "标题" + }, + { + "name": "empty_note", + "value": "笔记内容为空" + }, + { + "name": "restore", + "value": "已恢复" + } + ] +} \ No newline at end of file diff --git a/product/phone/src/main/config.json b/product/phone/src/main/config.json index d3f9ca3..de43749 100644 --- a/product/phone/src/main/config.json +++ b/product/phone/src/main/config.json @@ -67,6 +67,20 @@ "autoDesignWidth": false } } + ], + "reqPermissions": [ + { + "name": "ohos.permission.READ_MEDIA", + "reason": "$string:per_read_media" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "$string:per_get_bundleInfo" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "$string:per_dis_dataSync" + } ] } } \ No newline at end of file diff --git a/product/phone/src/main/ets/AbilityStage.ts b/product/phone/src/main/ets/AbilityStage.ts index 71e62c4..9eb7993 100644 --- a/product/phone/src/main/ets/AbilityStage.ts +++ b/product/phone/src/main/ets/AbilityStage.ts @@ -1,18 +1,3 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { diff --git a/product/phone/src/main/ets/MainAbility/MainAbility.ts b/product/phone/src/main/ets/MainAbility/MainAbility.ts index ffe9641..ef95f8f 100644 --- a/product/phone/src/main/ets/MainAbility/MainAbility.ts +++ b/product/phone/src/main/ets/MainAbility/MainAbility.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,10 +14,28 @@ */ import Ability from '@ohos.application.Ability' +import {WebViewUtil} from './WebViewUtil.ets' +import fileio from '@ohos.fileio' export default class MainAbility extends Ability { onCreate(want, launchParam) { console.log("MainAbility onCreate, launchReason is " + launchParam.launchReason) + if (launchParam.launchReason == 3) { + // 获取对端的迁移数据 + let continueFolder: string = want.parameters["ContinueFolder"] + let continueNote: string = want.parameters["ContinueNote"] + let continueSection: number = want.parameters["ContinueSection"] + // 迁移数据存入AppStorage + AppStorage.SetOrCreate('ContinueFolder', continueFolder) + AppStorage.SetOrCreate('ContinueNote', continueNote) + AppStorage.SetOrCreate('ContinueSection', continueSection) + // 设置迁移标记 + AppStorage.SetOrCreate('IsContinue', 1) + this.context.restoreWindowStage(null) + } + AppStorage.SetOrCreate('openPhoto', 0) + AppStorage.SetOrCreate('openPerm', 0) + globalThis.noteContext = this.context } onDestroy() { @@ -39,5 +57,14 @@ export default class MainAbility extends Ability { onBackground() { console.log("MainAbility onBackground") + let controllerShow = WebViewUtil.getWebController() + if (controllerShow == undefined || controllerShow == null) { + console.info("MainAbility onBackground, controllerShow is error") + } + console.log("MainAbility controllerShow : " + controllerShow) + controllerShow.runJavaScript({ + script: "get_html_content()" + }) + console.log("MainAbility controllerShow end") } -} +} \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/WebViewUtil.ets b/product/phone/src/main/ets/MainAbility/WebViewUtil.ets new file mode 100644 index 0000000..44ed6a2 --- /dev/null +++ b/product/phone/src/main/ets/MainAbility/WebViewUtil.ets @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * WebView Util + */ +export class WebViewUtil { + private static controllerShow: WebController + + private constructor() { + + } + + public static getWebController(): WebController{ + console.info('WebViewUtil, getWebController') + if (!this.controllerShow && AppStorage.Get('openPhoto') == 0 && AppStorage.Get('openPerm') == 0) { + console.info('WebViewUtil, controllerShow is null') + this.controllerShow = new WebController() + } + return this.controllerShow + } + +} \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/app.ets b/product/phone/src/main/ets/MainAbility/app.ets index 64e6325..1e6c8b3 100644 --- a/product/phone/src/main/ets/MainAbility/app.ets +++ b/product/phone/src/main/ets/MainAbility/app.ets @@ -1,4 +1,19 @@ -import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' const TAG = "NoteApp" diff --git a/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets b/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets index c4753e0..1012e8b 100644 --- a/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets +++ b/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets @@ -14,9 +14,11 @@ */ import fileio from '@ohos.fileio' +import bundle from '@ohos.bundle' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import {NoteHomeComp} from './NoteHome.ets' import {NoteHomePortraitComp} from './NoteHomePortrait.ets' -import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets' @Entry @@ -44,19 +46,54 @@ export struct MyNoteHomeComp { LogUtil.info(this.TAG, "aboutToAppear") if (this.context == undefined || this.context == null) { - LogUtil.error(this.TAG, "context is error") + LogUtil.warn(this.TAG, "context is error") return } - LogUtil.info(this.TAG, "databaseDir is " + this.context.databaseDir) - // /data/storage/el2/database/tablet + let permissionList: Array = [ + "ohos.permission.READ_MEDIA", + "ohos.permission.DISTRIBUTED_DATASYNC" + ] + bundle.getApplicationInfo('com.ohos.note', 0, 100).then((appInfo) => { + let tokenId = appInfo.accessTokenId + let statusPromise: Array> = [] + let requestList: Array = [] + let atManager = abilityAccessCtrl.createAtManager() + for (let i = 0; i < permissionList.length; i++) { + statusPromise.push(atManager.verifyAccessToken(tokenId, permissionList[i])) + } + Promise.all(statusPromise).then((status) => { + for (let i = 0; i < status.length; i++) { + if (status[i] == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { + requestList.push(permissionList[i]) + } + } + if (requestList.length != 0) { + AppStorage.SetOrCreate('openPerm', 1) + LogUtil.info(this.TAG, 'permissions need to require from user: ' + requestList) + this.context.requestPermissionsFromUser(requestList).then((data) => { + LogUtil.info(this.TAG, 'data permissions : ' + data.permissions) + LogUtil.info(this.TAG, 'data result: ' + data.authResults) + let sum = 0 + for (let i = 0; i < data.authResults.length; i++) { + sum += data.authResults[i] + } + LogUtil.info(this.TAG, 'request permissions sum: ' + sum) + AppStorage.SetOrCreate('openPerm', 0) + }, (err) => { + LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code); + }); + } else { + LogUtil.info(this.TAG, 'check all permissions are granted.') + } + }) + }) - let dbPath = "/data/app/el2/100/database/com.ohos.note/phone/db/note.db" + let dbPath = this.context.databaseDir + "/db/note.db" try { - if (fileio.accessSync(dbPath) == undefined) { - LogUtil.info(this.TAG, "db has created") - RdbStoreUtil.initAppStorage(this.context) - } + fileio.accessSync(dbPath) + LogUtil.info(this.TAG, "db has created") + RdbStoreUtil.initAppStorage(this.context) } catch (err) { LogUtil.info(this.TAG, "db has not created, start to create db") RdbStoreUtil.createRdbStore(this.context) diff --git a/product/phone/src/main/ets/MainAbility/pages/NoteHome.ets b/product/phone/src/main/ets/MainAbility/pages/NoteHome.ets index a89a12c..54175a3 100644 --- a/product/phone/src/main/ets/MainAbility/pages/NoteHome.ets +++ b/product/phone/src/main/ets/MainAbility/pages/NoteHome.ets @@ -17,7 +17,7 @@ import {FolderListComp} from '../../../../../../../common/component/src/main/ets import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets' import {NoteContentComp} from '../../../../../../../common/component/src/main/ets/default/NoteContentComp' import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets' -import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets' import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets' import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets' @@ -33,7 +33,7 @@ export struct NoteHomeComp { @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray') @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] -// 当前文件夹、笔记、分栏 + // 当前文件夹、笔记、分栏 @Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder') @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note') @Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section') @@ -60,7 +60,6 @@ export struct NoteHomeComp { .visibility( LayoutUtil.getWidthWeightMessage(this.sectionStatus) .folderListVisibility == 0 ? Visibility.None : Visibility.Visible) - .opacity(this.search ? StyleConstants.OPACITY_40 : StyleConstants.OPACITY_100) .enabled(this.search ? false : true) Divider() @@ -92,10 +91,9 @@ export struct NoteHomeComp { NoteContentComp() } .flexShrink(0) - .backgroundColor(this.search && this.inputKeyword.length == 0 ? $r("app.color.notecontent_color_000000") : $r("app.color.notecontent_color_ffffff")) + .backgroundColor($r("app.color.notecontent_color_ffffff")) .width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).noteCotentWeight) .height(StyleConstants.PERCENTAGE_100) - .opacity(this.longpress ? StyleConstants.OPACITY_40 : this.search && this.inputKeyword.length == 0 ? StyleConstants.OPACITY_20 : StyleConstants.OPACITY_100) .enabled(this.longpress || this.search && this.inputKeyword.length == 0 ? false : true) } .width(StyleConstants.PERCENTAGE_100).height(StyleConstants.PERCENTAGE_100) diff --git a/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets b/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets index cdc6742..7fef717 100644 --- a/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets +++ b/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets @@ -17,7 +17,7 @@ import {FolderListComp} from '../../../../../../../common/component/src/main/ets import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets' import {NoteContentCompPortrait} from '../../../../../../../common/component/src/main/ets/default/NoteContentCompPortrait.ets' import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets' -import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets' import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets' import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets' @@ -34,7 +34,7 @@ export struct NoteHomePortraitComp { @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] -// 当前文件夹、笔记、分栏 + // 当前文件夹、笔记、分栏 @Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder') @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note') @Provide('SectionStatus') sectionStatus: number = 1; // 表示分栏状态, 3表示三分栏, 2表示二分栏,1表示一分栏 diff --git a/product/phone/src/main/resources/base/element/string.json b/product/phone/src/main/resources/base/element/string.json index fb355ba..acd4635 100644 --- a/product/phone/src/main/resources/base/element/string.json +++ b/product/phone/src/main/resources/base/element/string.json @@ -163,6 +163,18 @@ { "name": "restore", "value": "已恢复" + }, + { + "name": "per_read_media", + "value": "是否允许备忘录访问媒体资源" + }, + { + "name": "per_get_bundleInfo", + "value": "是否允许备忘录打开图库资源" + }, + { + "name": "per_dis_dataSync", + "value": "是否允许备忘录流转到其它设备" } ] } \ No newline at end of file diff --git a/product/phone/src/main/resources/base/media/search.svg b/product/phone/src/main/resources/base/media/search.svg index 2dae1c5..948fa20 100644 --- a/product/phone/src/main/resources/base/media/search.svg +++ b/product/phone/src/main/resources/base/media/search.svg @@ -3,7 +3,7 @@ 搜索 '); } -RICH_EDITOR.insertImage = function() { - var url = './shuxue.png'; +RICH_EDITOR.insertImage = function(url) { + console.log("js,url:" + url) var html = '

picvision

'; RICH_EDITOR.insertHTML(html); RICH_EDITOR.editor.scrollIntoView(false) } RICH_EDITOR.insertHTML = function(html) { - RICH_EDITOR.restorerange(); document.execCommand('insertHTML', false, html); } @@ -303,4 +302,11 @@ function save_html_content() { var htmlString = encodeURI(RICH_EDITOR.getHtml()) var str = callBackToApp.callbackhtmlSave(htmlString) console.log('hhh objName.test result:' + str); +} + +function scheduled_save_content() { + console.info('scheduled_save_content') + var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var str = callBackToApp.callbackScheduledSave(htmlString) + console.info('scheduled_save_content end') } \ No newline at end of file diff --git a/common/component/src/main/resources/base/element/string.json b/product/phone/src/main/resources/zh_CN/element/string.json similarity index 85% rename from common/component/src/main/resources/base/element/string.json rename to product/phone/src/main/resources/zh_CN/element/string.json index 3b06a90..fb355ba 100644 --- a/common/component/src/main/resources/base/element/string.json +++ b/product/phone/src/main/resources/zh_CN/element/string.json @@ -135,6 +135,34 @@ { "name": "check_all", "value": "多选" + }, + { + "name": "editNoteTitle", + "value": "修改标题" + }, + { + "name": "list", + "value": "清单" + }, + { + "name": "style", + "value": "样式" + }, + { + "name": "photo", + "value": "相册" + }, + { + "name": "title", + "value": "标题" + }, + { + "name": "empty_note", + "value": "笔记内容为空" + }, + { + "name": "restore", + "value": "已恢复" } ] } \ No newline at end of file diff --git a/product/tablet/src/main/config.json b/product/tablet/src/main/config.json index 43f93b7..bc6af9f 100644 --- a/product/tablet/src/main/config.json +++ b/product/tablet/src/main/config.json @@ -71,27 +71,15 @@ "reqPermissions": [ { "name": "ohos.permission.READ_MEDIA", - "reason": "This is used to access photos and videos" + "reason": "$string:per_read_media" }, { - "name": "ohos.permission.WRITE_MEDIA", - "reason": "This is used to access photos and videos." - }, - { - "name": "ohos.permission.WRITE_EXTERNAL_MEDIA_MEMORY", - "reason": "This is used to access photos and videos." - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason": "This is used to access photos and videos." - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "reques permission" + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "$string:per_get_bundleInfo" }, { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason": "reques permission" + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "$string:per_dis_dataSync" } ] } diff --git a/product/tablet/src/main/ets/AbilityStage.ts b/product/tablet/src/main/ets/AbilityStage.ts index 71e62c4..9eb7993 100644 --- a/product/tablet/src/main/ets/AbilityStage.ts +++ b/product/tablet/src/main/ets/AbilityStage.ts @@ -1,18 +1,3 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { diff --git a/product/tablet/src/main/ets/MainAbility/MainAbility.ts b/product/tablet/src/main/ets/MainAbility/MainAbility.ts index 919c0b2..ef95f8f 100644 --- a/product/tablet/src/main/ets/MainAbility/MainAbility.ts +++ b/product/tablet/src/main/ets/MainAbility/MainAbility.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,6 +15,7 @@ import Ability from '@ohos.application.Ability' import {WebViewUtil} from './WebViewUtil.ets' +import fileio from '@ohos.fileio' export default class MainAbility extends Ability { onCreate(want, launchParam) { @@ -32,6 +33,9 @@ export default class MainAbility extends Ability { AppStorage.SetOrCreate('IsContinue', 1) this.context.restoreWindowStage(null) } + AppStorage.SetOrCreate('openPhoto', 0) + AppStorage.SetOrCreate('openPerm', 0) + globalThis.noteContext = this.context } onDestroy() { @@ -63,33 +67,4 @@ export default class MainAbility extends Ability { }) console.log("MainAbility controllerShow end") } - - onContinue(wantParam: { [key: string]: any }) { - console.log("MainAbility onContinue") - // 获取本端的迁移数据 - let continueFolder = AppStorage.Get('ContinueFolder') - if (continueFolder == undefined || continueFolder == null) { - console.log("MainAbility onContinue, continue first folder") - continueFolder = JSON.stringify(AppStorage.Get('AllFolderArray')[0].toFolderObject()) - } - - let continueNote = AppStorage.Get('ContinueNote') - if (continueNote == undefined || continueNote == null) { - console.log("MainAbility onContinue, continue first note") - continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject()) - } - - let continueSection = AppStorage.Get('ContinueSection') - if (continueSection == undefined || continueSection == null) { - console.log("MainAbility onContinue, continue section 3") - continueSection = 3 - } - - // 保存本端的迁移数据 - wantParam["ContinueFolder"] = continueFolder - wantParam["ContinueNote"] = continueNote - wantParam["ContinueSection"] = continueSection - - return true - } -} +} \ No newline at end of file diff --git a/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets b/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets index 27dd60f..44ed6a2 100644 --- a/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets +++ b/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets @@ -25,7 +25,7 @@ export class WebViewUtil { public static getWebController(): WebController{ console.info('WebViewUtil, getWebController') - if (!this.controllerShow) { + if (!this.controllerShow && AppStorage.Get('openPhoto') == 0 && AppStorage.Get('openPerm') == 0) { console.info('WebViewUtil, controllerShow is null') this.controllerShow = new WebController() } diff --git a/product/tablet/src/main/ets/MainAbility/app.ets b/product/tablet/src/main/ets/MainAbility/app.ets index 64e6325..1e6c8b3 100644 --- a/product/tablet/src/main/ets/MainAbility/app.ets +++ b/product/tablet/src/main/ets/MainAbility/app.ets @@ -1,4 +1,19 @@ -import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' const TAG = "NoteApp" diff --git a/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets b/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets index 8f6a548..874c354 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets @@ -14,9 +14,11 @@ */ import fileio from '@ohos.fileio' +import bundle from '@ohos.bundle' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import {NoteHomeComp} from './NoteHome.ets' import {NoteHomePortraitComp} from './NoteHomePortrait.ets' -import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets' @Entry @@ -28,7 +30,7 @@ export struct MyNoteHomeComp { TAG = "MyNoteHomeComp" build() { - Flex() { + Row() { if (this.dBQueryFinished == 1) { if (this.portraitModel == true) { NoteHomePortraitComp() @@ -45,19 +47,54 @@ export struct MyNoteHomeComp { LogUtil.info(this.TAG, "aboutToAppear") if (this.context == undefined || this.context == null) { - LogUtil.error(this.TAG, "context is error") + LogUtil.warn(this.TAG, "context is error") return } - LogUtil.info(this.TAG, "databaseDir is " + this.context.databaseDir) - // /data/storage/el2/database/tablet + let permissionList: Array = [ + "ohos.permission.READ_MEDIA", + "ohos.permission.DISTRIBUTED_DATASYNC" + ] + bundle.getApplicationInfo('com.ohos.note', 0, 100).then((appInfo) => { + let tokenId = appInfo.accessTokenId + let statusPromise: Array> = [] + let requestList: Array = [] + let atManager = abilityAccessCtrl.createAtManager() + for (let i = 0; i < permissionList.length; i++) { + statusPromise.push(atManager.verifyAccessToken(tokenId, permissionList[i])) + } + Promise.all(statusPromise).then((status) => { + for (let i = 0; i < status.length; i++) { + if (status[i] == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { + requestList.push(permissionList[i]) + } + } + if (requestList.length != 0) { + AppStorage.SetOrCreate('openPerm', 1) + LogUtil.info(this.TAG, 'permissions need to require from user: ' + requestList) + this.context.requestPermissionsFromUser(requestList).then((data) => { + LogUtil.info(this.TAG, 'data permissions : ' + data.permissions) + LogUtil.info(this.TAG, 'data result: ' + data.authResults) + let sum = 0 + for (let i = 0; i < data.authResults.length; i++) { + sum += data.authResults[i] + } + LogUtil.info(this.TAG, 'request permissions sum: ' + sum) + AppStorage.SetOrCreate('openPerm', 0) + }, (err) => { + LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code); + }); + } else { + LogUtil.info(this.TAG, 'check all permissions are granted.') + } + }) + }) - let dbPath = "/data/app/el2/100/database/com.ohos.note/tablet/db/note.db" + let dbPath = this.context.databaseDir + "/db/note.db" try { - if (fileio.accessSync(dbPath) == undefined) { - LogUtil.info(this.TAG, "db has created") - RdbStoreUtil.initAppStorage(this.context) - } + fileio.accessSync(dbPath) + LogUtil.info(this.TAG, "db has created") + RdbStoreUtil.initAppStorage(this.context) } catch (err) { LogUtil.info(this.TAG, "db has not created, start to create db") RdbStoreUtil.createRdbStore(this.context) diff --git a/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets b/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets index a316dcf..7251496 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets @@ -17,7 +17,7 @@ import {FolderListComp} from '../../../../../../../common/component/src/main/ets import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets' import {NoteContentComp} from '../../../../../../../common/component/src/main/ets/default/NoteContentComp' import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets' -import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets' import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets' import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets' @@ -25,6 +25,7 @@ import {SysDefFolderUuid} from '../../../../../../../common/utils/src/main/ets/d import LayoutUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets' import NoteUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets' import {WebViewUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets' +import mediaquery from '@ohos.mediaquery' @Entry @Component @@ -34,7 +35,7 @@ export struct NoteHomeComp { @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray') @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] -// 当前文件夹、笔记、分栏 + // 当前文件夹、笔记、分栏 @Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder') @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note') @Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section') @@ -52,6 +53,13 @@ export struct NoteHomeComp { TAG = "NoteHomeComp" + narrowWinListener = mediaquery.matchMediaSync('(width < 2000)') + onWinSizeChange(mediaQueryResult) { + if (this.sectionStatus != 1) { + this.sectionStatus = (mediaQueryResult.matches) ? 2 : 3 + } + } + build() { Flex({ justifyContent: FlexAlign.Start }) { // Folder list display area @@ -60,47 +68,44 @@ export struct NoteHomeComp { } .flexShrink(0) .backgroundColor($r("app.color.folderlist_bgcolor_f1f3f5")) - .width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).folderListWeight) + .width(200) .height(StyleConstants.PERCENTAGE_100) .visibility( LayoutUtil.getWidthWeightMessage(this.sectionStatus) .folderListVisibility == 0 ? Visibility.None : Visibility.Visible) - .opacity(this.search ? StyleConstants.OPACITY_40 : StyleConstants.OPACITY_100) .enabled(this.search ? false : true) - Divider() - .vertical(true) - .strokeWidth(1) - .color($r("app.color.divider_color_182431")) - .height("100%") - .opacity(StyleConstants.OPACITY_10) // Note list display area Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { + Divider() + .vertical(true) + .strokeWidth(1) + .color($r("app.color.divider_color_182431")) + .height("100%") + .opacity(StyleConstants.OPACITY_10) NoteListComp({ controllerShow: this.controllerShow }) } .flexShrink(0) .backgroundColor($r("app.color.notelist_bgcolor_f1f3f5")) - .width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).noteListWeight) + .layoutWeight(2) .height(StyleConstants.PERCENTAGE_100) .visibility( LayoutUtil.getWidthWeightMessage(this.sectionStatus) .noteListVisibility == 0 ? Visibility.None : Visibility.Visible) - - Divider() - .vertical(true) - .strokeWidth(1) - .color($r("app.color.divider_color_182431")) - .height("100%") - .opacity(StyleConstants.OPACITY_10) // Note content display area Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { + Divider() + .vertical(true) + .strokeWidth(1) + .color($r("app.color.divider_color_182431")) + .height("100%") + .opacity(StyleConstants.OPACITY_10) NoteContentComp({ controllerShow: this.controllerShow }) } .flexShrink(0) - .backgroundColor(this.search && this.inputKeyword.length == 0 ? $r("app.color.notecontent_color_000000") : $r("app.color.notecontent_color_ffffff")) - .width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).noteCotentWeight) + .backgroundColor($r("app.color.notecontent_color_ffffff")) + .layoutWeight(this.sectionStatus != 1 ? 3 : null) .height(StyleConstants.PERCENTAGE_100) - .opacity(this.longpress ? StyleConstants.OPACITY_40 : this.search && this.inputKeyword.length == 0 ? StyleConstants.OPACITY_20 : StyleConstants.OPACITY_100) .enabled(this.longpress || this.search && this.inputKeyword.length == 0 ? false : true) } .width(StyleConstants.PERCENTAGE_100) @@ -109,6 +114,8 @@ export struct NoteHomeComp { aboutToAppear(): void{ LogUtil.info(this.TAG, "aboutToAppear") + this.narrowWinListener.on('change', this.onWinSizeChange.bind(this)) + this.sectionStatus = this.narrowWinListener.matches ? 2 : 3 } aboutToDisappear(): void{ diff --git a/product/tablet/src/main/ets/MainAbility/pages/NoteHomePortrait.ets b/product/tablet/src/main/ets/MainAbility/pages/NoteHomePortrait.ets index 123fd53..5968cae 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/NoteHomePortrait.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/NoteHomePortrait.ets @@ -17,7 +17,7 @@ import {FolderListComp} from '../../../../../../../common/component/src/main/ets import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets' import {NoteContentComp} from '../../../../../../../common/component/src/main/ets/default/NoteContentComp' import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets' -import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets' import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets' import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets' @@ -30,7 +30,7 @@ export struct NoteHomePortraitComp { @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray') @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] -// 当前文件夹、笔记、分栏 + // 当前文件夹、笔记、分栏 @Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder') @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note') @Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section') diff --git a/product/tablet/src/main/resources/base/element/string.json b/product/tablet/src/main/resources/base/element/string.json index fb355ba..b27e571 100644 --- a/product/tablet/src/main/resources/base/element/string.json +++ b/product/tablet/src/main/resources/base/element/string.json @@ -102,7 +102,7 @@ }, { "name": "searchNote", - "value": "搜索笔记" + "value": "搜索笔记..." }, { "name": "chooseFolder", @@ -163,6 +163,18 @@ { "name": "restore", "value": "已恢复" + }, + { + "name": "per_read_media", + "value": "是否允许备忘录访问媒体资源" + }, + { + "name": "per_get_bundleInfo", + "value": "是否允许备忘录打开图库资源" + }, + { + "name": "per_dis_dataSync", + "value": "是否允许备忘录流转到其它设备" } ] } \ No newline at end of file diff --git a/product/tablet/src/main/resources/base/media/search.svg b/product/tablet/src/main/resources/base/media/search.svg index 2dae1c5..948fa20 100644 --- a/product/tablet/src/main/resources/base/media/search.svg +++ b/product/tablet/src/main/resources/base/media/search.svg @@ -3,7 +3,7 @@ 搜索 '); } -RICH_EDITOR.insertImage = function() { - var url = './shuxue.png'; +RICH_EDITOR.insertImage = function(url) { + console.log("js,url:" + url) var html = '

picvision

'; RICH_EDITOR.insertHTML(html); RICH_EDITOR.editor.scrollIntoView(false) } RICH_EDITOR.insertHTML = function(html) { - RICH_EDITOR.restorerange(); document.execCommand('insertHTML', false, html); } @@ -303,4 +302,11 @@ function save_html_content() { var htmlString = encodeURI(RICH_EDITOR.getHtml()) var str = callBackToApp.callbackhtmlSave(htmlString) console.log('hhh objName.test result:' + str); +} + +function scheduled_save_content() { + console.info('scheduled_save_content') + var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var str = callBackToApp.callbackScheduledSave(htmlString) + console.info('scheduled_save_content end') } \ No newline at end of file diff --git a/product/tablet/src/main/resources/zh_CN/element/string.json b/product/tablet/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..a48ce08 --- /dev/null +++ b/product/tablet/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,168 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "备忘录" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + }, + { + "name": "note", + "value": "笔记" + }, + { + "name": "allNotes", + "value": "全部笔记" + }, + { + "name": "unClassified", + "value": "未分类" + }, + { + "name": "recentDeletes", + "value": "最近删除" + }, + { + "name": "myFavorites", + "value": "我的收藏" + }, + { + "name": "create", + "value": "新建" + }, + { + "name": "createFolder", + "value": "新建文件夹" + }, + { + "name": "editFolder", + "value": "编辑文件夹" + }, + { + "name": "deleteFolder", + "value": "删除文件夹" + }, + { + "name": "createNote", + "value": "新建笔记" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "save", + "value": "保存" + }, + { + "name": "delete", + "value": "删除" + }, + { + "name": "name", + "value": "名称" + }, + { + "name": "delete_tips", + "value": "是否删除此文件夹及其中的内容?" + }, + { + "name": "deleteNote", + "value": "是否删除此笔记?" + }, + { + "name": "deleteNoteComplete", + "value": "此笔记将被永久删除,无法恢复。是否删除?" + }, + { + "name": "deleteAllNote", + "value": "是否删除全部笔记?" + }, + { + "name": "deletePartNote", + "value": "是否删除%d条笔记?" + }, + { + "name": "selected", + "value": "已选择%d项" + }, + { + "name": "none_selected", + "value": "未选择" + }, + { + "name": "noteslist", + "value": "条笔记" + }, + { + "name": "Empty_page", + "value": "没有笔记" + }, + { + "name": "searchNote", + "value": "搜索笔记..." + }, + { + "name": "chooseFolder", + "value": "请选择文件夹" + }, + { + "name": "category_already_exist", + "value": "文件夹名称已存在" + }, + { + "name": "input_placeholder", + "value": "名称" + }, + { + "name": "permanently_delete_tips", + "value": "笔记删除前会显示剩余天数(最长30天),之后将永久删除" + }, + { + "name": "set_top", + "value": "置顶" + }, + { + "name": "move", + "value": "移到" + }, + { + "name": "recover", + "value": "恢复" + }, + { + "name": "check_all", + "value": "多选" + }, + { + "name": "editNoteTitle", + "value": "修改标题" + }, + { + "name": "list", + "value": "清单" + }, + { + "name": "style", + "value": "样式" + }, + { + "name": "photo", + "value": "相册" + }, + { + "name": "title", + "value": "标题" + }, + { + "name": "empty_note", + "value": "笔记内容为空" + }, + { + "name": "restore", + "value": "已恢复" + } + ] +} \ No newline at end of file diff --git a/signature/notes.p7b b/signature/notes.p7b new file mode 100644 index 0000000000000000000000000000000000000000..fdbebb05316a5bb11e3c0a40c2f5a3e3bb2ae28d GIT binary patch literal 3426 zcmcgvYj6|S8MPiZF(7PWz~BNl!od_Qd{>ri$tfhe(rP8aN?sw^mLpxY$8KJZ;)-4SIm;r46ATcJ|-$KQ)^Y4GPP2zDelUXK9-8|=`xL0 zRbI-cXBW%eaoQWA6hYd@2-Ce(6BS}2R8-ML-5Q~2BN+`dbThwBA2J>)$_9Nw56KFw z6~YfeF_Wc0huZ8WgGmS5(XOnE#!V(2p491JH|2*p69W59C~4J|B=sGu+t7VSgiaTYy^k;o%$+*n2K_2r3b5uPsa?+?rLqEvZJ*) z;=y3Zf$9=CVJ}5O?uJ0X6NZ}Hbc4SNs|vViw;ip=b!Zm~PT=IzD53`8+*qjIS!0X1 zl`200P|g_eSnzt3!|UN@o`c<#u-frNHJ`QU8xnXuo_L(AM;M%laXO-lBZhKjy}cfF z;E1W4R{)>pqMuqbf!X1j?(dA*QB=#-R;x|U8Z+xws?{cgE##~QiK%)x+>OEQF4_p5 zLZJrEgC!zPr2&w9EldV;$jyJRN9o|I?XVs3dwQyCLWD}Y=m>Z|#D5i(2{fONihGZ1d zxDPe>NE2&I!qzS{p+R7u21Q_8hp1rAC{)x2tO(*n4V7#n8V`hAw8w@JF|(KR)HY6w zYZ;59%1`1jhv{^U*mPW_=0@jl-%+(U61Z-wWP)R5wD!nOQ5{bF!X}EWqPVXnw z4kHu-h^i6`AR*lE4Jwm94c(xPMaU#dm`Xs6g^T!D4FQ`tFk zC%ad+z)q22Xe<~b3`uhGdJn;oNJy|3o_~Q32BULjN(d-{5>oO{b#1OprG=EGP)`UV zKavChle$S1J�Xl<@^aRDrGAp@9?RWc2GQgILs44~eLs1WA)tpAi4EW9y#FaO1(D zM}9T_-Cc(Ad9u~{qJQj~@W(|L&RrUfZ!iB|a_YN7w0NTZwfv9&)J81N9QKD5s^b!R z;i2L0ZnA+&kk8W@HC8$t3~L$k*VcCVu)hr0Ftz>sE3-PjOP{?_fq_8+AWI~AB$Z0U z{aU~%As!?hCLQtxdG(`hNz0iNzux=H>*)`EsFR6oefLZfOaneKl(uup?#z_CdAG4} zFminv)e*?p^YXfE&M@V{^^L3BFC$C6=X~E^+IIWW;*7GH4}ZIkpVHP^pZwg>dhhp{=Gf6Lm->qpP)=SYu!vMy;B z_T>TsKXU8FgK^zkm;b!2voQ?&l!zb|r0FH1uJ8piX#&|##FIYp7t%Dj#GNL^%g#41 zZ;;JfdsAjU^l&_L!vlw>&gxJMSljf`HK+6B8*4Vcp1SwpX{Quhh-0fGE0HZb+irK% z-M4QYIOx3Rouyx4gEze;yKrF3#`|?c?~lu07(HL`(@{jsX_`~s5Bqi#0$vAMf>3e< z;iLlz|LChEQARH%3k zYTenIeM@&2ZSBAK#J~d;9i!iBnV?R(wrm)wSbyeoMmjd=EMnJ)LE-y_Z!XXTR znY_T=>t#lex>VU)M?&~w9Pv348ngb!;dLM6s&_3oy1DM}SK(KRq*wCZyLFnKr`x?f zYS*8KU| zw@$7eGym?~nfoT@-@SI^(vo`$$0iRT`vJC~4GB2IR(|ETJ{SHGSFr9?0Z4XT@itikAuu~D2qQ7m7o+-11*0ps%t^XlTj%o zmloW)czwx`I}?g;Ot}d9mlP(OZ?tAcZhyLL{-5vFi7g|Pp#S5OTr9-^DlQm#T#-f1 znkbJPUbd+C%XwerXtG_>Lhf|z-lH3*XWlz59+UPqw)SXN{_MFMa__4Bp)q+QpktR8 QoGK^gtibA8X6?`UFQ&y$wg3PC literal 0 HcmV?d00001 -- Gitee