diff --git a/OAT.xml b/OAT.xml
index d7a659e173dd695d4cef7f88b16ad35ae8d03d71..75df75ef91d362e018f7fa1b430af23d62f0e9e3 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 0b0143788c8820163f811b0dd37ed48e75a4a253..959e2dade5c8ce76224032a2a0999eec84cc433a 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 c133304555a92f2421271af574785b9c20a3adbc..a1f6d7f804209ae001774815f59a33c5718afdb6 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 f1d0e0db133bf8ebba031710675b5b8decdb4c79..83b5684575b3d6901f73ef0acf460044b8a1ca73 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 2359d03bb694282ad659c2539380d7a8d08e6231..6fbd3d79d877d5de11b9b644e2538922e769badd 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 3524ada75516298a842311cf2adfe2a588f62a5a..528cc182ced24f154108110e27e9a80e2d065821 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 6e15ec2ea3f55bb0cd8814b91854e8a8d02f7ddf..0000000000000000000000000000000000000000
--- 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 fe803f0649fe2816669468a39f02622d8215da85..0000000000000000000000000000000000000000
--- 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 0000000000000000000000000000000000000000..3756840b9ebdff41f797714e05314ca1f0a636c2
--- /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 ddc60685dc77b49f55bce7ca7f8ae4f62b149521..af971c413977b9133feb71e27a1b4b7a5cc21bee 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 d385d96f1770a3fcaeb20dbf8588ee5e56ab123f..09eb7d11f4cb7838a1bf55935f62d9abc8d44f50 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 e8750189a268440fa794a9e709679ee191433cae..33ca9807d9e4e551c821fad8478240c411a10218 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 6f4f1fc30a70862834e2febc083b58f6d3f0ff2e..edfa97019f4b23c54d39e834e3046d7e0dd33de1 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 d0c3c43a8e1b5ae5409c3756dcb66ebf4f331ba1..514e43bdd9294349b114380f73b9197c49d8a312 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 bded946670ed46437489a27987a035a488cd7f34..85689be912b8e0a9cf395b65ef512e81dc6dddc3 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 942224e13303a4587695e5515d91e69173feba2c..851a7bd9cf71335b708f7ab6e444fe90978006c8 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 0000000000000000000000000000000000000000..7ece3f5d78d15565565cefe0237f86cf8a2fa005
--- /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 f3d1bbdf9c1016fad9f2ec510c197b530540ad55..bedecf33a4f5192d08b618a12ade6d9b547d0479 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 094d05b2f71fe520e1614205a4894722cce2bc27..809fa78d8250cedb30bc2645d30c5da8a76899b2 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 c963d9930d194d004eb415603e5a4e0b05f9befd..44d3c91503d08c80f02871f99fae28e9bc6c9639 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 8fa46789d26d2239baaaf1d63b92d076a8a696c8..0f7643026af7575807ee0a7aa6e9dfffee64819f 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 3b06a900c144024459b84a0b4f32a61d3b30d264..a48ce08cf932a3c4af493b1cedf61c47a38a2cb4 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 0000000000000000000000000000000000000000..a7618c3e9a3b813e6e9a55e2fd463012cfae0a6d
--- /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 0000000000000000000000000000000000000000..a48ce08cf932a3c4af493b1cedf61c47a38a2cb4
--- /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 d3f9ca37ed103612a65c2138ef50e1ca4c3de2b4..de43749897f58de6658f4ccb0b04d86519ca5aa2 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 71e62c4ff167457ad15522c8aa35ca996ab3cc92..9eb7993046ecb5767ab6455bf23c96625c3b5d61 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 ffe9641c2f12e6bd76fe5347c74603f952d1e874..ef95f8f69536dc29e49b92076b120fcf0c49edae 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 0000000000000000000000000000000000000000..44ed6a2715c9a45cefd162633968411cc79da1ad
--- /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 64e632597a8f872d1192a096c6c6e5da34738861..1e6c8b3d40694f57a81b67eca79af24449cdb756 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 c4753e00d541d6f454c78c9a444f2c768d3dfd55..1012e8b0a0da4fdbe34df1124a2f3920f548538d 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 a89a12c239bceb8b1b3db96d9f19778c08224414..54175a316b2b68a780caacd96c1eade25a1f25ec 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 cdc674287cccae67850653ae0757cbad88529aec..7fef71723d544389c550d04136cea1b72d3931b2 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 fb355baaa36d57d35d46cb9b79df976621b604ad..acd4635b4360dc8df47911ab5f7eb9121f4642fa 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 2dae1c554b597d9f0a67197fa44330c072dfd606..948fa20f75c89185754bf6d896848336ba04b7e7 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 @@