mirror of
https://gitee.com/openharmony/applications_notes
synced 2024-11-23 15:39:50 +00:00
commit
99fa44e0e0
@ -72,6 +72,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"))
|
||||
@ -682,69 +685,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 +858,7 @@ export struct EditContentDialogPortrait {
|
||||
}
|
||||
}
|
||||
.height(48)
|
||||
.padding({ left: 24, right: 24 })
|
||||
|
||||
Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
|
||||
|
||||
@ -794,11 +888,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 })
|
||||
}
|
||||
}
|
@ -25,9 +25,12 @@ import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUt
|
||||
import prompt from '@system.prompt'
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
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"
|
||||
|
||||
var timeId : number
|
||||
|
||||
// Note content component
|
||||
@Component
|
||||
export struct NoteContentComp {
|
||||
@ -79,7 +82,22 @@ 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()
|
||||
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<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, 'callbackScheduledSave, set continue note success')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -102,7 +120,7 @@ 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()
|
||||
@ -131,9 +149,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<number>('ContinueSection', this.sectionStatus)
|
||||
console.log("NoteContentComp, set continue section success")
|
||||
LogUtil.info(TAG, "NoteContentComp, set continue section success")
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -218,7 +241,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)
|
||||
@ -300,7 +323,6 @@ export struct ToolBarComp {
|
||||
})
|
||||
|
||||
confirm(excuteJs: string) {
|
||||
prompt.showToast({ message: excuteJs, duration: 2000 })
|
||||
this.controllerShow.runJavaScript({ script: excuteJs })
|
||||
}
|
||||
|
||||
@ -331,6 +353,11 @@ export struct ToolBarComp {
|
||||
LogUtil.info(TAG, "close note" + this.selectedNoteData.uuid)
|
||||
this.controllerShow.runJavaScript({ script: "save_html_content()" })
|
||||
this.sectionStatus = this.lastSectionStatus
|
||||
// 清除定时器
|
||||
if (timeId != undefined) {
|
||||
LogUtil.info(TAG, "zoom, clearInterval timeId : " + timeId)
|
||||
clearInterval(timeId)
|
||||
}
|
||||
} else {
|
||||
this.sectionStatus = 3
|
||||
}
|
||||
@ -399,59 +426,124 @@ 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(() => {
|
||||
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'))
|
||||
|
||||
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)
|
||||
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)
|
||||
.onClick(async () => {
|
||||
console.log('startAbility start')
|
||||
AppStorage.SetOrCreate<number>('openPhoto', 1)
|
||||
LogUtil.info(TAG, 'globalThis.noteContext is:' + JSON.stringify(globalThis.noteContext))
|
||||
await globalThis.noteContext.startAbilityForResult({
|
||||
parameters: { uri: "singleselect" },
|
||||
bundleName: "com.ohos.photos",
|
||||
abilityName: "com.ohos.photos.MainAbility",
|
||||
})
|
||||
.then(v => {
|
||||
AppStorage.SetOrCreate<number>('openPhoto', 0)
|
||||
let want = v['want'];
|
||||
console.info(`test select single ${want}`);
|
||||
if (want != null && want != undefined) {
|
||||
let param = want['parameters'];
|
||||
console.info(`test select single ${param}`);
|
||||
let imageUri = ""
|
||||
if (param != null && param != undefined) {
|
||||
let uri = param['select-item-list'];
|
||||
console.info(`test select single ${uri}`);
|
||||
imageUri = uri;
|
||||
}
|
||||
|
||||
// 拷贝
|
||||
OperationUtils.copy(imageUri).then((uriPath) => {
|
||||
var path = "file://" + uriPath
|
||||
LogUtil.info(TAG, 'image uri is:' + path)
|
||||
this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"})
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.tick_thick'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.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'))
|
||||
|
@ -26,6 +26,7 @@ import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUt
|
||||
import prompt from '@system.prompt'
|
||||
import featureAbility from '@ohos.ability.featureAbility';
|
||||
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"
|
||||
|
||||
@ -242,29 +243,45 @@ export struct ToolBarComp {
|
||||
}.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 +424,38 @@ export struct EditNoteCompForPortrait {
|
||||
Image($r('app.media.picture_white'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.onClick(() => {
|
||||
.onClick(async () => {
|
||||
console.log('startAbility start')
|
||||
AppStorage.SetOrCreate<number>('openPhoto', 1)
|
||||
LogUtil.info(TAG, 'globalThis.noteContext is:' + JSON.stringify(globalThis.noteContext))
|
||||
await globalThis.noteContext.startAbilityForResult({
|
||||
parameters: { uri: "singleselect" },
|
||||
bundleName: "com.ohos.photos",
|
||||
abilityName: "com.ohos.photos.MainAbility",
|
||||
}).then(v => {
|
||||
AppStorage.SetOrCreate<number>('openPhoto', 0)
|
||||
let want = v['want'];
|
||||
console.info(`test select single ${want}`);
|
||||
if (want != null && want != undefined) {
|
||||
let param = want['parameters'];
|
||||
console.info(`test select single ${param}`);
|
||||
let imageUri = ""
|
||||
if (param != null && param != undefined) {
|
||||
let uri = param['select-item-list'];
|
||||
console.info(`test select single ${uri}`);
|
||||
imageUri = uri;
|
||||
}
|
||||
|
||||
// 拷贝
|
||||
OperationUtils.copy(imageUri).then((uriPath) => {
|
||||
var path = "file://" + uriPath
|
||||
LogUtil.info(TAG, 'image uri is:' + path)
|
||||
this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"})
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Text($r("app.string.photo"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
|
@ -103,13 +103,14 @@ struct NoteOverViewComp {
|
||||
Text(FolderUtil.getFolderText(this.selectedFolderData))
|
||||
.fontSize(30)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Bold)
|
||||
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')
|
||||
}
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
|
||||
}.visibility(this.longpress ? Visibility.None : Visibility.Visible)
|
||||
@ -174,9 +175,9 @@ 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)
|
||||
@ -186,7 +187,8 @@ export struct NoteItemComp {
|
||||
Row({ space: 4 }) {
|
||||
Text(DateUtil.formateDateForNoteTitle(new Date(this.noteItem.modified_time)))
|
||||
.fontSize(14)
|
||||
.fontColor('#182431')
|
||||
.fontColor('#99182431')
|
||||
.fontWeight(FontWeight.Regular)
|
||||
Image($r("app.media.favorite"))
|
||||
.height(16)
|
||||
.width(16)
|
||||
@ -206,6 +208,7 @@ export struct NoteItemComp {
|
||||
.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)
|
||||
@ -349,8 +352,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 +389,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)
|
||||
}
|
||||
|
||||
@ -528,7 +532,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)
|
||||
@ -577,6 +586,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 +595,12 @@ export struct SearchComp {
|
||||
this.search = true
|
||||
})
|
||||
}
|
||||
.width(this.search ? 344 : 384)
|
||||
.height(52)
|
||||
.padding({ left: 12, right: 12, top: 6, bottom: 6 })
|
||||
.width(this.search ? 336 : 384)
|
||||
.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") })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -618,7 +629,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)
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
{
|
||||
"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": "多选"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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,
|
||||
}
|
||||
LogUtil.debug(TAG, `getFirstObject: ${JSON.stringify(fetchOpt)}`)
|
||||
try {
|
||||
// 通过Uri拷贝图片到指定指定的包路径下
|
||||
// 1、获取本地路径
|
||||
|
||||
let fileResult = await MediaLib.getMediaLibrary(context).getFileAssets(fetchOpt)
|
||||
LogUtil.debug(TAG, `fileResult is : ${JSON.stringify(fileResult)}`)
|
||||
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.error(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.error(TAG, 'openAsset Fail')
|
||||
return;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static async closeAsset(fd: number, fileAsset: any) {
|
||||
LogUtil.info(TAG, 'closeAsset start')
|
||||
|
||||
if (fd <= 0) {
|
||||
LogUtil.error(TAG, 'closeAsset fd is invalid')
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await fileAsset.close(fd)
|
||||
LogUtil.info(TAG, 'closeAsset end')
|
||||
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, 'closeAsset fail')
|
||||
}
|
||||
}
|
||||
}
|
@ -138,6 +138,9 @@ export class NoteUtil {
|
||||
LogUtil.info(TAG, "NoteBgColor is ffffff")
|
||||
return $r("app.color.color_ffffff")
|
||||
}
|
||||
if (folderData.color == "#ffffff") {
|
||||
return "#FFEBE1"
|
||||
}
|
||||
LogUtil.info(TAG, "isSelected %s, folderData.color: %s", isSelected, folderData.color)
|
||||
return isSelected ? selectedNoteBgColorMap[folderData.color] : unSelectedNoteBgColorMap[folderData.color]
|
||||
}
|
||||
@ -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
|
||||
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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<string> {
|
||||
try {
|
||||
let numId = this.getIdByUri(uri)
|
||||
var context = globalThis.noteContext
|
||||
let fileAsset = await this.getFileAssetById(numId,context);
|
||||
if (fileAsset == null || fileAsset == undefined) {
|
||||
LogUtil.error(TAG, "Failed to get fileAsset")
|
||||
return;
|
||||
}
|
||||
|
||||
let fd = await MediaLibraryAccess.openAsset('RW', fileAsset);
|
||||
if (fd <= 0) {
|
||||
LogUtil.error(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"
|
||||
LogUtil.info(TAG, 'imagePath is :'+ imagePath)
|
||||
// 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;
|
@ -14,8 +14,10 @@
|
||||
*/
|
||||
|
||||
import ohosDataRdb from '@ohos.data.rdb'
|
||||
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'
|
||||
@ -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,15 +130,26 @@ 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)
|
||||
@ -131,7 +157,7 @@ export default {
|
||||
} else {
|
||||
console.info("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)
|
||||
@ -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,15 +262,26 @@ 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)
|
||||
@ -239,7 +289,7 @@ export default {
|
||||
} else {
|
||||
console.info("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)
|
||||
@ -250,6 +300,48 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
getSrcFromHtml(html: string): any{
|
||||
LogUtil.info(TAG, "getSrcFromHtml, html : " + html)
|
||||
let imgReg = /<img[^>]+>/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)
|
||||
console.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
|
||||
|
@ -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
|
||||
|
@ -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": "已恢复"
|
||||
}
|
||||
]
|
||||
}
|
@ -67,6 +67,32 @@
|
||||
"autoDesignWidth": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"reqPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA",
|
||||
"reason": "This is used to access photos and videos"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_MEDIA",
|
||||
"reason": "This is used to access photos and videos."
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_EXTERNAL_MEDIA_MEMORY",
|
||||
"reason": "This is used to access photos and videos."
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.MEDIA_LOCATION",
|
||||
"reason": "This is used to access photos and videos."
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_INFO",
|
||||
"reason": "reques permission"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
|
||||
"reason": "reques permission"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
@ -1,23 +1,11 @@
|
||||
/**
|
||||
* 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 Ability from '@ohos.application.Ability'
|
||||
import {WebViewUtil} from './WebViewUtil.ets'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
console.log("MainAbility onCreate, launchReason is " + launchParam.launchReason)
|
||||
AppStorage.SetOrCreate<number>('openPhoto', 0)
|
||||
globalThis.noteContext = this.context
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
@ -39,5 +27,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")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
35
product/phone/src/main/ets/MainAbility/WebViewUtil.ets
Normal file
35
product/phone/src/main/ets/MainAbility/WebViewUtil.ets
Normal file
@ -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) {
|
||||
console.info('WebViewUtil, controllerShow is null')
|
||||
this.controllerShow = new WebController()
|
||||
}
|
||||
return this.controllerShow
|
||||
}
|
||||
|
||||
}
|
@ -48,15 +48,14 @@ export struct MyNoteHomeComp {
|
||||
return
|
||||
}
|
||||
|
||||
LogUtil.info(this.TAG, "databaseDir is " + this.context.databaseDir)
|
||||
// /data/storage/el2/database/tablet
|
||||
let databaseDir = this.context.databaseDir
|
||||
LogUtil.info(this.TAG, "databaseDir is " + databaseDir)
|
||||
|
||||
let dbPath = "/data/app/el2/100/database/com.ohos.note/phone/db/note.db"
|
||||
let dbPath = 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)
|
||||
|
@ -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)
|
||||
|
@ -3,7 +3,7 @@
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 18 18" style="enable-background:new 0 0 18 18;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#007DFF;}
|
||||
.st0{fill:#F86D05;}
|
||||
</style>
|
||||
<title>搜索</title>
|
||||
<path class="st0" d="M13.2,12.2l2.4,2.4c0.3,0.3,0.3,0.8,0,1.1s-0.8,0.3-1.1,0l-2.4-2.4C12.5,13,12.9,12.6,13.2,12.2z M7.8,1.5
|
||||
|
Before Width: | Height: | Size: 840 B After Width: | Height: | Size: 840 B |
@ -220,15 +220,14 @@ RICH_EDITOR.setBlockquote = function() {
|
||||
document.execCommand('formatBlock', false, '<blockquote>');
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertImage = function() {
|
||||
var url = './shuxue.png';
|
||||
RICH_EDITOR.insertImage = function(url) {
|
||||
console.log("js,url:" + url)
|
||||
var html = '<br></br><img src="' + url + '" alt="picvision" style="margin:0px auto;width:90%;display:table-cell;vertical-align:middle;border-radius:10px;max-width:90%" /><br></br>';
|
||||
RICH_EDITOR.insertHTML(html);
|
||||
RICH_EDITOR.editor.scrollIntoView(false)
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertHTML = function(html) {
|
||||
RICH_EDITOR.restorerange();
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
|
@ -71,27 +71,15 @@
|
||||
"reqPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA",
|
||||
"reason": "This is used to access photos and videos"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_MEDIA",
|
||||
"reason": "This is used to access photos and videos."
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_EXTERNAL_MEDIA_MEMORY",
|
||||
"reason": "This is used to access photos and videos."
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.MEDIA_LOCATION",
|
||||
"reason": "This is used to access photos and videos."
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_INFO",
|
||||
"reason": "reques permission"
|
||||
"reason": "$string:per_read_media"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
|
||||
"reason": "reques permission"
|
||||
"reason": "$string:per_get_bundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.DISTRIBUTED_DATASYNC",
|
||||
"reason": "$string:per_dis_dataSync"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -1,20 +1,8 @@
|
||||
/**
|
||||
* 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 Ability from '@ohos.application.Ability'
|
||||
import {WebViewUtil} from './WebViewUtil.ets'
|
||||
import fileio from '@ohos.fileio'
|
||||
import accessControl from "@ohos.abilityAccessCtrl"
|
||||
import bundle from '@ohos.bundle'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
@ -32,6 +20,8 @@ export default class MainAbility extends Ability {
|
||||
AppStorage.SetOrCreate<number>('IsContinue', 1)
|
||||
this.context.restoreWindowStage(null)
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('openPhoto', 0)
|
||||
globalThis.noteContext = this.context
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
@ -40,6 +30,42 @@ export default class MainAbility extends Ability {
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
console.log("MainAbility onWindowStageCreate")
|
||||
// 动态申请权限
|
||||
globalThis.requestPermissions = async () => {
|
||||
let array: Array<string> = [
|
||||
"ohos.permission.READ_MEDIA",
|
||||
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC"];
|
||||
let needGrantPermission = false
|
||||
let accessManger = accessControl.createAtManager()
|
||||
let bundleInfo = await bundle.getApplicationInfo("com.ohos.note", 0, 100)
|
||||
console.info("onWindowStageCreate, accessTokenId : " + bundleInfo.accessTokenId.toString())
|
||||
for (const permission of array) {
|
||||
console.info("onWindowStageCreate, query permission : " + permission)
|
||||
try {
|
||||
let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission)
|
||||
if (grantStatus == -1) {
|
||||
needGrantPermission = true
|
||||
break
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("onWindowStageCreate, verifyAccessToken error : " + JSON.stringify(err))
|
||||
needGrantPermission = true
|
||||
break
|
||||
}
|
||||
}
|
||||
console.info("onWindowStageCreate, needGrantPermission : " + needGrantPermission)
|
||||
if (needGrantPermission) {
|
||||
try {
|
||||
await this.context.requestPermissionsFromUser(array)
|
||||
} catch (err) {
|
||||
console.warn("onWindowStageCreate, requestPermissionsFromUser err : " + JSON.stringify(err))
|
||||
}
|
||||
} else {
|
||||
console.info("onWindowStageCreate, requestPermissionsFromUser, already granted")
|
||||
}
|
||||
}
|
||||
globalThis.requestPermissions()
|
||||
windowStage.setUIContent(this.context, "pages/MyNoteHome", null)
|
||||
}
|
||||
|
||||
@ -85,6 +111,19 @@ export default class MainAbility extends Ability {
|
||||
continueSection = 3
|
||||
}
|
||||
|
||||
// save img to DisFileDir
|
||||
console.log("MainAbility onContinue, save img to DisFileDir")
|
||||
let continueNoteObj = JSON.parse(continueNote)
|
||||
let srcArray = this.getSrcFromHtml(decodeURI(continueNoteObj.content_text))
|
||||
srcArray.forEach((src: string) => {
|
||||
let lastIndex = src.lastIndexOf('/')
|
||||
if (lastIndex != -1) {
|
||||
let imgName = src.substring(lastIndex + 1)
|
||||
this.writeToDisFileDir(imgName)
|
||||
}
|
||||
})
|
||||
console.log("MainAbility onContinue, save img to DisFileDir success")
|
||||
|
||||
// 保存本端的迁移数据
|
||||
wantParam["ContinueFolder"] = continueFolder
|
||||
wantParam["ContinueNote"] = continueNote
|
||||
@ -92,4 +131,33 @@ export default class MainAbility extends Ability {
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
getSrcFromHtml(html: string): any{
|
||||
let imgReg = /<img[^>]+>/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)
|
||||
srcArray.push(src[1])
|
||||
}
|
||||
}
|
||||
return srcArray
|
||||
}
|
||||
|
||||
writeToDisFileDir(fileName: string) {
|
||||
console.log("MainAbility writeToDisFileDir, fileName : " + fileName)
|
||||
let filesDir = this.context.filesDir
|
||||
let srcPath = filesDir + "/" + fileName
|
||||
let distributedFilesDir = this.context.distributedFilesDir
|
||||
let desPath = distributedFilesDir + "/" + fileName
|
||||
try {
|
||||
fileio.copyFileSync(srcPath, desPath)
|
||||
console.info("MainAbility onContinue, writeToDisFileDir, copyFile successfully")
|
||||
} catch (err) {
|
||||
console.warn("MainAbility onContinue, writeToDisFileDir, copyFile failed : " + err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ export class WebViewUtil {
|
||||
|
||||
public static getWebController(): WebController{
|
||||
console.info('WebViewUtil, getWebController')
|
||||
if (!this.controllerShow) {
|
||||
if (!this.controllerShow && AppStorage.Get('openPhoto') == 0) {
|
||||
console.info('WebViewUtil, controllerShow is null')
|
||||
this.controllerShow = new WebController()
|
||||
}
|
||||
|
@ -49,15 +49,14 @@ export struct MyNoteHomeComp {
|
||||
return
|
||||
}
|
||||
|
||||
LogUtil.info(this.TAG, "databaseDir is " + this.context.databaseDir)
|
||||
// /data/storage/el2/database/tablet
|
||||
let databaseDir = this.context.databaseDir
|
||||
LogUtil.info(this.TAG, "databaseDir is " + databaseDir)
|
||||
|
||||
let dbPath = "/data/app/el2/100/database/com.ohos.note/tablet/db/note.db"
|
||||
let dbPath = 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)
|
||||
|
@ -65,17 +65,16 @@ 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()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_182431"))
|
||||
.height("100%")
|
||||
.opacity(StyleConstants.OPACITY_10)
|
||||
// Note list display area
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_182431"))
|
||||
.height("100%")
|
||||
.opacity(StyleConstants.OPACITY_10)
|
||||
NoteListComp({ controllerShow: this.controllerShow })
|
||||
}
|
||||
.flexShrink(0)
|
||||
@ -86,21 +85,20 @@ export struct NoteHomeComp {
|
||||
LayoutUtil.getWidthWeightMessage(this.sectionStatus)
|
||||
.noteListVisibility == 0 ? Visibility.None : Visibility.Visible)
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_182431"))
|
||||
.height("100%")
|
||||
.opacity(StyleConstants.OPACITY_10)
|
||||
// Note content display area
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_182431"))
|
||||
.height("100%")
|
||||
.opacity(StyleConstants.OPACITY_10)
|
||||
NoteContentComp({ controllerShow: this.controllerShow })
|
||||
}
|
||||
.flexShrink(0)
|
||||
.backgroundColor(this.search && this.inputKeyword.length == 0 ? $r("app.color.notecontent_color_000000") : $r("app.color.notecontent_color_ffffff"))
|
||||
.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)
|
||||
|
@ -102,7 +102,7 @@
|
||||
},
|
||||
{
|
||||
"name": "searchNote",
|
||||
"value": "搜索笔记"
|
||||
"value": "搜索笔记..."
|
||||
},
|
||||
{
|
||||
"name": "chooseFolder",
|
||||
@ -163,6 +163,18 @@
|
||||
{
|
||||
"name": "restore",
|
||||
"value": "已恢复"
|
||||
},
|
||||
{
|
||||
"name": "per_read_media",
|
||||
"value": "是否允许备忘录访问媒体资源"
|
||||
},
|
||||
{
|
||||
"name": "per_get_bundleInfo",
|
||||
"value": "是否允许备忘录打开图库资源"
|
||||
},
|
||||
{
|
||||
"name": "per_dis_dataSync",
|
||||
"value": "是否允许备忘录流转到其它设备"
|
||||
}
|
||||
]
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 18 18" style="enable-background:new 0 0 18 18;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#007DFF;}
|
||||
.st0{fill:#F86D05;}
|
||||
</style>
|
||||
<title>搜索</title>
|
||||
<path class="st0" d="M13.2,12.2l2.4,2.4c0.3,0.3,0.3,0.8,0,1.1s-0.8,0.3-1.1,0l-2.4-2.4C12.5,13,12.9,12.6,13.2,12.2z M7.8,1.5
|
||||
|
Before Width: | Height: | Size: 840 B After Width: | Height: | Size: 840 B |
@ -220,15 +220,14 @@ RICH_EDITOR.setBlockquote = function() {
|
||||
document.execCommand('formatBlock', false, '<blockquote>');
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertImage = function() {
|
||||
var url = './shuxue.png';
|
||||
RICH_EDITOR.insertImage = function(url) {
|
||||
console.log("js,url:" + url)
|
||||
var html = '<br></br><img src="' + url + '" alt="picvision" style="margin:0px auto;width:90%;display:table-cell;vertical-align:middle;border-radius:10px;max-width:90%" /><br></br>';
|
||||
RICH_EDITOR.insertHTML(html);
|
||||
RICH_EDITOR.editor.scrollIntoView(false)
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertHTML = function(html) {
|
||||
RICH_EDITOR.restorerange();
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
@ -303,4 +302,11 @@ function save_html_content() {
|
||||
var htmlString = encodeURI(RICH_EDITOR.getHtml())
|
||||
var str = callBackToApp.callbackhtmlSave(htmlString)
|
||||
console.log('hhh objName.test result:' + str);
|
||||
}
|
||||
|
||||
function scheduled_save_content() {
|
||||
console.info('scheduled_save_content')
|
||||
var htmlString = encodeURI(RICH_EDITOR.getHtml())
|
||||
var str = callBackToApp.callbackScheduledSave(htmlString)
|
||||
console.info('scheduled_save_content end')
|
||||
}
|
Loading…
Reference in New Issue
Block a user