diff --git a/common/component/src/main/config.json b/common/component/src/main/config.json index fa515b0725fc39f4bfa8be8a68adaedc86b6fc26..bebec2df71bc8a029e52347089b9509db2af3695 100644 --- a/common/component/src/main/config.json +++ b/common/component/src/main/config.json @@ -3,8 +3,8 @@ "bundleName": "com.ohos.note", "vendor": "ohos", "version": { - "code": 1000000, - "name": "1.0.0" + "code": 1000003, + "name": "1.0.3" } }, "deviceConfig": {}, diff --git a/common/component/src/main/ets/default/CusDialogComp.ets b/common/component/src/main/ets/default/CusDialogComp.ets index cb3939254b131fe9ba124e775851ee54c30997e8..addde37ac313d6668643a591da793d2ee2d3eb3f 100644 --- a/common/component/src/main/ets/default/CusDialogComp.ets +++ b/common/component/src/main/ets/default/CusDialogComp.ets @@ -60,7 +60,7 @@ export struct NewOrEditFolderDialog { .maxLength(20) .borderRadius(15) .backgroundColor($r("app.color.New_folder_input_box_color")) - .width('90%') + .width('100%') .onChange((value: string) => { this.inputName = value FolderUtil.duplicateDetection(this.inputName, this.AllFolderArray).then(result => { @@ -69,15 +69,17 @@ export struct NewOrEditFolderDialog { }) }.margin({ bottom: 4, left: 24, right: 24 }) + Divider() + .height(1) + .margin({ left: 64, right: 24 }) + .color((this.isExisted && this.inputName != this.oriInputName) ? $r("app.color.category_already_exist_divider_color"):$r("app.color.divider_color_182431")) + Text($r("app.string.category_already_exist")) .fontSize(10) - .margin({ left: 64 }) + .margin({ left: 64, top: 4 }) .fontColor($r("app.color.category_already_exist_font_color")) .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")) @@ -305,6 +307,7 @@ export struct NoteDataMoveDialog { Flex({ alignItems: ItemAlign.Center }) { Text($r("app.string.chooseFolder")) .fontSize(20) + .fontWeight(600) }.height(56) .width(288) @@ -325,7 +328,7 @@ export struct NoteDataMoveDialog { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text($r("app.string.cancel")) .fontSize(16) - .fontColor($r("app.color.text_color_3f97e9")) + .fontColor($r("app.color.button_color_f86d05")) .onClick(() => { this.noteDataMoveDialogCtl.close() }) diff --git a/common/component/src/main/ets/default/FolderListComp.ets b/common/component/src/main/ets/default/FolderListComp.ets index 725a512174bcefd947ad0a65a7f060a2e3ee9460..3dc257fb40d0a2f822e9c678f9f9f5e951026a99 100644 --- a/common/component/src/main/ets/default/FolderListComp.ets +++ b/common/component/src/main/ets/default/FolderListComp.ets @@ -42,7 +42,6 @@ export struct FolderListComp { .onClick(() => { if (this.sectionStatus == 1) { this.expandStatus = !this.expandStatus - AppStorage.SetOrCreate('ContinueExpand', this.expandStatus) } else { this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) // save continue data @@ -56,7 +55,7 @@ export struct FolderListComp { .padding({ left: 24 }) NoteAndCreateComp() - // center + // center List() { ForEach(this.AllFolderArray, (folderItem: FolderData) => { ListItem() { @@ -67,6 +66,7 @@ export struct FolderListComp { }, folderItem => folderItem.name.toString()) }.width('100%') .padding({ left: 12, right: 12 }) + Blank() Column() { FolderItemComp({ @@ -92,7 +92,6 @@ export struct FolderListComp { aboutToDisappear(): void{ LogUtil.info(this.TAG, "aboutToDisappear") } - } @Component @@ -362,7 +361,11 @@ struct FolderItemComp { this.selectedFolderData = this.folderItem this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.folderItem.uuid) // 刷新web界面 - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) + if (this.portraitModel == false) { + 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) diff --git a/common/component/src/main/ets/default/NoteContent.ets b/common/component/src/main/ets/default/NoteContent.ets index 4ca57ec884dd3e48c5cf8f31c75e18a455d48062..be09721f64f64ef66565d35add69f251f6f224fe 100644 --- a/common/component/src/main/ets/default/NoteContent.ets +++ b/common/component/src/main/ets/default/NoteContent.ets @@ -37,9 +37,10 @@ var timeID: number @Component export struct NoteContent { - @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get("NewNote") + @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote') @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @Provide('Issave') issave: number = 0 + @Provide('EditModel') editModel: boolean = false controllerShow: WebController private editContentFlag = false @@ -49,12 +50,13 @@ export struct NoteContent { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) 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.uuid) AppStorage.SetOrCreate('NewNote', this.selectedNoteData) + AppStorage.SetOrCreate('needRefresh',true) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) @@ -66,7 +68,7 @@ export struct NoteContent { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) @@ -80,11 +82,11 @@ export struct NoteContent { 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 }) - } + }.margin({ left: 24, right: 24 }) Column() { NoteContentOverViewComp() @@ -106,22 +108,22 @@ export struct NoteContent { this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) }) .zoomAccess(false) - .height(450) + .height('70%') .width('100%') } - .margin({ top: 16 }) + .margin({ left: 12, right: 24, top: 16 }) .width(StyleConstants.PERCENTAGE_100) .onClick(() => { - this.issave = 0 // 添加定时器:3s自动保存 timeID = setInterval(() => { this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) }, 3000) LogUtil.info(TAG, "setInterval timeID : " + timeID) + this.issave = 0 + this.editModel = true }) } .height(StyleConstants.PERCENTAGE_100) - .margin({ left: 24, right: 24 }) } .height(StyleConstants.PERCENTAGE_100) .width(StyleConstants.PERCENTAGE_100) @@ -141,6 +143,7 @@ export struct ToolBarComp { @Consume('SelectedNoteData') selectedNoteData: NoteData @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @Consume('Issave') issave: number + @Consume('EditModel') editModel: boolean controllerShow: WebController editContentDialogCtl: CustomDialogController = new CustomDialogController({ @@ -157,7 +160,7 @@ export struct ToolBarComp { build() { Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Image($r('app.media.zoom')) + Image($r('app.media.narrow')) .height(24) .width(24) .onClick(() => { @@ -168,131 +171,141 @@ export struct ToolBarComp { LogUtil.info(TAG, "zoom, clearInterval timeID : " + timeID) clearInterval(timeID) } - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); router.back() }) .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) - Row({ space: StyleConstants.SPACE_6 }) { - Button({ type: ButtonType.Normal, stateEffect: true }) { - Image($r('app.media.circle_tick1')) - .height(24) - .width(24) - .onClick(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - // 清单 - 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.font_style')) - .height(24) - .width(24) + if (this.editModel == false) { + Row({ space: StyleConstants.SPACE_24 }) { + Image(this.selectedNoteData.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel')) + .height(24).width(24) .onClick(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - LogUtil.info(TAG, 'editContentDialogCtl start') - this.editContentDialogCtl.open() + this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes) + // update note to db + let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) + predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) + RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, 'ToolBarComp, set continue note success') }) - }.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) - .onClick(async () => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - LogUtil.info(TAG, 'startAbility start') - AppStorage.SetOrCreate('openPhoto', 1) - await globalThis.noteContext.startAbilityForResult({ - parameters: { uri: "singleselect" }, - bundleName: "com.ohos.photos", - abilityName: "com.ohos.photos.MainAbility", + }.width(36) + .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) + } else { + Row({ space: StyleConstants.SPACE_6 }) { + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.circle_tick1')) + .height(24) + .width(24) + .onClick(() => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + // 清单 + this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" }) }) - .then(v => { - AppStorage.SetOrCreate('openPhoto', 0) - let want = v['want']; - if (want != null && want != undefined) { - let param = want['parameters']; - let imageUri = "" - if (param != null && param != undefined) { - let uri = param['select-item-list']; - imageUri = uri; - } - // 拷贝 - if(imageUri != null && imageUri != "") { - OperationUtils.copy(imageUri).then((uriPath) => { - var path = "file://" + uriPath - LogUtil.info(TAG, 'image uri is:' + path) - this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"}) - }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Image($r('app.media.font_style')) + .height(24) + .width(24) + .onClick(() => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + LogUtil.info(TAG, 'editContentDialogCtl start') + 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) + .onClick(async () => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + LogUtil.info(TAG, 'startAbility start') + await globalThis.noteContext.startAbilityForResult({ + parameters: { uri: "singleselect" }, + bundleName: "com.ohos.photos", + abilityName: "com.ohos.photos.MainAbility", + }) + .then(v => { + let want = v['want']; + if (want != null && want != undefined) { + let param = want['parameters']; + let imageUri = "" + if (param != null && param != undefined) { + let uri = param['select-item-list']; + imageUri = uri; + } + // 拷贝 + if(imageUri != null && imageUri != "") { + OperationUtils.copy(imageUri).then((uriPath) => { + var path = "file://" + uriPath + LogUtil.info(TAG, 'image uri is:' + path) + this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"}) + }) + } } - } - }); - }) - }.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) - .fillColor(this.issave == 0 ? Color.Black : Color.Grey) - .onClick(() => { - this.issave = 1 - // 清除定时器 - if (timeID != undefined) { - LogUtil.info(TAG, "tick_thick, clearInterval timeID : " + timeID) - clearInterval(timeID) - } - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - // 保存笔记信息到数据库 - this.controllerShow.runJavaScript({ script: "get_html_content()" }) - }) - }.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(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - 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(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" }) - }) - }.width(42) - .height(42) - .borderRadius(8) - .backgroundColor($r('app.color.color_ffffff')) - }.width(274) + }); + }) + }.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(() => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + 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(() => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + this.controllerShow.runJavaScript({ script: "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_thick')) + .height(24) + .width(24) + .fillColor(this.issave == 0 ? Color.Black : Color.Grey) + .onClick(() => { + this.issave = 1 + // 保存笔记信息到数据库 + this.controllerShow.runJavaScript({ script: "get_html_content()" }) + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + }.width(274) + } } .width(StyleConstants.PERCENTAGE_100) .height(80) @@ -354,7 +367,9 @@ export struct NoteContentOverViewComp { Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Row() { - Text(this.selectedNoteData.title).fontSize(30) + Text(this.selectedNoteData.title) + .fontSize(30) + .margin({ left: 12, right: 24 }) .onClick(() => { this.editTitleDialogCtl.open() }) @@ -366,9 +381,11 @@ export struct NoteContentOverViewComp { .fontSize(12) .padding({ top: 4, bottom: 4 }) .fontColor($r("app.color.modified_time_font_color")) + .margin({ left: 12 }) Row() { Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid))) .fontSize(12) + .fontColor($r("app.color.list_modified_time_font_color")) Image($r('app.media.triangle')) .width(6) .height(12) diff --git a/common/component/src/main/ets/default/NoteContentComp.ets b/common/component/src/main/ets/default/NoteContentComp.ets index 7aca88005e6954a524ca19ca0183445049c0a014..fe32406bde5c688209c938ea8acac931e986bda2 100644 --- a/common/component/src/main/ets/default/NoteContentComp.ets +++ b/common/component/src/main/ets/default/NoteContentComp.ets @@ -54,7 +54,7 @@ export struct NoteContentComp { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) @@ -71,7 +71,7 @@ export struct NoteContentComp { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) @@ -91,7 +91,7 @@ export struct NoteContentComp { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) @@ -111,9 +111,10 @@ export struct NoteContentComp { Column() { ToolBarComp({ controllerShow: this.controllerShow }) } + .margin({ left: 24, right: 24 }) Column() { - NoteContentOverViewComp() + NoteContentOverViewComp({ controllerShow: this.controllerShow }) Text(this.refreshFlag.toString()).visibility(Visibility.None) Text(this.AllNoteArray.length.toString()).visibility(Visibility.None) // 用于强制刷新使用 @@ -138,20 +139,22 @@ export struct NoteContentComp { } }) .zoomAccess(false) - .height(450) + .height('70%') .width('100%') } - .margin({ top: 16 }) + .margin({ left: 12, right: 24, top: 16 }) .width(StyleConstants.PERCENTAGE_100) .enabled(this.selectedNoteData.is_deleted == Delete.Yes ? false : true) .onClick(() => { this.issave = 0 + LogUtil.info(TAG, "editModel : " + this.editModel + ", sectionStatus : " + this.sectionStatus) + let isContinue = AppStorage.Get('IsContinue') + LogUtil.info(TAG, "isContinue : " + isContinue) // 点击第三屏进入全屏编辑模式 - if (this.sectionStatus != 1) { + if (this.sectionStatus != 1 || isContinue) { this.lastSectionStatus = this.sectionStatus this.sectionStatus = 1 this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" }) - this.editModel = !this.editModel // 添加定时器:3s自动保存 timeId = setInterval(() => { this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) @@ -160,11 +163,12 @@ export struct NoteContentComp { // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) LogUtil.info(TAG, "set continue section success") + this.editModel = !this.editModel + AppStorage.SetOrCreate('IsContinue', false) } }) } .height(StyleConstants.PERCENTAGE_100) - .margin({ left: 24, right: 24 }) .visibility(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0 ? Visibility.Hidden : Visibility.Visible) } .height(StyleConstants.PERCENTAGE_100) @@ -186,9 +190,12 @@ export struct NoteContentOverViewComp { @Consume('SelectedNoteData') selectedNoteData: NoteData @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = [] @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] + @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') + @Consume('SelectedFolderData') selectedFolderData: FolderData @Consume('EditModel') editModel: boolean @Consume('SectionStatus') sectionStatus: number @Consume('RefreshFlag') refreshFlag: number + controllerShow: WebController editTitleDialogCtl: CustomDialogController = new CustomDialogController({ builder: EditTitleDialog({ confirm: this.confirm.bind(this), dialogType: 0 }), alignment: DialogAlignment.Center, @@ -216,7 +223,17 @@ export struct NoteContentOverViewComp { 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) + if(this.sectionStatus != 1) { + this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid) + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) + this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + } else { + this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), item.uuid) + } + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, "NoteContentOverViewComp, MenuBuilder, set continue note success") }) }, noteItem => noteItem.uuid) }.listDirection(Axis.Vertical) @@ -232,7 +249,9 @@ export struct NoteContentOverViewComp { Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Row() { - Text(this.selectedNoteData.title).fontSize(30) + Text(this.selectedNoteData.title) + .fontSize(30) + .margin({ left: 12, right: 24 }) .onClick(() => { this.editModel = true this.sectionStatus = 1 @@ -249,9 +268,11 @@ export struct NoteContentOverViewComp { .fontSize(12) .padding({ top: 4, bottom: 4 }) .fontColor($r("app.color.modified_time_font_color")) + .margin({ left: 12 }) Row() { Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid))) .fontSize(12) + .fontColor($r("app.color.list_modified_time_font_color")) Image($r('app.media.triangle')) .width(6) .height(12) @@ -311,11 +332,10 @@ export struct ToolBarComp { this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) this.chooseNote = false - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - LogUtil.info(TAG, "NoteContentOverViewComp, set continue section success") + LogUtil.info(TAG, "NoteContentOverViewComp, set continue note success") } editContentDialogCtl: CustomDialogController = new CustomDialogController({ @@ -332,7 +352,7 @@ export struct ToolBarComp { build() { Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Image($r('app.media.zoom')) + Image(this.sectionStatus == 1 ? $r('app.media.narrow') : $r('app.media.zoom')) .height(24) .width(24) .onClick(() => { @@ -342,8 +362,6 @@ export struct ToolBarComp { this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" }) } else { if (this.lastSectionStatus != undefined) { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); // 切换为小屏预览模式 this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) // 退出全屏时存库 @@ -382,7 +400,6 @@ export struct ToolBarComp { prompt.showToast({ message: "已恢复", duration: 2000 }) this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) this.chooseNote = false - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // update note to db let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) @@ -403,15 +420,10 @@ export struct ToolBarComp { .height(24) .width(24) .onClick(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); // 清单 this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" }) - // 清除定时器 - if (timeId != undefined) { - LogUtil.info(TAG, "circle_tick1, clearInterval timeId : " + timeId) - clearInterval(timeId) - } + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); }) }.width(42) .height(42) @@ -436,25 +448,49 @@ export struct ToolBarComp { Image($r('app.media.picture_white')) .height(24) .width(24) + .onClick(async () => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + LogUtil.info(TAG, 'startAbility start') + await globalThis.noteContext.startAbilityForResult({ + parameters: { uri: "singleselect" }, + bundleName: "com.ohos.photos", + abilityName: "com.ohos.photos.MainAbility", + }) + .then(v => { + let want = v['want']; + if (want != null && want != undefined) { + let param = want['parameters']; + let imageUri = "" + if (param != null && param != undefined) { + let uri = param['select-item-list']; + imageUri = uri; + } + // 拷贝 + if(imageUri != null && imageUri != "") { + OperationUtils.copy(imageUri).then((uriPath) => { + var path = "file://" + uriPath + LogUtil.info(TAG, 'image uri is:' + path) + this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"}) + }) + } + } + }); + }) }.width(42) .height(42) .borderRadius(8) .backgroundColor($r('app.color.color_ffffff')) + Button({ type: ButtonType.Normal, stateEffect: true }) { - Image($r('app.media.tick_thick')) + Image($r('app.media.undo')) .height(24) .width(24) - .fillColor(this.issave == 0 ? Color.Black : Color.Grey) .onClick(() => { // 退出键盘 inputMethod.getInputMethodController().stopInput(); - this.issave = 1 - // 保存笔记信息到数据库 - 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.undo()" }) }) }.width(42) .height(42) @@ -462,27 +498,32 @@ export struct ToolBarComp { .backgroundColor($r('app.color.color_ffffff')) Button({ type: ButtonType.Normal, stateEffect: true }) { - Image($r('app.media.undo')) + Image($r('app.media.todo')) .height(24) .width(24) .onClick(() => { // 退出键盘 inputMethod.getInputMethodController().stopInput(); - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" }) + this.controllerShow.runJavaScript({ script: "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.todo')) + Image($r('app.media.tick_thick')) .height(24) .width(24) + .fillColor(this.issave == 0 ? Color.Black : Color.Grey) .onClick(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" }) + // 保存笔记信息到数据库 + 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.issave = 1 }) }.width(42) .height(42) diff --git a/common/component/src/main/ets/default/NoteContentCompPortrait.ets b/common/component/src/main/ets/default/NoteContentCompPortrait.ets index 348750937e623f87bafe6960aa2018f31c2e7d1d..6f406c06e40c6d5205610e18b5801b1daebb69a8 100644 --- a/common/component/src/main/ets/default/NoteContentCompPortrait.ets +++ b/common/component/src/main/ets/default/NoteContentCompPortrait.ets @@ -37,7 +37,7 @@ const TAG = "NoteContentCompPortrait" // Note content component @Component export struct NoteContentCompPortrait { - @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get("NewNote") + @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote') @Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get("NewFolder") @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @Provide('EditModel') editModel: boolean = false @@ -49,7 +49,7 @@ export struct NoteContentCompPortrait { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) @@ -65,7 +65,7 @@ export struct NoteContentCompPortrait { 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) + this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData) let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) @@ -79,7 +79,7 @@ export struct NoteContentCompPortrait { 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 }) @@ -107,16 +107,16 @@ export struct NoteContentCompPortrait { }) }) .zoomAccess(false) - .height(450) + .height('70%') .width('100%') } .onClick(() => { - this.editModel = true // 添加定时器:3s自动保存 time_id = setInterval(() => { this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) }, 3000) LogUtil.info(TAG, "setInterval time_id : " + time_id) + this.editModel = true }) .margin({ top: 16 }) .width(StyleConstants.PERCENTAGE_100) @@ -251,8 +251,6 @@ export struct ToolBarComp { LogUtil.info(TAG, "back, clearInterval time_id : " + time_id) clearInterval(time_id) } - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); router.back() }) @@ -305,16 +303,9 @@ export struct ToolBarComp { Button({ type: ButtonType.Normal, stateEffect: true }) { Image($r('app.media.tick_thin')).height(24).width(24) .onClick(() => { - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); // 保存笔记信息到数据库 this.controllerShow.runJavaScript({ script: "get_html_content()" }) this.editModel = false - // 清除定时器 - if (time_id != undefined) { - LogUtil.info(TAG, "tick_thin, clearInterval time_id : " + time_id) - clearInterval(time_id) - } }) }.width(42) .height(42) @@ -464,6 +455,32 @@ export struct EditNoteCompForPortrait { .width(24) .height(24) .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) + .onClick(async () => { + LogUtil.info(TAG, 'startAbility start') + await globalThis.noteContext.startAbilityForResult({ + parameters: { uri: "singleselect" }, + bundleName: "com.ohos.photos", + abilityName: "com.ohos.photos.MainAbility", + }).then(v => { + let want = v['want']; + if (want != null && want != undefined) { + let param = want['parameters']; + let imageUri = "" + if (param != null && param != undefined) { + let uri = param['select-item-list']; + imageUri = uri; + } + // 拷贝 + if (imageUri != null && imageUri != "") { + OperationUtils.copy(imageUri).then((uriPath) => { + var path = "file://" + uriPath + LogUtil.info(TAG, 'image uri is:' + path) + this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImage('" + path + "')" }) + }) + } + } + }); + }) Text($r("app.string.photo")) .fontSize(10) diff --git a/common/component/src/main/ets/default/NoteListComp.ets b/common/component/src/main/ets/default/NoteListComp.ets index 62244e40b033b1c60dc07310bcf773e3a5860d82..964beee0b855a132bf8161aab4e84479ae1a1fef 100644 --- a/common/component/src/main/ets/default/NoteListComp.ets +++ b/common/component/src/main/ets/default/NoteListComp.ets @@ -100,7 +100,6 @@ struct NoteOverViewComp { .onClick(() => { if (this.sectionStatus == 1) { this.expandStatus = !this.expandStatus - AppStorage.SetOrCreate('ContinueExpand', this.expandStatus) } else { this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) // save continue data @@ -269,7 +268,6 @@ export struct NoteItemComp { } else { this.selectedNoteData = this.noteItem this.chooseNote = true - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) @@ -313,6 +311,7 @@ export struct NoteItemListComp { @Consume @Watch('doSearch') inputKeyword: string @Consume('SearchResultList') searchResultList: NoteData[] @Consume('SelectedNoteData') selectedNoteData: NoteData + @Consume('PortraitModel') portraitModel:boolean controllerShow: WebController doSearch() { @@ -325,7 +324,9 @@ 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 + "')" }) + if(this.portraitModel == false) { + 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) @@ -419,6 +420,13 @@ export struct OperateNoteComp { RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null) }) this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, "onMoveConfirm, set continue note success") + if(this.portraitModel == false) { + this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) + } this.longpress = false this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray) @@ -584,7 +592,6 @@ export struct AddNoteComp { this.editModel = true } this.chooseNote = true - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) @@ -660,6 +667,10 @@ export struct OperateNoteCompForPortrait { RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null) }) this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, "onMoveConfirm, set continue note success") this.longpress = false this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray) diff --git a/common/utils/src/main/config.json b/common/utils/src/main/config.json index 69ee57bd96d2471359216214333c2c571d35c8a5..dc7f5778f8bd7e15a1b4425e3d26e3b5768373da 100644 --- a/common/utils/src/main/config.json +++ b/common/utils/src/main/config.json @@ -3,8 +3,8 @@ "bundleName": "com.ohos.note", "vendor": "ohos", "version": { - "code": 1000000, - "name": "1.0.0" + "code": 1000003, + "name": "1.0.3" } }, "deviceConfig": {}, diff --git a/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets b/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets index eb3a43c45d4d0137ef21b24b7bdfdb8b02fdefe9..57efa783b648e2638c9195ee0e9c319b3ef0a1dd 100644 --- a/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets +++ b/common/utils/src/main/ets/default/baseUtil/OperationUtils.ets @@ -43,7 +43,7 @@ export class OperationUtils { var dir = context.filesDir // 2、生成本地文件名 var time = new Date().getTime() - var imagePath = dir + "/" + time.toString().substr(5) + "_note" + numId + ".jpg" + var imagePath = dir + "/" + time.toString() + "_note" + ".jpg" // 3、拷贝 await fileio.copyFile(fd, imagePath) // 4、关闭安fd,Asset diff --git a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets index 69faf60ce0cb59b291ddc62dc96e0f9328020473..c14bed37b067b4e4771a164b1812ba8edc06a5a4 100644 --- a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets @@ -25,6 +25,8 @@ import {TableSql, TableName, FolderTableColumn, NoteTableColumn, SysDefFolderUui const TAG = "RdbStoreUtil" +const FileMaxSize: number = 20 * 1024 * 1024 + /** * db instance */ @@ -95,7 +97,6 @@ export default { if (isContinue) { let continueNote: string = AppStorage.Get('ContinueNote') let continueSection = AppStorage.Get('ContinueSection') - let noteObj = JSON.parse(continueNote) let noteData = new NoteData(noteObj.uuid, noteObj.title, noteObj.uuid, noteObj.folder_uuid, noteObj.content_text, noteObj.content_img, noteObj.note_type, noteObj.is_top, noteObj.is_favorite, @@ -103,16 +104,10 @@ export default { // save img to FileDir LogUtil.info(TAG, "createRdbStore, save img to FileDir") - let srcArray = this.getSrcFromHtml(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) - } + let imgNameArray = this.getImgNameFromHtml(noteData) + imgNameArray.forEach((imgName: string) => { + this.writeToFileDir(imgName) }) - LogUtil.info(TAG, "createRdbStore, save img to FileDir success") // if not exit this note let exist = false @@ -147,7 +142,9 @@ export default { AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid)) } AppStorage.SetOrCreate('Note', noteData) + AppStorage.SetOrCreate('ContinueNote', JSON.stringify(noteData.toNoteObject())) AppStorage.SetOrCreate('Section', continueSection) + AppStorage.SetOrCreate('NewNote', noteData) } else { LogUtil.info(TAG, "createRdbStore, IsContinue false") AppStorage.SetOrCreate('Folder', AppStorage.Get('AllFolderArray')[0]) @@ -218,7 +215,7 @@ export default { AppStorage.SetOrCreate('AllNoteArray', noteDataArray) LogUtil.info(TAG, "AppStorage[query] set AllFolderArray and AllNoteArray success") - // 迁移 + // save continue data let isContinue = AppStorage.Get('IsContinue'); LogUtil.info(TAG, "initAppStorage, isContinue is " + isContinue) if (isContinue) { @@ -232,16 +229,10 @@ export default { // save img to FileDir LogUtil.info(TAG, "initAppStorage, save img to FileDir") - let srcArray = this.getSrcFromHtml(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) - } + let imgNameArray = this.getImgNameFromHtml(noteData) + imgNameArray.forEach((imgName: string) => { + this.writeToFileDir(imgName) }) - LogUtil.info(TAG, "initAppStorage, save img to FileDir success") // if not exit this note let exist = false @@ -276,9 +267,11 @@ export default { AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid)) } AppStorage.SetOrCreate('Note', noteData) + AppStorage.SetOrCreate('ContinueNote', JSON.stringify(noteData.toNoteObject())) AppStorage.SetOrCreate('Section', continueSection) + AppStorage.SetOrCreate('NewNote', noteData) } else { - LogUtil.info(TAG, "RdbStoreUtil initAppStorage, IsContinue false") + LogUtil.info(TAG, "initAppStorage, IsContinue false") AppStorage.SetOrCreate('Folder', AppStorage.Get('AllFolderArray')[0]) let note = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes) AppStorage.SetOrCreate('Note', note) @@ -293,43 +286,87 @@ export default { }) }, - getSrcFromHtml(html: string): any{ - LogUtil.info(TAG, "getSrcFromHtml") + getImgNameFromHtml(noteData: NoteData): any{ + let newModuleName = "file://" + globalThis.noteContext.filesDir + let imgNameArray = [] + let html = noteData.content_text + if (html == undefined || html == null || html == "") { + return imgNameArray + } let imgReg = /]+>/g let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i let imgArray = html.match(imgReg) - let srcArray = [] if (imgArray != null) { + let hasFirstImg: boolean = false for (let i = 0; i < imgArray.length; i++) { let src = imgArray[i].match(srcReg) - srcArray.push(src[1]) + if (src != null && src.length > 1) { + LogUtil.info(TAG, "getImgNameFromHtml, src[1] : " + src[1]) + let lastIndex = src[1].lastIndexOf('/') + if (lastIndex != -1) { + let oldModuleName = src[1].substring(0, lastIndex) + let imgName = src[1].substring(lastIndex + 1) + noteData.content_text = noteData.content_text.replace(oldModuleName, newModuleName) + if (!hasFirstImg) { + noteData.content_img = newModuleName + "/" + imgName + hasFirstImg = true + } + imgNameArray.push(imgName) + } + } } } - return srcArray + return imgNameArray }, - writeToFileDir(context, fileName: string) { + writeToFileDir(fileName: string) { LogUtil.info(TAG, "writeToFileDir fileName : " + fileName) - let distributedFilesDir = context.distributedFilesDir - let srcPath = distributedFilesDir + "/" + fileName + let desPath = globalThis.noteContext.filesDir + "/" + fileName + LogUtil.info(TAG, "desPath : " + desPath) + try { + fileio.accessSync(desPath) + LogUtil.info(TAG, "desPath has existed, return") + return + } catch (err) { + LogUtil.warn(TAG, "desPath has not existed, need to write") + } + + let srcPath = globalThis.noteContext.distributedFilesDir + "/" + fileName + LogUtil.info(TAG, "srcPath : " + srcPath) + let size = fileio.statSync(srcPath).size + LogUtil.info(TAG, "srcPath size : " + size) + if (size > FileMaxSize) { + LogUtil.warn(TAG, "srcPath size more then FileMaxSize, return") + return + } let srcFd try { - srcFd = fileio.openSync(srcPath, 0o2, 0o666) + srcFd = fileio.openSync(srcPath, 0o0) LogUtil.info(TAG, "open srcPath success : " + srcFd) } catch (err) { LogUtil.warn(TAG, "open srcPath failed : " + err) + return } - let filesDir = context.filesDir - let desPath = filesDir + "/" + fileName + let desFd + try { + desFd = fileio.openSync(desPath, 0o2 | 0o100, 0o400 | 0o200 | 0o040 | 0o020) + LogUtil.info(TAG, "open desPath success : " + srcFd) + } catch (err) { + LogUtil.warn(TAG, "open desPath failed : " + err) + return + } + let buf = new ArrayBuffer(size) try { - fileio.copyFileSync(srcFd, desPath) - LogUtil.info(TAG, "writeToFileDir, copyFile successfully") + let readNum = fileio.readSync(srcFd, buf) + LogUtil.info(TAG, "readNum : " + readNum) + let writeNum = fileio.writeSync(desFd, buf) + LogUtil.info(TAG, "writeNum : " + writeNum) } catch (err) { - LogUtil.warn(TAG, "writeToFileDir, copyFile failed : " + err) + LogUtil.warn(TAG, "read or write error : " + err) } }, @@ -408,20 +445,18 @@ export default { return new ohosDataRdb.RdbPredicates(tableName) }, - updataNoteImage(content):string { - let srcArray = this.getSrcFromHtml(content) - if(srcArray.length == 0) { - return "" + updataNoteImage(noteData: NoteData): string { + let content_img = "" + let imgNameArray = this.getImgNameFromHtml(noteData) + if (imgNameArray.length == 0) { + return content_img } - if(srcArray[0] == './shuxue.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 + if (imgNameArray[0] == 'shuxue.png' || imgNameArray[0] == 'cake.png') { + content_img = "/res/" + imgNameArray[0] + } else { + content_img = noteData.content_img } - return srcArray[0] + LogUtil.info(TAG, "updataNoteImage, content_img : " + content_img) + return content_img } } \ No newline at end of file diff --git a/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets b/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets index 704c427635e343cd7311ef10ff7d9f6f3950bc3a..9b5c9db62352f97b4a6b29ff5f104d15ecf3ffdd 100644 --- a/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets +++ b/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets @@ -114,8 +114,8 @@ export default { "title": "数学公式", "uuid": "note1_uuid", "folder_uuid": SysDefFolderUuid.UnClassified, - "content_text": '

好好学习,天天向上



', - "content_img": "/res/shuxue.png", + "content_text": '好好学习,天天向上', + "content_img": "", "note_type": NoteType.SysDef, "is_top": Top.Yes, "is_favorite": Favorite.Yes, @@ -146,12 +146,7 @@ export default { "title": "旅游心得", "uuid": "note3_uuid", "folder_uuid": SysDefFolderUuid.Work, - "content_text": '

出门在外首要是安全问题,不然命都没有了还谈什么?其次是身上的财物,要知道,你一到某地,身上的行李很容易被狼盯上。' + - '背着旅行袋的人到那里都是任人宰割的对象,所以不要完成全相信陌生人的话,也不要走行人稀少的小道,方便的话最好是将包裹就近寄存,免去这道危险。' + - '同时在身上相对安全的地方保留贴身的救命钱,狡兔三窟,千万不要将开心的旅游变成伤心的流浪!

' + - '

出门在外要想整个旅程无遗憾,关键是心态。首先要对即将到的目的地有一个正确的认识和恰当的期望。

' + - '

一般每个自然风景区旅游区都有着自己的特色,带著一种游九寨沟桂林山水的心情和期望去陕西的人肯定会失望而归。' + - '同样带着游西部的心情和期望去海南.桂林你也会觉得那里也没有什么,只不过山和水比别的地方特别一点。

', + "content_text": '
要想整个旅程无遗憾,关键是心态,首先要对即将到的目的地有一个正确的认识和恰当的期望。
', "content_img": "", "note_type": NoteType.SysDef, "is_top": Top.No, @@ -172,11 +167,10 @@ export default { '  糖60g
' + '' + '  玉米油40g
' + - '
    1. 准备小盆打入三个鸡蛋,加盐加糖,蛋糕粉分两次加入蛋糊内。
' + - '    2. 玉米油倒入碗里,再加入牛奶,用打蛋器打到完全融为一体,烤箱预热15分钟。
' + - '    3. 再加入葡萄干、核桃仁,把蛋糕放进烤箱,定时40分钟,取出即可食用。

' + - '


', - "content_img": "/res/cake.png", + '
    1. 添加鸡蛋、盐、糖、蛋糕粉
' + + '    2. 加入玉米油、牛奶,烤箱预热15分钟
' + + '    3. 加入葡萄干、核桃仁,烤箱定时40分钟

', + "content_img": "", "note_type": NoteType.CusDef, "is_top": Top.No, "is_favorite": Favorite.Yes, diff --git a/product/pc/src/main/config.json b/product/pc/src/main/config.json index 31502bc0ae8992b60ecd3cb6554a0c3b4c6101f4..d3d7b444c2b9b2a3e2a9dfba5cdc97bb7362e016 100644 --- a/product/pc/src/main/config.json +++ b/product/pc/src/main/config.json @@ -3,8 +3,8 @@ "bundleName": "com.ohos.note", "vendor": "ohos", "version": { - "code": 1000000, - "name": "1.0.0" + "code": 1000003, + "name": "1.0.3" } }, "deviceConfig": {}, diff --git a/product/pc/src/main/resources/base/element/color.json b/product/pc/src/main/resources/base/element/color.json index 02771c324f3a1fff11a4b2d89e0e6843427fe282..9576e702632ca8dd7943b8f03fb8f71f7fd53195 100644 --- a/product/pc/src/main/resources/base/element/color.json +++ b/product/pc/src/main/resources/base/element/color.json @@ -84,6 +84,10 @@ "name": "category_already_exist_font_color", "value": "#FA2A2D" }, + { + "name": "category_already_exist_divider_color", + "value": "#FA2A2D" + }, { "name": "create_folder_bg_color", "value": "#FFFFFF" @@ -158,7 +162,7 @@ }, { "name": "Recently_delete_prompt_font_color", - "value": "#18181A" + "value": "#99182431" }, { "name": "Empty_page_font_color", diff --git a/product/phone/src/main/config.json b/product/phone/src/main/config.json index 5dac9c8e5b6e0ec70fac4a00bf5c3fe9c10d51b2..4ad1ec0a86777fcb341a1e3ff4857c6b3b251123 100644 --- a/product/phone/src/main/config.json +++ b/product/phone/src/main/config.json @@ -3,8 +3,8 @@ "bundleName": "com.ohos.note", "vendor": "ohos", "version": { - "code": 1000000, - "name": "1.0.0" + "code": 1000003, + "name": "1.0.3" } }, "deviceConfig": {}, diff --git a/product/phone/src/main/ets/MainAbility/MainAbility.ts b/product/phone/src/main/ets/MainAbility/MainAbility.ts index 8062c4f2e6dd95c4932a9847539ed61ebe7a2b7a..ce55692c071fd608a8f603601b761b972dda989b 100644 --- a/product/phone/src/main/ets/MainAbility/MainAbility.ts +++ b/product/phone/src/main/ets/MainAbility/MainAbility.ts @@ -15,44 +15,31 @@ import Ability from '@ohos.application.Ability' import fileio from '@ohos.fileio' -import inputMethod from '@ohos.inputMethod'; +import inputMethod from '@ohos.inputMethod' export default class MainAbility extends Ability { - private Tag = "Phone_Note_MainAbility" + private Tag = "MainAbility_Phone" onCreate(want, launchParam) { console.info(this.Tag + " onCreate, launchReason is " + launchParam.launchReason) - // 折叠状态 AppStorage.SetOrCreate('Expand', false) - AppStorage.SetOrCreate('Choose', false) + AppStorage.SetOrCreate('Choose', true) if (launchParam.launchReason == 3) { + // 设置迁移标记 + AppStorage.SetOrCreate('IsContinue', true) // 获取对端的迁移数据 let continueNote: string = want.parameters["ContinueNote"] - let continueSection: number = want.parameters["ContinueSection"] - console.info(this.Tag + " continueSection : " + continueSection) AppStorage.SetOrCreate('ContinueNote', continueNote) - AppStorage.SetOrCreate('ContinueSection', continueSection) - // 折叠状态 - let continueExpand: boolean = want.parameters["ContinueExpand"] + // 来自手机的迁移 let continueChoose: boolean = want.parameters["ContinueChoose"] - console.info(this.Tag + " continueExpand : " + continueExpand + " , continueChoose : " + continueChoose) - AppStorage.SetOrCreate('Expand', continueExpand) - AppStorage.SetOrCreate('Choose', continueChoose) - // 设置迁移标记 - AppStorage.SetOrCreate('IsContinue', true) - - // 来自平板的迁移 - if (continueExpand == undefined && continueChoose == undefined) { - console.info(this.Tag + " from tablet") - AppStorage.SetOrCreate('Choose', true) - AppStorage.SetOrCreate('Expand', false) - AppStorage.SetOrCreate('ContinueChoose', true) + if (continueChoose) { + console.info(this.Tag + " continue from phone") + }else{ + AppStorage.SetOrCreate('ContinueFromTablet', true) + console.info(this.Tag + " continue from tablet") } - this.context.restoreWindowStage(null) } - AppStorage.SetOrCreate('openPhoto', 0) - AppStorage.SetOrCreate('openPerm', 0) globalThis.noteContext = this.context } @@ -78,4 +65,65 @@ export default class MainAbility extends Ability { // 退出键盘 inputMethod.getInputMethodController().stopInput(); } + + onContinue(wantParam: { [key: string]: any }) { + console.info(this.Tag + " onContinue") + // 获取本端的迁移数据 + let continueNote = AppStorage.Get('ContinueNote') + if (continueNote == undefined || continueNote == null) { + console.info(this.Tag + " onContinue, continueNote is error, default [0]") + continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject()) + } + + // 保存本端的迁移数据 + wantParam["ContinueNote"] = continueNote + wantParam["ContinueChoose"] = true + + // save img to DisFileDir + console.info(this.Tag + " onContinue, save img to DisFileDir") + let continueNoteObj = JSON.parse(continueNote) + let srcArray = this.getSrcFromHtml(continueNoteObj.content_text) + srcArray.forEach((src: string) => { + let lastIndex = src.lastIndexOf('/') + if (lastIndex != -1) { + let imgName = src.substring(lastIndex + 1) + this.writeToDisFileDir(imgName) + } + }) + console.info(this.Tag + " onContinue end") + return true + } + + getSrcFromHtml(html: string): any{ + let srcArray = [] + if (html == undefined || html == null || html == "") { + return srcArray + } + let imgReg = /]+>/g + let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i + let imgArray = html.match(imgReg) + if (imgArray != null) { + for (let i = 0; i < imgArray.length; i++) { + let src = imgArray[i].match(srcReg) + if (src != null && src.length > 1) { + srcArray.push(src[1]) + } + } + } + return srcArray + } + + writeToDisFileDir(fileName: string) { + console.info(this.Tag + " writeToDisFileDir, fileName : " + fileName) + let filesDir = this.context.filesDir + let srcPath = filesDir + "/" + fileName + let distributedFilesDir = this.context.distributedFilesDir + let desPath = distributedFilesDir + "/" + fileName + try { + fileio.copyFileSync(srcPath, desPath) + console.info(this.Tag + " onContinue, writeToDisFileDir, copyFile successfully") + } catch (err) { + console.warn(this.Tag + " onContinue, writeToDisFileDir, copyFile failed : " + err) + } + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets b/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets index eb9a721a103fe3a96b173958b2d87d085fa5df81..54112ebc3ea79714f78050d71778ac317f711416 100644 --- a/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets +++ b/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets @@ -19,7 +19,8 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import {NoteHomePortraitComp} from './NoteHomePortrait.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' -import inputMethod from '@ohos.inputMethod'; +import inputMethod from '@ohos.inputMethod' +import router from '@system.router' @Entry @Component @@ -27,14 +28,13 @@ export struct MyNoteHomeComp { @StorageLink('DBQueryFinished') dBQueryFinished: number = 0 @Provide('PortraitModel') portraitModel: boolean = true @Provide('RefreshFlag') refreshFlag: number = 0 - private controllerShow: WebController = new WebController() private context = getContext(this) - TAG = "MyNoteHomeComp" + TAG = "MyNoteHomeComp_Phone" build() { Flex() { if (this.dBQueryFinished == 1) { - NoteHomePortraitComp({ controllerShow: this.controllerShow }) + NoteHomePortraitComp() } } .width('100%').height('100%') @@ -52,39 +52,17 @@ export struct MyNoteHomeComp { "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])) + LogUtil.info(this.TAG, 'permissions need to require from user') + this.context.requestPermissionsFromUser(permissionList).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] } - 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.') - } - }) + LogUtil.info(this.TAG, 'request permissions sum: ' + sum) + }, (err) => { + LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code); }) let dbPath = this.context.databaseDir + "/db/note.db" @@ -105,6 +83,15 @@ export struct MyNoteHomeComp { onPageShow(): void{ LogUtil.info(this.TAG, "onPageShow") this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + // continue from tablet + let continueFromTablet = AppStorage.Get('ContinueFromTablet') + LogUtil.info(this.TAG, "onPageShow, continueFromTablet : " + continueFromTablet) + let noteContentHomeExist = AppStorage.Get('NoteContentHomeExist') + LogUtil.info(this.TAG, "onPageShow, noteContentHomeExist : " + noteContentHomeExist) + if (continueFromTablet && !noteContentHomeExist) { + router.push({ uri: 'pages/NoteContentHome' }) + AppStorage.SetOrCreate('ContinueFromTablet', false) + } } onBackPress():void{ diff --git a/product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets b/product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets index 06d5c2e0f6b84dd4e910c28f991465cada8c995f..98527cea1afc18220922ce632206a3f5dff7a435 100644 --- a/product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets +++ b/product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets @@ -15,19 +15,22 @@ import {NoteContentCompPortrait} from '../../../../../../../common/component/src/main/ets/default/NoteContentCompPortrait.ets' import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' -import inputMethod from '@ohos.inputMethod'; +import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets' @Entry @Component struct NoteContentHome { @Provide('RefreshFlag') refreshFlag: number = 0 private controllerShow: WebController = new WebController() - TAG = "NoteContentHome" + @StorageLink('DBQueryFinished') dBQueryFinished: number = 0 + TAG = "NoteContentHome_Phone" build() { // Note content display area Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { - NoteContentCompPortrait({ controllerShow: this.controllerShow }) + if (this.dBQueryFinished == 1) { + NoteContentCompPortrait({ controllerShow: this.controllerShow }) + } } .backgroundColor($r("app.color.notecontent_color_ffffff")) .width('100%') @@ -38,8 +41,16 @@ struct NoteContentHome { LogUtil.info(this.TAG, "onBackPress") this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) this.controllerShow.runJavaScript({ script: "get_html_content()" }) - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); + } + + aboutToAppear(): void{ + LogUtil.info(this.TAG, "aboutToAppear") + let isContinue = AppStorage.Get('IsContinue') + LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue) + if (isContinue) { + RdbStoreUtil.initAppStorage(globalThis.noteContext) + } + AppStorage.SetOrCreate('NoteContentHomeExist', true) } } \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets b/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets index 79772b70b8db011b962f5e84f4855fb9f981fe7a..cd10d79e2ee84960845d29693cb87df67ef66819 100644 --- a/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets +++ b/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets @@ -32,8 +32,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 = 1; // 表示分栏状态, 3表示三分栏, 2表示二分栏,1表示一分栏 @@ -41,7 +40,7 @@ export struct NoteHomePortraitComp { @Provide('SelectedColor') selectedColor: string = circleColorArray[0]; @Provide('Longpress') longpress: boolean = false // 第二栏长按状态 -// 分栏状态 + // 分栏状态 @Provide('ExpandStatus') expandStatus: boolean = AppStorage.Get('Expand') // 笔记本折叠展开状态 @Provide('ChooseNote') chooseNote: boolean = AppStorage.Get('Choose') // 是否选择笔记进行打开 @@ -50,9 +49,8 @@ export struct NoteHomePortraitComp { @Provide('InputKeyword') inputKeyword: string = '' // 搜索的字串 @Provide('SelectedAll') selectedAll:boolean = false; @Provide('EditModel') editModel: boolean = false - controllerShow: WebController - TAG = "NoteHomeComp" + TAG = "NoteHomePortraitComp_Phone" build() { Stack({ alignContent: Alignment.Start }) { diff --git a/product/phone/src/main/resources/base/element/color.json b/product/phone/src/main/resources/base/element/color.json index 23674b867de2c4512eae37f886b611eb44eb0e07..76374a33c2ca0c4732ec75705a965876366b4cec 100644 --- a/product/phone/src/main/resources/base/element/color.json +++ b/product/phone/src/main/resources/base/element/color.json @@ -100,6 +100,10 @@ "name": "category_already_exist_font_color", "value": "#FA2A2D" }, + { + "name": "category_already_exist_divider_color", + "value": "#FA2A2D" + }, { "name": "create_folder_bg_color", "value": "#FFFFFF" @@ -174,7 +178,7 @@ }, { "name": "Recently_delete_prompt_font_color", - "value": "#18181A" + "value": "#99182431" }, { "name": "Empty_page_font_color", diff --git a/product/phone/src/main/resources/rawfile/editor.html b/product/phone/src/main/resources/rawfile/editor.html index 5daf07b96ecc630c06ff6872be2f597b50d10aa6..b1d03d8e25640b86a2784b8586d6860b7067cf42 100644 --- a/product/phone/src/main/resources/rawfile/editor.html +++ b/product/phone/src/main/resources/rawfile/editor.html @@ -4,9 +4,6 @@ "editorJs" - diff --git a/product/phone/src/main/resources/rawfile/rich_editor.js b/product/phone/src/main/resources/rawfile/rich_editor.js index 3590ccb4b9106309de6e9d12d00b083eacc944ee..ee1466913c68bd8571bc042e2edd350e4cf750ad 100644 --- a/product/phone/src/main/resources/rawfile/rich_editor.js +++ b/product/phone/src/main/resources/rawfile/rich_editor.js @@ -57,7 +57,7 @@ RICH_EDITOR.setUnderline = function() { document.execCommand('underline', false, null); } -RICH_EDITOR.setStart = function () { +RICH_EDITOR.getListStyle = function () { var selection, type; if (window.getSelection) { selection = getSelection(); @@ -70,12 +70,12 @@ RICH_EDITOR.setStart = function () { if (child.nodeName == "OL") { console.info('insertOrderedList') document.execCommand('insertOrderedList', false, null); - break; + return child.style["list-style"] } if (child.nodeName == "UL") { console.info('insertUnorderedList') document.execCommand('insertUnorderedList', false, null); - break; + return child.style["list-style"] } if (child.parentNode) { child = child.parentNode @@ -85,11 +85,14 @@ RICH_EDITOR.setStart = function () { } } -} +} RICH_EDITOR.setNumbers = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "decimal") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -115,7 +118,10 @@ RICH_EDITOR.setNumbers = function () { } RICH_EDITOR.setABC = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "lower-alpha") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -141,7 +147,10 @@ RICH_EDITOR.setABC = function () { } RICH_EDITOR.setBullets = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "disc") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { @@ -167,7 +176,10 @@ RICH_EDITOR.setBullets = function () { } RICH_EDITOR.setSquare = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "square") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { diff --git a/product/tablet/src/main/config.json b/product/tablet/src/main/config.json index bd5f01225dec3242bc6f834d690245d07462a9d6..93eb91e65cddff67d0b5c17a9e446a193e969259 100644 --- a/product/tablet/src/main/config.json +++ b/product/tablet/src/main/config.json @@ -3,8 +3,8 @@ "bundleName": "com.ohos.note", "vendor": "ohos", "version": { - "code": 1000000, - "name": "1.0.0" + "code": 1000003, + "name": "1.0.3" } }, "deviceConfig": {}, diff --git a/product/tablet/src/main/ets/MainAbility/MainAbility.ts b/product/tablet/src/main/ets/MainAbility/MainAbility.ts index 514d7e4868f0be4ca1ae20870c9ea5b35780db69..aaafb2f69733c734ecfcaf24a64dff588e162968 100644 --- a/product/tablet/src/main/ets/MainAbility/MainAbility.ts +++ b/product/tablet/src/main/ets/MainAbility/MainAbility.ts @@ -18,28 +18,27 @@ import fileio from '@ohos.fileio' import inputMethod from '@ohos.inputMethod'; export default class MainAbility extends Ability { - private Tag = "Tablet_Note_MainAbility" + private Tag = "MainAbility_Tablet" onCreate(want, launchParam) { console.info(this.Tag + " onCreate, launchReason is " + launchParam.launchReason) if (launchParam.launchReason == 3) { + // 设置迁移标记 + AppStorage.SetOrCreate('IsContinue', true) // 获取对端的迁移数据 let continueNote: string = want.parameters["ContinueNote"] let continueSection: number = want.parameters["ContinueSection"] console.info(this.Tag + " continueSection : " + continueSection) AppStorage.SetOrCreate('ContinueNote', continueNote) AppStorage.SetOrCreate('ContinueSection', continueSection) - // 设置迁移标记 - AppStorage.SetOrCreate('IsContinue', true) - // 来自手机的迁移 - let isChoose: boolean = want.parameters["ContinueChoose"] - console.info(this.Tag + " from phone, isChoose : " + isChoose) - AppStorage.SetOrCreate('IsChoose', isChoose) + let continueChoose: boolean = want.parameters["ContinueChoose"] + if (continueChoose) { + console.info(this.Tag + " continue from phone") + AppStorage.SetOrCreate('ContinueFromPhone', true) + } this.context.restoreWindowStage(null) } - AppStorage.SetOrCreate('openPhoto', 0) - AppStorage.SetOrCreate('openPerm', 0) globalThis.noteContext = this.context } @@ -65,4 +64,73 @@ export default class MainAbility extends Ability { // 退出键盘 inputMethod.getInputMethodController().stopInput(); } + + onContinue(wantParam: { [key: string]: any }) { + console.info(this.Tag + " onContinue") + // 获取本端的迁移数据 + let continueNote = AppStorage.Get('ContinueNote') + if (continueNote == undefined || continueNote == null) { + console.info(this.Tag + " onContinue, continueNote is error, default [0]") + continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject()) + } + + let continueSection = AppStorage.Get('ContinueSection') + if (continueSection == undefined || continueSection == null) { + console.info(this.Tag + " onContinue, continueSection is error, default 3") + continueSection = 3 + } + console.info(this.Tag + " onContinue, continueSection : " + continueSection) + + // 保存本端的迁移数据 + wantParam["ContinueNote"] = continueNote + wantParam["ContinueSection"] = continueSection + + // save img to DisFileDir + console.info(this.Tag + " onContinue, save img to DisFileDir") + let continueNoteObj = JSON.parse(continueNote) + let srcArray = this.getSrcFromHtml(continueNoteObj.content_text) + srcArray.forEach((src: string) => { + let lastIndex = src.lastIndexOf('/') + if (lastIndex != -1) { + let imgName = src.substring(lastIndex + 1) + this.writeToDisFileDir(imgName) + } + }) + console.info(this.Tag + " onContinue end") + return true + } + + getSrcFromHtml(html: string): any{ + let srcArray = [] + if (html == undefined || html == null || html == "") { + return srcArray + } + let imgReg = /]+>/g + let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i + let imgArray = html.match(imgReg) + if (imgArray != null) { + for (let i = 0; i < imgArray.length; i++) { + let src = imgArray[i].match(srcReg) + if (src != null && src.length > 1) { + console.info(this.Tag + " getSrcFromHtml, src[1] : " + src[1]) + srcArray.push(src[1]) + } + } + } + return srcArray + } + + writeToDisFileDir(fileName: string) { + console.info(this.Tag + " writeToDisFileDir, fileName : " + fileName) + let filesDir = this.context.filesDir + let srcPath = filesDir + "/" + fileName + let distributedFilesDir = this.context.distributedFilesDir + let desPath = distributedFilesDir + "/" + fileName + try { + fileio.copyFileSync(srcPath, desPath) + console.info(this.Tag + " onContinue, writeToDisFileDir, copyFile successfully") + } catch (err) { + console.warn(this.Tag + " onContinue, writeToDisFileDir, copyFile failed : " + err) + } + } } \ No newline at end of file diff --git a/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets b/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets index 149ef2bbf9e3771fecd8ff81e300f735beb2dda6..a7f7a3b2c374746656d4edc053a2b77f15070c8e 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets @@ -30,7 +30,7 @@ export struct MyNoteHomeComp { @Provide('RefreshFlag') refreshFlag: number = 0 private controllerShow: WebController = new WebController() private context = getContext(this) - TAG = "MyNoteHomeComp" + TAG = "MyNoteHomeComp_Tablet" build() { Row() { @@ -54,39 +54,17 @@ export struct MyNoteHomeComp { "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])) + LogUtil.info(this.TAG, 'permissions need to require from user') + this.context.requestPermissionsFromUser(permissionList).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] } - 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.') - } - }) + LogUtil.info(this.TAG, 'request permissions sum: ' + sum) + }, (err) => { + LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code); }) let dbPath = this.context.databaseDir + "/db/note.db" @@ -107,8 +85,10 @@ export struct MyNoteHomeComp { onPageShow(): void{ LogUtil.info(this.TAG, "onPageShow") let currentNote = AppStorage.Get('NewNote') - if (currentNote != null) { + let needRefesh = AppStorage.Get('needRefresh') + if (currentNote != null && needRefesh == true) { this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + currentNote.content_text + "')" }) + AppStorage.SetOrCreate('needRefresh',false) } this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) } diff --git a/product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets b/product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets index aca088c716b754fdcdf466213a6c88a4dc5459e3..d705945bbb6b1f8549ec35a179991db0216bd8a6 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets @@ -15,18 +15,21 @@ import {NoteContent} from '../../../../../../../common/component/src/main/ets/default/NoteContent.ets' import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' -import inputMethod from '@ohos.inputMethod'; +import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets' @Entry @Component struct NoteContentHome { private controllerShow: WebController = new WebController() - TAG = "NoteContentHome" + @StorageLink('DBQueryFinished') dBQueryFinished: number = 0 + TAG = "NoteContentHome_Tablet" build() { // Note content display area Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { - NoteContent({ controllerShow: this.controllerShow }) + if (this.dBQueryFinished == 1) { + NoteContent({ controllerShow: this.controllerShow }) + } } .backgroundColor($r("app.color.notecontent_color_ffffff")) .width('100%') @@ -37,8 +40,15 @@ struct NoteContentHome { LogUtil.info(this.TAG, "onBackPress") this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) this.controllerShow.runJavaScript({ script: "get_html_content()" }) - // 退出键盘 - inputMethod.getInputMethodController().stopInput(); + } + + aboutToAppear(): void{ + LogUtil.info(this.TAG, "aboutToAppear") + let isContinue = AppStorage.Get('IsContinue') + LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue) + if (isContinue) { + RdbStoreUtil.initAppStorage(globalThis.noteContext) + } } } \ No newline at end of file diff --git a/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets b/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets index 84d9e6d5c6421ff7f85ffe6f98c07b85d8354f4a..ab7b316fecc7875412db12adc262e6f02245f9a8 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/NoteHome.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') @@ -50,12 +50,15 @@ export struct NoteHomeComp { @Provide('Issave') issave: number = 0 controllerShow: WebController - TAG = "NoteHomeComp" + TAG = "NoteHomeComp_Tablet" narrowWinListener = mediaquery.matchMediaSync('(width < 2000)') onWinSizeChange(mediaQueryResult) { if (this.sectionStatus != 1) { this.sectionStatus = (mediaQueryResult.matches) ? 2 : 3 + // save continue data + AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) + LogUtil.info(this.TAG, "onWinSizeChange, set continue section success") } } @@ -121,11 +124,14 @@ export struct NoteHomeComp { this.sectionStatus = AppStorage.Get('Section') } // continue from phone - let isChoose = AppStorage.Get('IsChoose') - LogUtil.info(this.TAG, "aboutToAppear, isChoose : " + isChoose) - if (isChoose) { - this.sectionStatus = 1 + let continueFromPhone = AppStorage.Get('ContinueFromPhone') + LogUtil.info(this.TAG, "aboutToAppear, continueFromPhone : " + continueFromPhone) + if (continueFromPhone) { + this.sectionStatus = 3 } + // save continue data + AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) + LogUtil.info(this.TAG, "aboutToAppear, set continue section success") } aboutToDisappear(): void{ diff --git a/product/tablet/src/main/resources/base/element/color.json b/product/tablet/src/main/resources/base/element/color.json index 23674b867de2c4512eae37f886b611eb44eb0e07..76374a33c2ca0c4732ec75705a965876366b4cec 100644 --- a/product/tablet/src/main/resources/base/element/color.json +++ b/product/tablet/src/main/resources/base/element/color.json @@ -100,6 +100,10 @@ "name": "category_already_exist_font_color", "value": "#FA2A2D" }, + { + "name": "category_already_exist_divider_color", + "value": "#FA2A2D" + }, { "name": "create_folder_bg_color", "value": "#FFFFFF" @@ -174,7 +178,7 @@ }, { "name": "Recently_delete_prompt_font_color", - "value": "#18181A" + "value": "#99182431" }, { "name": "Empty_page_font_color", diff --git a/product/tablet/src/main/resources/base/media/foldMove_select.svg b/product/tablet/src/main/resources/base/media/foldMove_select.svg index 6b7b9d104f70c7c42cf1b55968c2741c7bb8d2b6..f02ccc3ed44986345a9d006602791f667b0b9226 100644 --- a/product/tablet/src/main/resources/base/media/foldMove_select.svg +++ b/product/tablet/src/main/resources/base/media/foldMove_select.svg @@ -3,10 +3,10 @@ diff --git a/product/tablet/src/main/resources/base/media/narrow.svg b/product/tablet/src/main/resources/base/media/narrow.svg new file mode 100644 index 0000000000000000000000000000000000000000..fccbe1f38d133fa8a6ff1dd9f1db2c3971f60ea2 --- /dev/null +++ b/product/tablet/src/main/resources/base/media/narrow.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_reduce + + + + + + + + + + \ No newline at end of file diff --git a/product/tablet/src/main/resources/rawfile/editor.html b/product/tablet/src/main/resources/rawfile/editor.html index 5daf07b96ecc630c06ff6872be2f597b50d10aa6..b1d03d8e25640b86a2784b8586d6860b7067cf42 100644 --- a/product/tablet/src/main/resources/rawfile/editor.html +++ b/product/tablet/src/main/resources/rawfile/editor.html @@ -4,9 +4,6 @@ "editorJs" - diff --git a/product/tablet/src/main/resources/rawfile/editor_style.css b/product/tablet/src/main/resources/rawfile/editor_style.css index 2460c25e49b340c07ed4fd5153cdbfc00472ea68..1414505a28daae731059cb7b9eb0f2af85263fa8 100644 --- a/product/tablet/src/main/resources/rawfile/editor_style.css +++ b/product/tablet/src/main/resources/rawfile/editor_style.css @@ -25,7 +25,7 @@ body { table-layout: fixed; width: 100%; min-height:100%; - color: #333333; + color: #182431; margin: 0; } @@ -38,7 +38,7 @@ body { background-repeat: no-repeat; background-position: center; background-size: cover; - color: #333333; + color: #182431; font-size:40px; } @@ -58,8 +58,8 @@ body { } .note-checkbox { - width: 23px; - height: 23px; + width: 36px; + height: 36px; background-color: #ffffff; border: 2px solid #555555; -webkit-border-radius: 50%; diff --git a/product/tablet/src/main/resources/rawfile/rich_editor.js b/product/tablet/src/main/resources/rawfile/rich_editor.js index 3590ccb4b9106309de6e9d12d00b083eacc944ee..ee1466913c68bd8571bc042e2edd350e4cf750ad 100644 --- a/product/tablet/src/main/resources/rawfile/rich_editor.js +++ b/product/tablet/src/main/resources/rawfile/rich_editor.js @@ -57,7 +57,7 @@ RICH_EDITOR.setUnderline = function() { document.execCommand('underline', false, null); } -RICH_EDITOR.setStart = function () { +RICH_EDITOR.getListStyle = function () { var selection, type; if (window.getSelection) { selection = getSelection(); @@ -70,12 +70,12 @@ RICH_EDITOR.setStart = function () { if (child.nodeName == "OL") { console.info('insertOrderedList') document.execCommand('insertOrderedList', false, null); - break; + return child.style["list-style"] } if (child.nodeName == "UL") { console.info('insertUnorderedList') document.execCommand('insertUnorderedList', false, null); - break; + return child.style["list-style"] } if (child.parentNode) { child = child.parentNode @@ -85,11 +85,14 @@ RICH_EDITOR.setStart = function () { } } -} +} RICH_EDITOR.setNumbers = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "decimal") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -115,7 +118,10 @@ RICH_EDITOR.setNumbers = function () { } RICH_EDITOR.setABC = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "lower-alpha") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -141,7 +147,10 @@ RICH_EDITOR.setABC = function () { } RICH_EDITOR.setBullets = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "disc") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { @@ -167,7 +176,10 @@ RICH_EDITOR.setBullets = function () { } RICH_EDITOR.setSquare = function () { - RICH_EDITOR.setStart() + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "square") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { diff --git a/signature/notes.p7b b/signature/notes.p7b index fdbebb05316a5bb11e3c0a40c2f5a3e3bb2ae28d..6b11b978b6447dd8702077b381949c5e6b3e5296 100644 Binary files a/signature/notes.p7b and b/signature/notes.p7b differ