!10 代码上传

Merge pull request !10 from jiangchengfeixue/master
This commit is contained in:
openharmony_ci
2022-03-21 06:15:56 +00:00
committed by Gitee
42 changed files with 1418 additions and 414 deletions
+2
View File
@@ -25,6 +25,8 @@
<!--policyitem type="compatibility" name="GPL-2.0+" path="abc/.*" desc="Process that runs independently, invoked by the X process."/-->
<!--policyitem type="license" name="LGPL" path="abc/.*" desc="Dynamically linked by module X"/-->
<!--policyitem type="copyright" name="xxx" path="abc/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/-->
<policyitem type="copyright" name="Copyright 2015 the original author or authors." path="gradlew" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="file generated by development tool"/>
<policyitem type="copyright" name="Copyright 2015 the original author or authors." path="gradlew.bat" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="file generated by development tool"/>
</policy>
</policylist>
<filefilterlist>
@@ -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
@@ -574,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'))
@@ -880,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 })
@@ -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<number>('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<number>('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<string>('ContinueFolder', continueFolder)
AppStorage.SetOrCreate<string>('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<string>('ContinueFolder', continueFolder)
AppStorage.SetOrCreate<string>('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")
}
})
}
@@ -24,8 +24,9 @@ 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"
@@ -47,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<string>('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<string>('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]
@@ -88,6 +91,8 @@ export struct NoteContentComp {
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)
@@ -102,7 +107,7 @@ export struct NoteContentComp {
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 })
@@ -127,7 +132,6 @@ export struct NoteContentComp {
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) {
@@ -187,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,
@@ -211,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)
@@ -233,7 +242,7 @@ export struct NoteContentOverViewComp {
this.editTitleDialogCtl.open()
// save continue data
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
console.log("NoteContentOverViewComp, set continue section success")
LogUtil.info(TAG, "NoteContentComp, set continue section success")
})
}.height(40)
.width(StyleConstants.PERCENTAGE_100)
@@ -312,7 +321,7 @@ export struct ToolBarComp {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
console.log("ToolBarComp, onDeleteConfirm, set continue note success")
LogUtil.info(TAG, "NoteContentOverViewComp, set continue section success")
}
editContentDialogCtl: CustomDialogController = new CustomDialogController({
@@ -353,6 +362,7 @@ 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)
@@ -364,9 +374,9 @@ export struct ToolBarComp {
}
this.editModel = !this.editModel
// 迁移
console.log("ToolBarComp, set continue section")
LogUtil.info(TAG, "ToolBarComp, set continue section")
AppStorage.SetOrCreate<number>('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)
}
@@ -398,7 +408,7 @@ export struct ToolBarComp {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('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)
@@ -466,38 +476,6 @@ export struct ToolBarComp {
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)
@@ -558,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<string>('ContinueNote', continueNote)
console.log("ToolBarComp, set continue note success")
LogUtil.info(TAG, "ToolBarComp, set continue note success")
}
})
Image($r('app.media.delete'))
@@ -619,7 +598,7 @@ export struct DeleteNoteComp {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
console.log("DeleteNoteComp, onDeleteConfirm, set continue note success")
LogUtil.info(TAG, "DeleteNoteComp, onDeleteConfirm, set continue note success")
}
build() {
@@ -25,7 +25,7 @@ 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"
@@ -46,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";
}
}
@@ -85,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({
@@ -233,11 +233,10 @@ 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<string>('ContinueNote', continueNote)
console.log("ToolBarComp, set continue note success")
LogUtil.info(TAG, "ToolBarComp, set continue note success")
}
})
}.width(36)
@@ -424,37 +423,6 @@ export struct EditNoteCompForPortrait {
Image($r('app.media.picture_white'))
.width(24)
.height(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 + "')"})
})
}
});
})
Text($r("app.string.photo"))
.fontSize(10).fontColor('#182431')
@@ -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<number>('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<number>('ContinueSection', this.sectionStatus)
LogUtil.info(TAG, "NoteOverViewComp, set continue section success")
}
})
}.alignItems(HorizontalAlign.Center)
Flex({
direction: FlexDirection.Column,
wrap: FlexWrap.Wrap,
@@ -104,6 +106,7 @@ struct NoteOverViewComp {
.fontSize(30)
.fontColor('#182431')
.fontWeight(FontWeight.Bold)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Row() {
Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString())
.fontSize(14)
@@ -111,6 +114,7 @@ struct NoteOverViewComp {
Text($r("app.string.noteslist"))
.fontSize(14)
.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)
@@ -128,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 })
@@ -181,7 +186,7 @@ export struct NoteItemComp {
}
},
item => item.index)
}
}.textOverflow({ overflow: TextOverflow.Ellipsis })
}
Row({ space: 4 }) {
@@ -189,6 +194,7 @@ export struct NoteItemComp {
.fontSize(14)
.fontColor('#99182431')
.fontWeight(FontWeight.Regular)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Image($r("app.media.favorite"))
.height(16)
.width(16)
@@ -203,12 +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' })
.visibility(this.noteItem.content_img ? Visibility.Visible : Visibility.None)
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)
@@ -250,7 +258,7 @@ export struct NoteItemComp {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('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 + "')" })
@@ -297,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<string>('ContinueNote', continueNote)
console.log("doSearch, set continue note success")
LogUtil.info(TAG, "doSearch, set continue note success")
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
})
}
@@ -431,7 +440,7 @@ export struct OperateNoteComp {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
console.log("OperateNoteComp, set continue note success")
LogUtil.info(TAG, "OperateNoteComp, set continue note success")
}
build() {
@@ -560,7 +569,7 @@ export struct AddNoteComp {
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
AppStorage.SetOrCreate<number>('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)
}
@@ -595,12 +604,12 @@ export struct SearchComp {
this.search = true
})
}
.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") })
.margin({ right: this.search ? 40 : 0 })
}
}
}
@@ -668,7 +677,7 @@ export struct OperateNoteCompForPortrait {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
console.log("OperateNoteCompForPortrait, set continue note success")
LogUtil.info(TAG, "OperateNoteCompForPortrait, set continue note success")
}
build() {
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LogUtil from '../baseUtil/LogUtil.ets'
import {LogUtil} from '../baseUtil/LogUtil.ets'
import MediaLib from '@ohos.multimedia.mediaLibrary';
const TAG = "MediaLibraryAccess"
@@ -23,13 +23,11 @@ export class MediaLibraryAccess {
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) {
@@ -41,7 +39,7 @@ export class MediaLibraryAccess {
album.obj = file;
return album;
} else {
LogUtil.error(TAG, 'Failed getFirstObject')
LogUtil.warn(TAG, 'Failed getFirstObject')
}
}
return album;
@@ -58,7 +56,7 @@ export class MediaLibraryAccess {
LogUtil.info(TAG, `openAsset end. fd: ${fd}`)
if (fd <= 0) {
LogUtil.error(TAG, 'openAsset Fail')
LogUtil.warn(TAG, 'openAsset Fail')
return;
}
@@ -69,7 +67,7 @@ export class MediaLibraryAccess {
LogUtil.info(TAG, 'closeAsset start')
if (fd <= 0) {
LogUtil.error(TAG, 'closeAsset fd is invalid')
LogUtil.warn(TAG, 'closeAsset fd is invalid')
return;
}
@@ -78,7 +76,7 @@ export class MediaLibraryAccess {
LogUtil.info(TAG, 'closeAsset end')
} catch (error) {
LogUtil.error(TAG, 'closeAsset fail')
LogUtil.warn(TAG, 'closeAsset fail')
}
}
}
@@ -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)
}
@@ -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)
}
@@ -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"
@@ -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<string> {
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;
}
}
@@ -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'
@@ -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
}
@@ -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'
@@ -141,7 +141,7 @@ export class NoteUtil {
if (folderData.color == "#ffffff") {
return "#FFEBE1"
}
LogUtil.info(TAG, "isSelected %s, folderData.color: %s", isSelected, folderData.color)
LogUtil.info(TAG, "isSelected %s, folderData.color: %s" + isSelected.toString() + folderData.color.toString())
return isSelected ? selectedNoteBgColorMap[folderData.color] : unSelectedNoteBgColorMap[folderData.color]
}
@@ -158,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"
}
@@ -250,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)
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LogUtil from './LogUtil.ets'
import {LogUtil} from './LogUtil.ets'
import {MediaLibraryAccess} from '../access/MediaLibraryAccess.ets';
import fileio from '@ohos.fileio';
@@ -26,13 +26,13 @@ export class OperationUtils {
var context = globalThis.noteContext
let fileAsset = await this.getFileAssetById(numId,context);
if (fileAsset == null || fileAsset == undefined) {
LogUtil.error(TAG, "Failed to get fileAsset")
LogUtil.warn(TAG, "Failed to get fileAsset")
return;
}
let fd = await MediaLibraryAccess.openAsset('RW', fileAsset);
if (fd <= 0) {
LogUtil.error(TAG, "fd is invaild")
LogUtil.warn(TAG, "fd is invaild")
return;
}
LogUtil.info(TAG, 'copyAsset read end!')
@@ -43,7 +43,6 @@ export class OperationUtils {
// 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")
@@ -15,7 +15,7 @@
import ohosDataRdb from '@ohos.data.rdb'
import fileio from '@ohos.fileio'
import LogUtil from './LogUtil.ets'
import {LogUtil} from './LogUtil.ets'
import FolderUtil from './FolderUtil.ets'
import NoteUtil from './NoteUtil.ets'
import SysDefData from '../model/databaseModel/SysDefData.ets'
@@ -93,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')
@@ -155,7 +155,7 @@ export default {
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', NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes))
AppStorage.SetOrCreate('Section', 3)
@@ -164,7 +164,7 @@ export default {
LogUtil.info(TAG, "createRdbStore, set DBQueryFinished 1")
})
.catch((err) => {
LogUtil.error(TAG, "createRdbStore, error : " + err)
LogUtil.warn(TAG, "createRdbStore, error : " + err)
})
},
@@ -287,7 +287,7 @@ export default {
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', NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes))
AppStorage.SetOrCreate('Section', 3)
@@ -296,7 +296,7 @@ export default {
LogUtil.info(TAG, "initAppStorage, set DBQueryFinished 1")
})
.catch((err) => {
LogUtil.error(TAG, "initAppStorage, error : " + err)
LogUtil.warn(TAG, "initAppStorage, error : " + err)
})
},
@@ -326,7 +326,7 @@ export default {
let srcFd
try {
srcFd = fileio.openSync(srcPath, 0o2, 0o666)
console.info(TAG, "open srcPath success : " + srcFd)
LogUtil.info(TAG, "open srcPath success : " + srcFd)
} catch (err) {
LogUtil.warn(TAG, "open srcPath failed : " + err)
}
@@ -355,7 +355,7 @@ export default {
callback(rowId)
}
}).catch((err) => {
LogUtil.error(TAG, "insert error : " + err)
LogUtil.warn(TAG, "insert error : " + err)
})
},
@@ -371,7 +371,7 @@ export default {
callback(affectedRowCount)
}
}).catch((err) => {
LogUtil.error(TAG, "delete error : " + err)
LogUtil.warn(TAG, "delete error : " + err)
})
},
@@ -388,7 +388,7 @@ export default {
callback(affectedRowCount)
}
}).catch((err) => {
LogUtil.error(TAG, "update error : " + err)
LogUtil.warn(TAG, "update error : " + err)
})
},
@@ -405,7 +405,7 @@ export default {
callback(resultSet)
}
}).catch((err) => {
LogUtil.error(TAG, "query error : " + err)
LogUtil.warn(TAG, "query error : " + err)
})
},
@@ -415,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]
}
}
@@ -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);
+6 -2
View File
@@ -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')
},
}
@@ -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"
}
]
}
@@ -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": "已恢复"
}
]
}
+6 -18
View File
@@ -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,10 +1,40 @@
/**
* 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 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<string>('ContinueFolder', continueFolder)
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
AppStorage.SetOrCreate<number>('ContinueSection', continueSection)
// 设置迁移标记
AppStorage.SetOrCreate<number>('IsContinue', 1)
this.context.restoreWindowStage(null)
}
AppStorage.SetOrCreate<number>('openPhoto', 0)
AppStorage.SetOrCreate<number>('openPerm', 0)
globalThis.noteContext = this.context
}
@@ -37,4 +67,4 @@ export default class MainAbility extends Ability {
})
console.log("MainAbility controllerShow end")
}
};
}
@@ -25,7 +25,7 @@ export class WebViewUtil {
public static getWebController(): WebController{
console.info('WebViewUtil, getWebController')
if (!this.controllerShow && AppStorage.Get('openPhoto') == 0) {
if (!this.controllerShow && AppStorage.Get('openPhoto') == 0 && AppStorage.Get('openPerm') == 0) {
console.info('WebViewUtil, controllerShow is null')
this.controllerShow = new WebController()
}
+16 -1
View File
@@ -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"
@@ -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,14 +46,50 @@ 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
}
let databaseDir = this.context.databaseDir
LogUtil.info(this.TAG, "databaseDir is " + databaseDir)
let permissionList: Array<string> = [
"ohos.permission.READ_MEDIA",
"ohos.permission.DISTRIBUTED_DATASYNC"
]
bundle.getApplicationInfo('com.ohos.note', 0, 100).then((appInfo) => {
let tokenId = appInfo.accessTokenId
let statusPromise: Array<Promise<number>> = []
let requestList: Array<string> = []
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<number>('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<number>('openPerm', 0)
}, (err) => {
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
});
} else {
LogUtil.info(this.TAG, 'check all permissions are granted.')
}
})
})
let dbPath = databaseDir + "/db/note.db"
let dbPath = this.context.databaseDir + "/db/note.db"
try {
fileio.accessSync(dbPath)
LogUtil.info(this.TAG, "db has created")
@@ -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')
@@ -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表示一分栏
@@ -163,6 +163,18 @@
{
"name": "restore",
"value": "已恢复"
},
{
"name": "per_read_media",
"value": "是否允许备忘录访问媒体资源"
},
{
"name": "per_get_bundleInfo",
"value": "是否允许备忘录打开图库资源"
},
{
"name": "per_dis_dataSync",
"value": "是否允许备忘录流转到其它设备"
}
]
}
@@ -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"
},
{
"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"
}
]
}
@@ -14,7 +14,7 @@
*/
html {
height: 100%;
height: 15%;
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
}
@@ -302,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')
}
@@ -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": "已恢复"
}
]
}
@@ -1,8 +1,21 @@
/**
* 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 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) {
@@ -21,6 +34,7 @@ export default class MainAbility extends Ability {
this.context.restoreWindowStage(null)
}
AppStorage.SetOrCreate<number>('openPhoto', 0)
AppStorage.SetOrCreate<number>('openPerm', 0)
globalThis.noteContext = this.context
}
@@ -30,42 +44,6 @@ 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)
}
@@ -89,75 +67,4 @@ export default class MainAbility extends Ability {
})
console.log("MainAbility controllerShow end")
}
onContinue(wantParam: { [key: string]: any }) {
console.log("MainAbility onContinue")
// 获取本端的迁移数据
let continueFolder = AppStorage.Get<string>('ContinueFolder')
if (continueFolder == undefined || continueFolder == null) {
console.log("MainAbility onContinue, continue first folder")
continueFolder = JSON.stringify(AppStorage.Get('AllFolderArray')[0].toFolderObject())
}
let continueNote = AppStorage.Get<string>('ContinueNote')
if (continueNote == undefined || continueNote == null) {
console.log("MainAbility onContinue, continue first note")
continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject())
}
let continueSection = AppStorage.Get<number>('ContinueSection')
if (continueSection == undefined || continueSection == null) {
console.log("MainAbility onContinue, continue section 3")
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
wantParam["ContinueSection"] = continueSection
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 && AppStorage.Get('openPhoto') == 0) {
if (!this.controllerShow && AppStorage.Get('openPhoto') == 0 && AppStorage.Get('openPerm') == 0) {
console.info('WebViewUtil, controllerShow is null')
this.controllerShow = new WebController()
}
@@ -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"
@@ -14,9 +14,11 @@
*/
import fileio from '@ohos.fileio'
import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import {NoteHomeComp} from './NoteHome.ets'
import {NoteHomePortraitComp} from './NoteHomePortrait.ets'
import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
@Entry
@@ -28,7 +30,7 @@ export struct MyNoteHomeComp {
TAG = "MyNoteHomeComp"
build() {
Flex() {
Row() {
if (this.dBQueryFinished == 1) {
if (this.portraitModel == true) {
NoteHomePortraitComp()
@@ -45,14 +47,50 @@ 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
}
let databaseDir = this.context.databaseDir
LogUtil.info(this.TAG, "databaseDir is " + databaseDir)
let permissionList: Array<string> = [
"ohos.permission.READ_MEDIA",
"ohos.permission.DISTRIBUTED_DATASYNC"
]
bundle.getApplicationInfo('com.ohos.note', 0, 100).then((appInfo) => {
let tokenId = appInfo.accessTokenId
let statusPromise: Array<Promise<number>> = []
let requestList: Array<string> = []
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<number>('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<number>('openPerm', 0)
}, (err) => {
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
});
} else {
LogUtil.info(this.TAG, 'check all permissions are granted.')
}
})
})
let dbPath = databaseDir + "/db/note.db"
let dbPath = this.context.databaseDir + "/db/note.db"
try {
fileio.accessSync(dbPath)
LogUtil.info(this.TAG, "db has created")
@@ -17,7 +17,7 @@ import {FolderListComp} from '../../../../../../../common/component/src/main/ets
import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets'
import {NoteContentComp} from '../../../../../../../common/component/src/main/ets/default/NoteContentComp'
import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets'
import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets'
import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
@@ -25,6 +25,7 @@ import {SysDefFolderUuid} from '../../../../../../../common/utils/src/main/ets/d
import LayoutUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets'
import NoteUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
import {WebViewUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets'
import mediaquery from '@ohos.mediaquery'
@Entry
@Component
@@ -34,7 +35,7 @@ export struct NoteHomeComp {
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
// 当前文件夹、笔记、分栏
// 当前文件夹、笔记、分栏
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section')
@@ -52,6 +53,13 @@ export struct NoteHomeComp {
TAG = "NoteHomeComp"
narrowWinListener = mediaquery.matchMediaSync('(width < 2000)')
onWinSizeChange(mediaQueryResult) {
if (this.sectionStatus != 1) {
this.sectionStatus = (mediaQueryResult.matches) ? 2 : 3
}
}
build() {
Flex({ justifyContent: FlexAlign.Start }) {
// Folder list display area
@@ -60,7 +68,7 @@ export struct NoteHomeComp {
}
.flexShrink(0)
.backgroundColor($r("app.color.folderlist_bgcolor_f1f3f5"))
.width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).folderListWeight)
.width(200)
.height(StyleConstants.PERCENTAGE_100)
.visibility(
LayoutUtil.getWidthWeightMessage(this.sectionStatus)
@@ -79,12 +87,11 @@ export struct NoteHomeComp {
}
.flexShrink(0)
.backgroundColor($r("app.color.notelist_bgcolor_f1f3f5"))
.width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).noteListWeight)
.layoutWeight(2)
.height(StyleConstants.PERCENTAGE_100)
.visibility(
LayoutUtil.getWidthWeightMessage(this.sectionStatus)
.noteListVisibility == 0 ? Visibility.None : Visibility.Visible)
// Note content display area
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
Divider()
@@ -97,7 +104,7 @@ export struct NoteHomeComp {
}
.flexShrink(0)
.backgroundColor($r("app.color.notecontent_color_ffffff"))
.width(LayoutUtil.getWidthWeightMessage(this.sectionStatus).noteCotentWeight)
.layoutWeight(this.sectionStatus != 1 ? 3 : null)
.height(StyleConstants.PERCENTAGE_100)
.enabled(this.longpress || this.search && this.inputKeyword.length == 0 ? false : true)
}
@@ -107,6 +114,8 @@ export struct NoteHomeComp {
aboutToAppear(): void{
LogUtil.info(this.TAG, "aboutToAppear")
this.narrowWinListener.on('change', this.onWinSizeChange.bind(this))
this.sectionStatus = this.narrowWinListener.matches ? 2 : 3
}
aboutToDisappear(): void{
@@ -17,7 +17,7 @@ import {FolderListComp} from '../../../../../../../common/component/src/main/ets
import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets'
import {NoteContentComp} from '../../../../../../../common/component/src/main/ets/default/NoteContentComp'
import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets'
import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets'
import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
@@ -30,7 +30,7 @@ export struct NoteHomePortraitComp {
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
// 当前文件夹、笔记、分栏
// 当前文件夹、笔记、分栏
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section')
@@ -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"
}
]
}
@@ -14,7 +14,7 @@
*/
html {
height: 100%;
height: 15%;
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
}
@@ -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": "已恢复"
}
]
}
Binary file not shown.