备忘录升级API12

Signed-off-by: zhanghong <zhanghong121@huawei.com>
This commit is contained in:
zhanghong
2024-12-04 14:23:53 +08:00
parent 3be2312e14
commit 246d4bb04c
12 changed files with 225 additions and 160 deletions
+2 -2
View File
@@ -20,8 +20,8 @@
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": 10,
"compatibleSdkVersion": 10,
"compileSdkVersion": 12,
"compatibleSdkVersion": 12,
"runtimeOS": "OpenHarmony"
}
],
@@ -191,7 +191,7 @@ export class NoteUtil {
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, allNoteDataArray[index].uuid)
RdbStoreUtil.delete(predicates_note, null!);
RdbStoreUtil.delete(predicates_note, null);
allNoteDataArray.splice(index, 1);
}
index++
@@ -278,7 +278,7 @@ export class NoteUtil {
LogUtil.info(TAG, "delete note:" + selectedNoteData.uuid);
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicates_note.equalTo(NoteTableColumn.Uuid, selectedNoteData.uuid);
RdbStoreUtil.delete(predicates_note, null!);
RdbStoreUtil.delete(predicates_note, null);
LogUtil.info(TAG, "delete note success:" + selectedNoteData.uuid);
return true;
}
@@ -115,7 +115,7 @@ class RdbStoreUtil {
noteData.folder_uuid = SysDefFolderUuid.UnClassified
noteDataArray.push(noteData)
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
this.insert(TableName.NoteTable, noteData.toNoteObject(), null!);
this.insert(TableName.NoteTable, noteData.toNoteObject(), null);
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, SysDefFolderUuid.UnClassified))
} else {
// 迁移过来的笔记在本地存在,则进行修改
@@ -128,7 +128,7 @@ class RdbStoreUtil {
}
let predicates_note = this.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.CreatedTime, noteData.created_time)
this.update(noteData.toNoteObject(), predicates_note, null!);
this.update(noteData.toNoteObject(), predicates_note, null);
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid))
}
AppStorage.SetOrCreate('Note', noteData)
@@ -138,7 +138,7 @@ class RdbStoreUtil {
} else {
LogUtil.info(TAG, "createRdbStore, IsContinue false")
AppStorage.SetOrCreate('Folder', (AppStorage.Get('AllFolderArray') as FolderData[])[0]);
let note = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes)
let note = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, SysDefFolderUuid.AllNotes);
AppStorage.SetOrCreate('Note', note)
if (note) {
AppStorage.SetOrCreate<string>('ContinueNote', JSON.stringify(note.toNoteObject()))
@@ -289,7 +289,7 @@ class RdbStoreUtil {
noteData.folder_uuid = SysDefFolderUuid.UnClassified
noteDataArray.push(noteData)
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
this.insert(TableName.NoteTable, noteData.toNoteObject(), null!);
this.insert(TableName.NoteTable, noteData.toNoteObject(), null);
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, SysDefFolderUuid.UnClassified))
} else {
// 迁移过来的笔记在本地存在,则进行修改
@@ -302,7 +302,7 @@ class RdbStoreUtil {
}
let predicates_note = this.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.CreatedTime, noteData.created_time)
this.update(noteData.toNoteObject(), predicates_note, null!);
this.update(noteData.toNoteObject(), predicates_note, null);
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid))
}
AppStorage.SetOrCreate('Note', noteData)
@@ -312,7 +312,7 @@ class RdbStoreUtil {
} else {
LogUtil.info(TAG, "initAppStorage, IsContinue false")
AppStorage.SetOrCreate('Folder', (AppStorage.Get('AllFolderArray') as FolderData[])[0]);
let note = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes)
let note = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, SysDefFolderUuid.AllNotes);
AppStorage.SetOrCreate('Note', note)
if (note) {
AppStorage.SetOrCreate<string>('ContinueNote', JSON.stringify(note.toNoteObject()))
@@ -437,7 +437,7 @@ class RdbStoreUtil {
* @param valueBucket
* @param callback
*/
insert(tableName: string, valueBucket: relationalStore.ValuesBucket, callback: Callback<number>) {
insert(tableName: string, valueBucket: relationalStore.ValuesBucket, callback: Callback<number> | null) {
rdbStore!.insert(tableName, valueBucket).then((rowId: number) => {
LogUtil.info(TAG, "insert success, rowId is " + rowId)
if (callback != null) {
@@ -453,7 +453,7 @@ class RdbStoreUtil {
* @param predicates
* @param callback
*/
delete(predicates: relationalStore.RdbPredicates, callback: Callback<number>) {
delete(predicates: relationalStore.RdbPredicates, callback: Callback<number> | null) {
rdbStore!.delete(predicates).then((affectedRowCount: number) => {
LogUtil.info(TAG, "delete success, affectedRowCount is " + affectedRowCount)
if (callback != null) {
@@ -471,7 +471,7 @@ class RdbStoreUtil {
* @param callback
*/
update(valueBucket: relationalStore.ValuesBucket, predicates: relationalStore.RdbPredicates,
callback: Callback<number>) {
callback: Callback<number> | null) {
if (!rdbStore) {
return;
}
@@ -371,7 +371,8 @@ export struct NoteDataMoveDialog {
.width(288)
List() {
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null &&
this.NoteDataMoveArray.length > 0) {
ForEach(this.NoteDataMoveArray.slice(0, this.NoteDataMoveArray.length - 1), (item: FolderData) => {
ListItem() {
NoteDataMoveItemComp({ folderItem: item })
@@ -91,11 +91,11 @@ export struct FolderListComp {
Column() {
FolderItemComp({
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.MyFavorites),
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray')!, SysDefFolderUuid.MyFavorites),
controllerShow: this.controllerShow
})
FolderItemComp({
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.RecentDeletes),
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray')!, SysDefFolderUuid.RecentDeletes),
controllerShow: this.controllerShow
})
}
@@ -150,7 +150,7 @@ export struct NoteAndCreateComp {
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)
// insert folder to db
RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null!);
RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null);
AppStorage.SetOrCreate('isUpdate', true)
}
@@ -242,7 +242,7 @@ struct FolderItemComp {
// update folder to db
let predicates_folder = RdbStoreUtil.getRdbPredicates(TableName.FolderTable)
predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid)
RdbStoreUtil.update(this.folderItem.toFolderObject(), predicates_folder, null!);
RdbStoreUtil.update(this.folderItem.toFolderObject(), predicates_folder, null);
this.isUpdate = true
}
@@ -268,8 +268,8 @@ struct FolderItemComp {
onDeleteConfirm() {
let currentFolder = FolderUtil.getFolderData(this.AllFolderArray, this.folderItem.uuid)
let index = this.AllFolderArray.indexOf(currentFolder)
let currentNoteDataArray = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.folderItem.uuid)
let deleteNoteDataArray = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), 'sys_def_recentDeletes_uuid')
let currentNoteDataArray = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.folderItem.uuid);
let deleteNoteDataArray = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, 'sys_def_recentDeletes_uuid');
if (index > -1) {
this.AllFolderArray.splice(index, 1)
if (deleteNoteDataArray.length != 0) {
@@ -280,7 +280,7 @@ struct FolderItemComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
}
})
}
@@ -292,13 +292,13 @@ struct FolderItemComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
}
// delete folder from db
let predicates_folder = RdbStoreUtil.getRdbPredicates(TableName.FolderTable)
predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid)
RdbStoreUtil.delete(predicates_folder, null!);
RdbStoreUtil.delete(predicates_folder, null);
// update selectedFolderData and selectedNoteData
this.selectedFolderData = FolderUtil.getFolderData(this.AllFolderArray, SysDefFolderUuid.AllNotes)
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, SysDefFolderUuid.AllNotes)!;
@@ -348,7 +348,7 @@ struct FolderItemComp {
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)
// insert folder to db
RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null!);
RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null);
this.isUpdate = true
}
@@ -457,7 +457,7 @@ struct FolderItemComp {
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
} else {
this.selectedFolderData = this.folderItem
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.folderItem.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.folderItem.uuid)!;
if (!this.selectedNoteData) {
return
}
@@ -522,7 +522,7 @@ struct FolderItemComp {
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
} else {
this.selectedFolderData = this.folderItem
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.folderItem.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.folderItem.uuid)!;
if (!this.selectedNoteData) {
return
}
@@ -105,7 +105,7 @@ export struct NoteContent {
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!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid)
AppStorage.SetOrCreate<NoteData>('NewNote', this.selectedNoteData)
AppStorage.SetOrCreate<boolean>('needRefresh', true)
@@ -130,7 +130,7 @@ export struct NoteContent {
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!);
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())
@@ -498,7 +498,7 @@ export struct NoteContentOverViewComp {
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!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -517,7 +517,7 @@ export struct NoteContentOverViewComp {
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!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -572,7 +572,7 @@ export struct NoteContentOverViewComp {
.padding({ left: 8, right: 8, top: 4, bottom: 4 })
.margin({ left: 8 })
.borderRadius(16)
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid, SysDefFolderUuid.AllNotes, false))
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray')!, this.selectedNoteData.folder_uuid, SysDefFolderUuid.AllNotes, false))
.bindMenu(this.MenuBuilder)
}.alignItems(VerticalAlign.Top).height(40).width(StyleConstants.PERCENTAGE_100)
}
@@ -136,7 +136,7 @@ export struct NoteContentComp {
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!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
@@ -156,7 +156,7 @@ export struct NoteContentComp {
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!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid)
this.sectionStatus = this.lastSectionStatus
this.sectionStatus = mediaquery.matchMediaSync('(width < 2000)').matches ? 2 : 3
@@ -178,7 +178,7 @@ export struct NoteContentComp {
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!);
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())
@@ -401,14 +401,15 @@ export struct NoteContentOverViewComp {
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!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
NoteUtil.refreshAll()
}
@Builder MenuBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
List() {
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null &&
this.NoteDataMoveArray.length > 0) {
ForEach(this.NoteDataMoveArray, (item: FolderData) => {
ListItem() {
NoteDataMoveItemCompTablet({ folderItem: item, uuid: this.selectedNoteData.folder_uuid })
@@ -417,7 +418,7 @@ export struct NoteContentOverViewComp {
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)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
if (this.sectionStatus != 1) {
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
this.controllerShow.runJavaScript(
@@ -425,7 +426,7 @@ export struct NoteContentOverViewComp {
)
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
} else {
this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), item.uuid)
this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray')!, item.uuid);
}
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
@@ -487,7 +488,7 @@ export struct NoteContentOverViewComp {
.padding({ left: 8, right: 8, top: 4, bottom: 4 })
.margin({ left: 8 })
.borderRadius(16)
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid, SysDefFolderUuid.AllNotes, false))
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray')!, this.selectedNoteData.folder_uuid, SysDefFolderUuid.AllNotes, false))
.bindMenu(this.MenuBuilder)
}.alignItems(VerticalAlign.Top).height(40).width(StyleConstants.PERCENTAGE_100)
}
@@ -534,16 +535,16 @@ export struct ToolBarComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
} else {
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData.uuid)
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.delete(predicates_note, null!);
RdbStoreUtil.delete(predicates_note, null);
}
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
try {
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text! + "')");
} catch (error) {
@@ -643,9 +644,9 @@ export struct ToolBarComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null);
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
this.controllerShow.runJavaScript(
"RICH_EDITOR.setHtml('" + this.selectedNoteData!.content_text + "')"
)
@@ -42,11 +42,13 @@ import { BusinessError } from '@ohos.base';
import resourceManager from '@ohos.resourceManager';
import common from '@ohos.app.ability.common';
import window from '@ohos.window';
import { wantAgent, WantAgent } from '@kit.AbilityKit';
import { backgroundTaskManager } from '@kit.BackgroundTasksKit';
let time_id: number = 0;
let noteContext = AppStorage.Get<common.UIAbilityContext>('noteContext')!;
const TAG = "NoteContentCompPortrait"
const TAG = 'NoteContentCompPortrait';
interface NoteContentType {
callbackhtml: (html: string) => void;
@@ -64,17 +66,15 @@ async function routePage() {
try {
await router.back()
} catch (err) {
LogUtil.info(TAG, "fail callback")
LogUtil.info(TAG, 'fail callback');
}
}
// Note content component
@Component
export struct NoteContentCompPortrait {
@State scrollHeight: number = 0;
@State keyHeight: number = 0;
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote')!;
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get("NewFolder")!;
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('NewFolder')!;
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Provide('EditModel') editModel: boolean = false
@StorageLink('dpi') dpi: number = 240
@@ -142,14 +142,14 @@ export struct NoteContentCompPortrait {
};
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!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
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)
LogUtil.info(TAG, "callbackhtml, set continue note success")
LogUtil.info(TAG, 'callbackhtml, set continue note success');
},
callbackImagePath: (imgName) => {
// updata note image
@@ -165,9 +165,9 @@ export struct NoteContentCompPortrait {
}
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!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
LogUtil.info(TAG, 'callbackScheduledSave, update note success:' + this.selectedNoteData?.uuid)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
@@ -177,18 +177,18 @@ export struct NoteContentCompPortrait {
callbackPasteImage: (html) => {
if (html) {
LogUtil.info(TAG, 'paste info' + html)
let realHtml = ""
let realHtml = '';
let base64regex: RegExp = new RegExp('/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/');
if (html && html.indexOf("base64") > 0) {
LogUtil.info(TAG, " getSrcFromHtml, src[1] : " + html)
if (html && html.indexOf('base64') > 0) {
LogUtil.info(TAG, ' getSrcFromHtml, src[1] : ' + html);
let imgData = html.split(',')[1];
let imgType = 'png'
if (html.indexOf("jpeg") > 0) {
if (html.indexOf('jpeg') > 0) {
imgType = 'jpg'
} else if (html.indexOf("gif") > 0) {
} else if (html.indexOf('gif') > 0) {
imgType = 'gif'
}
let filePath = ""
let filePath = '';
if (base64regex.test(imgData)) {
let base64 = new util.Base64()
let decodeArr = base64.decodeSync(imgData)
@@ -196,7 +196,7 @@ export struct NoteContentCompPortrait {
} else {
filePath = OperationUtils.saveImage(imgData, imgType)
}
realHtml = "file://" + filePath
realHtml = 'file://' + filePath;
}
LogUtil.info(TAG, 'paste info11' + realHtml)
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')")
@@ -219,17 +219,43 @@ export struct NoteContentCompPortrait {
},
addToDo: () => {
// 清单
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.setTodo()")
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.setTodo()');
},
chooseStyle: () => {
this.editContentDialogCtl!.open();
},
openAlbum: async () => {
let context: common.UIAbilityContext = AppStorage.Get('context')!;
// 申请长时任务
let wantAgentInfo: wantAgent.WantAgentInfo = {
wants: [
{
bundleName: 'com.ohos.note',
abilityName: 'com.ohos.note.MainAbility'
}
],
actionType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
try {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: WantAgent) => {
backgroundTaskManager.startBackgroundRunning(context,
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
LogUtil.info(TAG, `Operation startBackgroundRunning succeeded`);
}).catch((error: BusinessError) => {
LogUtil.error(TAG, `Operation startBackgroundRunning failed. code is ${JSON.stringify(error.code)},
message is ${JSON.stringify(error.message)}`);
});
});
} catch (error) {
LogUtil.error(TAG, `Operation getWantAgent failed. code is ${(error as BusinessError).code},
message is ${(error as BusinessError).message}`);
}
let permissionList: Permissions[] = [
"ohos.permission.READ_IMAGEVIDEO",
"ohos.permission.WRITE_IMAGEVIDEO"
'ohos.permission.READ_IMAGEVIDEO',
'ohos.permission.WRITE_IMAGEVIDEO'
]
let context: common.UIAbilityContext = AppStorage.Get("context")!;
let AtManager = abilityAccessCtrl.createAtManager();
await AtManager.requestPermissionsFromUser(context, permissionList).then((data) => {
LogUtil.info(TAG, 'data permissions : ' + data.permissions)
@@ -244,29 +270,41 @@ export struct NoteContentCompPortrait {
})
LogUtil.info(TAG, 'startAbility start')
await noteContext.startAbilityForResult({
parameters: { uri: "singleselect", filterMediaType: "FILTER_MEDIA_TYPE_IMAGE" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
parameters: { uri: 'singleselect', filterMediaType: 'FILTER_MEDIA_TYPE_IMAGE' },
bundleName: 'com.ohos.photos',
abilityName: 'com.ohos.photos.MainAbility',
}).then((v: common.AbilityResult) => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
let imageUri = '';
if (param != null && param != undefined) {
let uri = param['select-item-list'] as Record<string,string>;
let uri = param['select-item-list'] as Record<string, string>;
imageUri = uri[0];
}
LogUtil.info(TAG, "image url" + imageUri)
LogUtil.info(TAG, 'image url' + imageUri);
// 拷贝
if (imageUri != null && imageUri != "") {
if (imageUri != null && imageUri != '') {
OperationUtils.copy(imageUri).then((uriPath) => {
let path = 'file://' + uriPath;
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.getFocus()")
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.getFocus()');
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImage('" + path + "')")
})
}
}
// 取消长时任务
try {
backgroundTaskManager.stopBackgroundRunning(context).then(() => {
LogUtil.info(TAG, `Operation stopBackgroundRunning succeeded`);
}).catch((error: BusinessError) => {
LogUtil.error(TAG, `Operation stopBackgroundRunning failed. code is ${JSON.stringify(error.code)},
message is ${JSON.stringify(error.message)}`);
});
} catch (error) {
LogUtil.error(TAG, `Operation stopBackgroundRunning failed. code is ${JSON.stringify(error.code)},
message is ${JSON.stringify(error.message)}`);
}
});
},
getBreakPoint: () => {
@@ -294,20 +332,21 @@ export struct NoteContentCompPortrait {
.javaScriptAccess(true)
.javaScriptProxy({
object: this.noteContent,
name: "callBackToApp", // html--> name.method
methodList: ["callbackhtml", "callbackScheduledSave", "callbackPasteImage", "callbackImagePath", "addToDo", "chooseStyle", "openAlbum", "callbackGetSize", "getBreakPoint"],
name: 'callBackToApp', // html--> name.method
methodList: ['callbackhtml', 'callbackScheduledSave', 'callbackPasteImage', 'callbackImagePath',
'addToDo', 'chooseStyle', 'openAlbum', 'callbackGetSize', 'getBreakPoint'],
controller: this.controllerShow
})
.onPageEnd((e) => {
try {
if (this.dpi <= 240) {
this.controllerShow.runJavaScript("changeSizeToRk()")
this.controllerShow.runJavaScript('changeSizeToRk()');
} else if (this.dpi <= 320 && this.dpi > 240) {
this.controllerShow.runJavaScript("changeSizeToPhone()")
this.controllerShow.runJavaScript('changeSizeToPhone()');
} else {
this.controllerShow.runJavaScript("changeSizeToTablet()")
this.controllerShow.runJavaScript('changeSizeToTablet()');
}
LogUtil.info(TAG, "finish loadurl")
LogUtil.info(TAG, 'finish loadurl');
let self = this
this.controllerShow.runJavaScript(
"RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')",
@@ -342,13 +381,13 @@ export struct NoteContentCompPortrait {
time_id = setInterval(() => {
try {
if (!this.isClickBack) {
this.controllerShow.runJavaScript("scheduledSaveContent()")
this.controllerShow.runJavaScript('scheduledSaveContent()');
}
} catch (error) {
LogUtil.info(TAG, 'setInterval error')
}
}, 3000)
LogUtil.info(TAG, "setInterval time_id : " + time_id)
LogUtil.info(TAG, 'setInterval time_id : ' + time_id)
this.editModel = true
})
}
@@ -369,7 +408,7 @@ export struct NoteContentCompPortrait {
aboutToAppear(): void {
this.isClickBack = false
LogUtil.info(TAG, "aboutToAppear")
LogUtil.info(TAG, 'aboutToAppear');
window.getLastWindow(getContext(this)).then(currentWindow => {
currentWindow.setWindowLayoutFullScreen(true);
})
@@ -379,7 +418,7 @@ export struct NoteContentCompPortrait {
this.isClickBack = true
clearInterval(time_id)
NoteUtil.refreshAll()
LogUtil.info(TAG, "aboutToDisappear")
LogUtil.info(TAG, 'aboutToDisappear');
this.editContentDialogCtl = null
}
}
@@ -403,7 +442,7 @@ export struct NoteContentOverViewComp {
aboutToAppear() {
this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length);
if (this.AllFolderArray[1] === undefined || this.AllFolderArray[1] === null) {
LogUtil.info(TAG, "this AllFolderArray[1] undefined")
LogUtil.info(TAG, 'this AllFolderArray[1] undefined');
return
}
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
@@ -416,9 +455,9 @@ export struct NoteContentOverViewComp {
confirm(newTitle: string) {
this.selectedNoteData.title = newTitle
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!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -431,16 +470,17 @@ export struct NoteContentOverViewComp {
Column() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
List() {
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null && this.NoteDataMoveArray !== []) {
if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null &&
this.NoteDataMoveArray.length > 0) {
ForEach(this.NoteDataMoveArray, (item: FolderData) => {
ListItem() {
NoteDataMoveItemCompMenu({ folderItem: item, uuid: this.selectedNoteData?.folder_uuid })
}
.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)
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -481,7 +521,7 @@ export struct NoteContentOverViewComp {
.id(this.isUpdate + '')
.fontSize(12)
.padding({ top: 4, bottom: 4 })
.fontColor($r("app.color.modified_time_font_color"))
.fontColor($r('app.color.modified_time_font_color'))
Row() {
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData?.folder_uuid)) ==
folderTextMap.sys_def_myFavorites_uuid ? folderTextMap.sys_def_unClassified_uuid :
@@ -498,7 +538,7 @@ export struct NoteContentOverViewComp {
.padding({ left: 8, right: 8, top: 4, bottom: 4 })
.margin({ left: 8 })
.borderRadius(16)
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray'), this.selectedNoteData?.folder_uuid, SysDefFolderUuid.AllNotes, false))
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray')!, this.selectedNoteData?.folder_uuid, SysDefFolderUuid.AllNotes, false))
.bindMenu(this.MenuBuilder)
}.alignItems(VerticalAlign.Top).height(40).width(StyleConstants.PERCENTAGE_100)
}
@@ -522,16 +562,16 @@ export struct ToolBarComp {
this.selectedNoteData.is_deleted = Delete.Yes
this.selectedNoteData.deleted_time = new Date().getTime()
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid)
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicates_note, null!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
routePage()
} else {
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData?.uuid)
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid)
RdbStoreUtil.delete(predicates_note, null!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.delete(predicatesNote, null);
routePage()
}
AppStorage.SetOrCreate('isUpdate', true)
@@ -560,14 +600,14 @@ export struct ToolBarComp {
.responseRegion({ width: 54, height: 54 })
.onClick(() => {
try {
this.controllerShow.runJavaScript("getHtmlContent()")
this.controllerShow.runJavaScript('getHtmlContent()');
// 清除定时器
if (time_id != undefined) {
LogUtil.info(TAG, "back, clearInterval time_id : " + time_id)
LogUtil.info(TAG, 'back, clearInterval time_id : ' + time_id);
clearInterval(time_id)
}
setTimeout(() => {
LogUtil.info(TAG, "wait save cotext")
LogUtil.info(TAG, 'wait save cotext');
router.back()
}, 50)
NoteUtil.refreshAll()
@@ -582,13 +622,14 @@ export struct ToolBarComp {
.height(24).width(24)
.onClick(() => {
try {
this.selectedNoteData.is_favorite = (this.selectedNoteData?.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes)
this.selectedNoteData.is_favorite = (this.selectedNoteData?.is_favorite == Favorite.Yes ?
Favorite.No : Favorite.Yes)
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid)
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicates_note, null)
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
if (this.selectedFolderData?.uuid === SysDefFolderUuid.MyFavorites) {
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, SysDefFolderUuid.MyFavorites)!;
if (!this.selectedNoteData) {
routePage()
}
@@ -598,7 +639,7 @@ export struct ToolBarComp {
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "ToolBarComp, set continue note success")
LogUtil.info(TAG, 'ToolBarComp, set continue note success');
}
NoteUtil.refreshAll()
} catch (error) {
@@ -619,7 +660,7 @@ export struct ToolBarComp {
try {
// 退出键盘
inputMethod.getController().stopInputSession();
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.undo()")
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.undo()');
} catch (error) {
LogUtil.info(TAG, 'undo error')
}
@@ -635,7 +676,7 @@ export struct ToolBarComp {
try {
// 退出键盘
inputMethod.getController().stopInputSession();
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.redo()")
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.redo()');
} catch (error) {
LogUtil.info(TAG, 'todo error')
}
@@ -650,9 +691,9 @@ export struct ToolBarComp {
.onClick(() => {
try {
// 保存笔记信息到数据库
this.controllerShow.runJavaScript("getHtmlContent()")
this.controllerShow.runJavaScript('getHtmlContent()');
this.editModel = false
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.getBlur()")
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.getBlur()');
} catch (error) {
LogUtil.info(TAG, 'tick_thin error')
}
@@ -696,16 +737,16 @@ export struct DeleteNoteComp {
this.selectedNoteData.is_deleted = Delete.Yes
this.selectedNoteData.deleted_time = new Date().getTime()
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid)
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicates_note, null!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
routePage()
} else {
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData?.uuid)
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid)
RdbStoreUtil.delete(predicates_note, null!);
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.delete(predicatesNote, null);
NoteUtil.refreshAll()
routePage()
}
@@ -722,12 +763,12 @@ export struct DeleteNoteComp {
.onClick(() => {
this.noteDataDeleteDialogCtlBottom!.open();
})
Text($r("app.string.delete"))
Text($r('app.string.delete'))
.fontSize(10)
.fontColor($r('app.color.delete_font_color'))
.padding({ top: 5 })
}
.height("100%")
.height('100%')
.width(180)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
@@ -743,30 +784,30 @@ export struct DeleteNoteComp {
this.selectedNoteData.deleted_time = 0
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
let resource: resourceManager.Resource = {
bundleName: "com.ohos.note",
moduleName: "default",
bundleName: 'com.ohos.note',
moduleName: 'default',
id: $r('app.string.restore').id
};
context.resourceManager.getStringValue(resource, (error: BusinessError, value: string) => {
if (error != null) {
LogUtil.error(TAG, "error is " + error);
LogUtil.error(TAG, 'error is' + error);
} else {
prompt.showToast({ message: value, duration: 2000 });
}
});
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid)
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicates_note, null)
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
NoteUtil.refreshAll()
})
Text($r("app.string.recover"))
Text($r('app.string.recover'))
.fontSize(10)
.fontColor($r('app.color.recover_font_color'))
.padding({ top: 5 })
}
.height("100%")
.height('100%')
.width(180)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
@@ -796,7 +837,8 @@ struct NoteDataMoveItemCompMenu {
.width(24)
.height(24)
.flexShrink(0)
.fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.folderItem.uuid == this.uuid))
.fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid,
this.folderItem.uuid == this.uuid))
}
.width(24)
@@ -816,7 +858,7 @@ struct NoteDataMoveItemCompMenu {
if (this.folderItem.uuid != SysDefFolderUuid.UnClassified) {
Divider()
.color($r("app.color.divider_color_e4e4e4"))
.color($r('app.color.divider_color_e4e4e4'))
.strokeWidth(1)
}
@@ -227,7 +227,7 @@ struct NoteOverViewComp {
@State isShow: boolean = false
notesNumberChange() {
let noteNumbers = FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
let noteNumbers = FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid);
if (noteNumbers == 0) {
this.isShow = false
} else {
@@ -372,7 +372,7 @@ export struct NoteItemComp {
.id(this.isUpdate + '')
.height(16)
.width(4)
.fillColor(NoteUtil.getVerticalBarBgColor(AppStorage.Get('AllFolderArray'), this.noteItem.folder_uuid))
.fillColor(NoteUtil.getVerticalBarBgColor(AppStorage.Get('AllFolderArray')!, this.noteItem.folder_uuid))
Text(this.noteItem.title)
.fontSize(16)
.maxLines(1)
@@ -486,7 +486,7 @@ export struct NoteItemComp {
routePage()
}
this.selectedAll = this.CheckedNoteArray.length ==
NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).length
NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid).length;
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
})
.gesture(
@@ -524,7 +524,7 @@ export struct NoteItemListComp {
updateList() {
if (this.isUpdate) {
this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid);
}
this.isUpdate = false
this.doSearch()
@@ -533,7 +533,7 @@ export struct NoteItemListComp {
aboutToAppear() {
LogUtil.info(TAG, "inputKeyWord:" + this.inputKeyword)
this.inputKeyword = ''
this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid);
}
doSearch() {
@@ -541,7 +541,7 @@ export struct NoteItemListComp {
this.setNoteListLazy()
return;
};
SearchModel.search(NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid), this.inputKeyword)
SearchModel.search(NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid), this.inputKeyword)
.then((result: NoteData[]) => {
LogUtil.info(TAG, "result size " + result.length.toString())
this.searchResultList = result
@@ -549,7 +549,7 @@ export struct NoteItemListComp {
if (this.searchResultList.length != 0) {
this.selectedNoteData = this.searchResultList[0]
} else {
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
}
if (this.portraitModel == false) {
this.controllerShow.runJavaScript(
@@ -693,7 +693,7 @@ export struct OperateNoteComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
// save continue data
@@ -726,7 +726,7 @@ export struct OperateNoteComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
} else {
this.CheckedNoteArray.forEach((noteItem: NoteData) => {
@@ -734,13 +734,13 @@ export struct OperateNoteComp {
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.delete(predicates_note, null!);
RdbStoreUtil.delete(predicates_note, null);
})
}
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
this.longpress = false
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
if (this.portraitModel == false) {
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')")
}
@@ -766,7 +766,7 @@ export struct OperateNoteComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
this.longpress = false
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
@@ -818,7 +818,7 @@ export struct OperateNoteComp {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
this.longpress = false
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
@@ -832,8 +832,8 @@ export struct OperateNoteComp {
.onClick(() => {
LogUtil.info(TAG, "select all click")
if (this.CheckedNoteArray.length <
NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).length) {
NoteUtil.setAllNotesChecked(this.CheckedNoteArray, NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid))
NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid).length) {
NoteUtil.setAllNotesChecked(this.CheckedNoteArray, NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid));
} else {
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
}
@@ -875,7 +875,7 @@ export struct AddNoteComp {
}
this.AllNoteArray.push(noteData)
RdbStoreUtil.insert(TableName.NoteTable, noteData.toNoteObject(), null)
RdbStoreUtil.insert(TableName.NoteTable, noteData.toNoteObject(), null);
LogUtil.info(TAG, 'insert new note is:' + noteData.uuid)
this.selectedNoteData = noteData
@@ -1019,7 +1019,7 @@ export struct OperateNoteCompForPortrait {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
// save continue data
@@ -1049,7 +1049,7 @@ export struct OperateNoteCompForPortrait {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null!);
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
} else {
this.CheckedNoteArray.forEach((noteItem: NoteData) => {
@@ -1057,13 +1057,13 @@ export struct OperateNoteCompForPortrait {
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.delete(predicates_note, null!);
RdbStoreUtil.delete(predicates_note, null);
})
}
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
this.longpress = false
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)!;
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -1086,7 +1086,7 @@ export struct OperateNoteCompForPortrait {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
this.longpress = false
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
@@ -1182,7 +1182,7 @@ export struct OperateNoteCompForPortrait {
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null)
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
})
this.longpress = false
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
@@ -1210,10 +1210,10 @@ export struct OperateNoteCompForPortrait {
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
.id(this.isUpdate + '')
.onClick(() => {
if (this.CheckedNoteArray.length <
NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
.length) {
NoteUtil.setAllNotesChecked(this.CheckedNoteArray, NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid))
if (this.CheckedNoteArray.length < NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!,
this.selectedFolderData.uuid).length) {
NoteUtil.setAllNotesChecked(this.CheckedNoteArray, NoteUtil.getNoteDataArray(
AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid));
} else {
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
}
+15 -2
View File
@@ -18,7 +18,7 @@
"module": {
"name": "default",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"srcEntry": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_MainAbility",
"mainElement": "MainAbility",
"deviceTypes": [
@@ -71,6 +71,16 @@
],
"when":"inuse"
}
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
"reason": "$string:keep_background_running_permission",
"usedScene": {
"abilities": [
"MainAbility"
],
"when":"always"
}
}
],
"deliveryWithInstall": true,
@@ -86,7 +96,7 @@
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"srcEntry": "./ets/MainAbility/MainAbility.ts",
"description": "$string:entry_MainAbility",
"icon": "$media:note",
"label": "$string:entry_MainAbility",
@@ -102,6 +112,9 @@
]
}
],
"backgroundModes": [
"dataTransfer"
],
"startWindowBackground": "$color:color_1",
"startWindowIcon": "$media:note"
}
@@ -19,6 +19,10 @@
{
"name": "write_image_video_permission",
"value": "Used to modify image or video files in the user's public directory"
},
{
"name": "keep_background_running_permission",
"value": "Allow Service Ability to run continuously in the background"
}
]
}
@@ -15,6 +15,10 @@
{
"name": "write_image_video_permission",
"value": "用于备忘录修改用户公共目录的图片或视频文件"
},
{
"name": "keep_background_running_permission",
"value": "允许Service Ability在后台持续运行"
}
]
}