mirror of
https://github.com/openharmony/applications_notes.git
synced 2026-07-20 05:34:03 -04:00
!321 merge master into master
修改废弃接口 Created-by: sephyrothcloud Commit-by: haoxiaohui Merged-by: openharmony_ci Description: ### 一、内容说明(相关的Issue) https://gitcode.com/openharmony/applications_notes/issues/339 ### 二、建议测试周期和提测地址  ### 三、变更内容 1. 增加维测日志,复现稳定性问题 2. 修改部分废弃接口 ### 四、压测结果 除audio_server外无crash、freeze报错,此错误非应用引起  See merge request: openharmony/applications_notes!321
This commit is contained in:
@@ -66,6 +66,10 @@ RICH_EDITOR.setUnderline = function () {
|
||||
document.execCommand('underline', false, null);
|
||||
};
|
||||
|
||||
RICH_EDITOR.setInputEnabled = function (enabled) {
|
||||
console.info(enabled);
|
||||
}
|
||||
|
||||
RICH_EDITOR.getListStyle = function () {
|
||||
let selection;
|
||||
let type;
|
||||
|
||||
@@ -18,22 +18,20 @@ import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil
|
||||
import FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData';
|
||||
import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData';
|
||||
import {
|
||||
TableName,
|
||||
Delete,
|
||||
Favorite,
|
||||
FolderType,
|
||||
NoteTableColumn,
|
||||
SysDefFolderUuid,
|
||||
Favorite,
|
||||
Delete,
|
||||
FolderType
|
||||
TableName
|
||||
} from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData';
|
||||
import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants';
|
||||
import { EditContentDialog, DeleteDialog, EditTitleDialog } from './CusDialogComp';
|
||||
import { DeleteDialog, EditContentDialog } from './CusDialogComp';
|
||||
import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil';
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
import util from '@ohos.util';
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil';
|
||||
import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationUtils';
|
||||
import mediaquery from '@ohos.mediaquery';
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import { folderTextMap } from '@ohos/utils/src/main/ets/default/model/NoteBaseData';
|
||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||
@@ -45,7 +43,7 @@ import resourceManager from '@ohos.resourceManager';
|
||||
const TAG = 'NoteContentComp';
|
||||
|
||||
let timeId: number = 0;
|
||||
let noteContext = AppStorage.Get<common.UIAbilityContext>('noteContext')!;
|
||||
let noteContext = AppStorage.get<common.UIAbilityContext>('noteContext')!;
|
||||
|
||||
// Note content component
|
||||
let inSetValue: string = AppStorage.Link('inSetValue');
|
||||
@@ -72,9 +70,7 @@ export struct NoteContentComp {
|
||||
@Consume('Search') search: boolean;
|
||||
@StorageLink('dpi') dpi: number = 240;
|
||||
controllerShow: webview.WebviewController = new webview.WebviewController();
|
||||
private editContentFlag = false;
|
||||
@State uri1: string = "";
|
||||
private context = getContext(this);
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0;
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false;
|
||||
@StorageLink('refreshCurrentNote') @Watch('isDataChange') refreshCurrentNote: boolean = false;
|
||||
@@ -85,6 +81,7 @@ export struct NoteContentComp {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LogUtil.info(TAG, `isDataChange runJavaScript setHtml ` + this.selectedNoteData.content_text);
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')");
|
||||
LogUtil.info(TAG, `runJavaScript setHtml success.`);
|
||||
} catch (error) {
|
||||
@@ -98,18 +95,21 @@ export struct NoteContentComp {
|
||||
if (scrollTop < 0) {
|
||||
return;
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight());
|
||||
AppStorage.setOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight());
|
||||
}
|
||||
|
||||
restoreScrollTop() {
|
||||
try {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
LogUtil.info(TAG, 'restoreScrollTop');
|
||||
if (!AppStorage.has('remoteScrollTopPercent')) {
|
||||
return;
|
||||
}
|
||||
let scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')!;
|
||||
if (scrollTopPercent < 0) {
|
||||
return;
|
||||
}
|
||||
LogUtil.info(TAG,
|
||||
'runJavaScript document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight() * scrollTopPercent);
|
||||
this.controllerShow.runJavaScript(
|
||||
'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight() * scrollTopPercent
|
||||
)
|
||||
@@ -120,14 +120,17 @@ export struct NoteContentComp {
|
||||
}
|
||||
|
||||
restoreFocus() {
|
||||
LogUtil.info(TAG, 'restoreFocus');
|
||||
if (!AppStorage.Has('isRemoteFocusOnSearch')) {
|
||||
return;
|
||||
}
|
||||
LogUtil.info(TAG, 'restoreFocus not return');
|
||||
let isRemoteFocusOnSearch = AppStorage.Get<boolean>('isRemoteFocusOnSearch');
|
||||
if (isRemoteFocusOnSearch) {
|
||||
LogUtil.info(TAG, 'restoreFocus isRemoteFocusOnSearch');
|
||||
focusControl.requestFocus('searchInput');
|
||||
}
|
||||
AppStorage.Delete('isRemoteFocusOnSearch');
|
||||
AppStorage.delete('isRemoteFocusOnSearch');
|
||||
}
|
||||
|
||||
noteContent: NoteContentType = {
|
||||
@@ -144,10 +147,10 @@ export struct NoteContentComp {
|
||||
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);
|
||||
LogUtil.info(TAG, 'update note success:' + JSON.stringify(this.selectedNoteData));
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject());
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'callbackhtml, set continue note success');
|
||||
return 'AceString';
|
||||
} catch (error) {
|
||||
@@ -174,13 +177,13 @@ export struct NoteContentComp {
|
||||
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);
|
||||
LogUtil.info(TAG, 'update note success:' + JSON.stringify(this.selectedNoteData));
|
||||
this.sectionStatus = this.lastSectionStatus;
|
||||
this.sectionStatus = mediaquery.matchMediaSync('(width < 2000)').matches ? 2 : 3;
|
||||
this.sectionStatus = this.getUIContext().getMediaQuery().matchMediaSync('(width < 2000)').matches ? 2 : 3;
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject());
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus);
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.setOrCreate<number>('ContinueSection', this.sectionStatus);
|
||||
LogUtil.info(TAG, 'callbackhtmlSave, set continue note and section success');
|
||||
return 'AceString';
|
||||
} catch (error) {
|
||||
@@ -201,7 +204,7 @@ export struct NoteContentComp {
|
||||
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);
|
||||
LogUtil.info(TAG, 'callbackScheduledSave, update note success:' + JSON.stringify(this.selectedNoteData));
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject());
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
@@ -213,6 +216,7 @@ export struct NoteContentComp {
|
||||
|
||||
callbackPasteImage: (html) => {
|
||||
try {
|
||||
LogUtil.info(TAG, 'paste image callback start');
|
||||
if (html) {
|
||||
LogUtil.info(TAG, 'paste info' + html);
|
||||
let realHtml = "";
|
||||
@@ -228,7 +232,7 @@ export struct NoteContentComp {
|
||||
}
|
||||
let filePath = "";
|
||||
if (base64regex.test(imgData)) {
|
||||
let base64 = new util.Base64();
|
||||
let base64 = new util.Base64Helper();
|
||||
let decodeArr = base64.decodeSync(imgData);
|
||||
filePath = OperationUtils.saveImageData(decodeArr, imgType);
|
||||
} else {
|
||||
@@ -292,6 +296,7 @@ export struct NoteContentComp {
|
||||
.enabled(this.sectionStatus !== 1 ? false : true)
|
||||
.onPageEnd((e) => {
|
||||
try {
|
||||
LogUtil.info(TAG, `dpi:${this.dpi}}`);
|
||||
if (this.dpi <= 240) {
|
||||
this.controllerShow.runJavaScript('changeSizeToRk()');
|
||||
} else if (this.dpi <= 320 && this.dpi > 240) {
|
||||
@@ -305,9 +310,11 @@ export struct NoteContentComp {
|
||||
LogUtil.info(TAG, 'finish loadurl');
|
||||
if (this.selectedNoteData) {
|
||||
let self = this;
|
||||
LogUtil.info(TAG, 'runJavaScript setHtml :' + this.selectedNoteData.content_text);
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
() => {
|
||||
LogUtil.info(TAG, 'runJavaScript setHtml success');
|
||||
// wait for the image in the note to load
|
||||
setTimeout(() => {
|
||||
self.restoreScrollTop();
|
||||
@@ -343,10 +350,11 @@ export struct NoteContentComp {
|
||||
try {
|
||||
this.issave = 0;
|
||||
LogUtil.info(TAG, 'editModel : ' + this.editModel + ', sectionStatus : ' + this.sectionStatus);
|
||||
let isContinue = AppStorage.Get<boolean>('IsContinue');
|
||||
let isContinue = AppStorage.get<boolean>('IsContinue');
|
||||
LogUtil.info(TAG, 'isContinue : ' + isContinue);
|
||||
// 点击第三屏进入全屏编辑模式
|
||||
if (this.sectionStatus != 1 || isContinue) {
|
||||
LogUtil.info(TAG, 'Third Screen Full Screen Edit Mode');
|
||||
this.asideWidth = 0;
|
||||
this.lastSectionStatus = this.sectionStatus;
|
||||
this.sectionStatus = 1;
|
||||
@@ -356,7 +364,9 @@ export struct NoteContentComp {
|
||||
clearInterval(timeId);
|
||||
}
|
||||
timeId = setInterval(() => {
|
||||
LogUtil.info(TAG, 'runJavaScript(scheduledSaveContent) start');
|
||||
this.controllerShow.runJavaScript('scheduledSaveContent()');
|
||||
LogUtil.info(TAG, 'runJavaScript(scheduledSaveContent) end');
|
||||
}, 3000)
|
||||
LogUtil.info(TAG, 'setInterval timeId : ' + timeId);
|
||||
// save continue data
|
||||
@@ -373,7 +383,7 @@ export struct NoteContentComp {
|
||||
}
|
||||
.id(this.isUpdate + '')
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.visibility(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0 ?
|
||||
.visibility(FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid) == 0 ?
|
||||
Visibility.Hidden : Visibility.Visible)
|
||||
|
||||
Column() {
|
||||
@@ -396,6 +406,14 @@ export struct NoteContentComp {
|
||||
clearInterval(timeId)
|
||||
LogUtil.info(TAG, 'aboutToDisappear')
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
LogUtil.info(TAG, 'onPageShow')
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
LogUtil.info(TAG, 'onPageHide')
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
@@ -425,35 +443,40 @@ export struct NoteContentOverViewComp {
|
||||
getArray() {
|
||||
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, 'NoteContentOverViewComp this AllFolderArray[1] undefined');
|
||||
return;
|
||||
}
|
||||
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
LogUtil.info(TAG, '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, 'NoteContentOverViewComp this AllFolderArray[1] undefined');
|
||||
return;
|
||||
}
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp ' + JSON.stringify(this.AllFolderArray));
|
||||
this.NoteDataMoveArray.push(this.AllFolderArray[1]);
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp aboutToDisappear');
|
||||
this.editTitleDialogCtl = null;
|
||||
}
|
||||
|
||||
confirm(newTitle: string) {
|
||||
try {
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp confirm');
|
||||
this.selectedNoteData.title = newTitle;
|
||||
this.selectedNoteData.modified_time = new Date().getTime();
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid);
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicatesNote, null);
|
||||
NoteUtil.refreshAll();
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp confirm end');
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, 'confirm error: ' + JSON.stringify(error));
|
||||
LogUtil.error(TAG, 'NoteContentOverViewComp confirm error: ' + JSON.stringify(error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,26 +492,32 @@ export struct NoteContentOverViewComp {
|
||||
}
|
||||
.onClick(() => {
|
||||
try {
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp MenuBuilder onClick');
|
||||
this.selectedNoteData.folder_uuid = item.uuid;
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid);
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicatesNote, null);
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp MenuBuilder onClick, selectionStatus:' + this.sectionStatus);
|
||||
if (this.sectionStatus != 1) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
|
||||
LogUtil.info(TAG,
|
||||
'NoteContentOverViewComp MenuBuilder onClick, runJavaScript(RICH_EDITOR.setHtml)' + this.selectedNoteData.content_text);
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
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);
|
||||
LogUtil.info(TAG,
|
||||
'NoteContentOverViewComp MenuBuilder onClick, selectedFolderData :' + JSON.stringify(this.selectedFolderData));
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject());
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp, MenuBuilder, set continue note success');
|
||||
NoteUtil.refreshAll();
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, 'ListItem click error: ' + JSON.stringify(error));
|
||||
LogUtil.error(TAG, 'NoteContentOverViewComp ListItem click error: ' + JSON.stringify(error));
|
||||
}
|
||||
})
|
||||
}, (noteItem: NoteData) => noteItem.uuid)
|
||||
@@ -519,8 +548,8 @@ export struct NoteContentOverViewComp {
|
||||
clearInterval(timeId);
|
||||
this.editTitleDialogCtl!.open();
|
||||
// save continue data
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus);
|
||||
LogUtil.info(TAG, 'NoteContentComp, set continue section success');
|
||||
AppStorage.setOrCreate<number>('ContinueSection', this.sectionStatus);
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp, set continue section success');
|
||||
})
|
||||
}.height(40)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
@@ -533,10 +562,10 @@ export struct NoteContentOverViewComp {
|
||||
.fontColor($r('app.color.modified_time_font_color'))
|
||||
.margin({ left: 0 })
|
||||
Row() {
|
||||
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'),
|
||||
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.get('AllFolderArray'),
|
||||
this.selectedNoteData.folder_uuid)) ==
|
||||
folderTextMap.sys_def_myFavorites_uuid ? folderTextMap.sys_def_unClassified_uuid :
|
||||
FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'),
|
||||
FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.get('AllFolderArray'),
|
||||
this.selectedNoteData.folder_uuid)))
|
||||
.id(this.isUpdate + '')
|
||||
.fontSize(12)
|
||||
@@ -556,7 +585,7 @@ export struct NoteContentOverViewComp {
|
||||
})
|
||||
.margin({ left: 8 })
|
||||
.borderRadius(16)
|
||||
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray')!, this.selectedNoteData.folder_uuid,
|
||||
.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)
|
||||
@@ -581,7 +610,6 @@ export struct ToolBarComp {
|
||||
@Consume('EditModel') editModel: boolean;
|
||||
@Consume('Issave') issave: number;
|
||||
controllerShow: webview.WebviewController = new webview.WebviewController();
|
||||
private context = getContext(this);
|
||||
noteDataDeleteDialogCtl: CustomDialogController | null = new CustomDialogController({
|
||||
builder: DeleteDialog({
|
||||
onConfirm: () => {
|
||||
@@ -595,12 +623,16 @@ export struct ToolBarComp {
|
||||
@Consume('AsideWidth') asideWidth: number;
|
||||
|
||||
aboutToDisappear() {
|
||||
LogUtil.info(TAG, 'ToolBarComp, aboutToDisappear');
|
||||
this.noteDataDeleteDialogCtl = null;
|
||||
this.editContentDialogCtl = null;
|
||||
}
|
||||
|
||||
onDeleteConfirm() {
|
||||
try {
|
||||
LogUtil.info(TAG, 'ToolBarComp, onDeleteConfirm selectedFolderData: ' + JSON.stringify(this.selectedFolderData));
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp, onDeleteConfirm RecentDeletes: ' + JSON.stringify(SysDefFolderUuid.RecentDeletes));
|
||||
if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
|
||||
this.selectedNoteData.is_deleted = Delete.Yes;
|
||||
this.selectedNoteData.deleted_time = new Date().getTime();
|
||||
@@ -615,21 +647,23 @@ export struct ToolBarComp {
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid);
|
||||
RdbStoreUtil.delete(predicatesNote, null);
|
||||
}
|
||||
LogUtil.info(TAG, 'ToolBarComp, onDeleteConfirm, delete note success');
|
||||
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 {
|
||||
LogUtil.info(TAG, 'ToolBarComp, onDeleteConfirm, set html ' + this.selectedNoteData.content_text);
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text! + "')");
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, `setHtml error. code:${JSON.stringify(error.code)},message:${error.message}`);
|
||||
LogUtil.info(TAG, `ToolBarComp setHtml error. code:${JSON.stringify(error.code)},message:${error.message}`);
|
||||
}
|
||||
this.chooseNote = false;
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject());
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp, set continue note success');
|
||||
AppStorage.SetOrCreate('isUpdate', true);
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'ToolBarComp, set continue note success');
|
||||
AppStorage.setOrCreate('isUpdate', true);
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, 'onDeleteConfirm error: ' + JSON.stringify(error));
|
||||
LogUtil.error(TAG, 'ToolBarComp onDeleteConfirm error: ' + JSON.stringify(error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,24 +695,27 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
try {
|
||||
if (this.sectionStatus != 1) {
|
||||
LogUtil.info(TAG, 'ToolBarComp zoom, sectionStatus : ' + this.sectionStatus);
|
||||
this.lastSectionStatus = this.sectionStatus;
|
||||
this.sectionStatus = 1;
|
||||
this.asideWidth = 0;
|
||||
this.controllerShow.runJavaScript('RICH_EDITOR.setInputEnabled(true)');
|
||||
LogUtil.info(TAG, 'ToolBarComp zoom, runJavaScript : RICH_EDITOR.setInputEnabled(true)');
|
||||
} else {
|
||||
LogUtil.info(TAG, 'ToolBarComp zoom, sectionStatus : ' + this.sectionStatus);
|
||||
if (this.lastSectionStatus != undefined) {
|
||||
this.asideWidth = 200;
|
||||
// 切换为小屏预览模式
|
||||
this.controllerShow.runJavaScript('RICH_EDITOR.setInputEnabled(false)');
|
||||
this.sectionStatus = this.lastSectionStatus;
|
||||
// 退出全屏时存库
|
||||
LogUtil.info(TAG, 'close note' + this.selectedNoteData.uuid);
|
||||
LogUtil.info(TAG, 'ToolBarComp close note' + this.selectedNoteData.uuid);
|
||||
this.controllerShow.runJavaScript('saveHtmlContent()');
|
||||
//退出键盘
|
||||
inputMethod.getController().stopInputSession();
|
||||
// 清除定时器
|
||||
if (timeId != undefined) {
|
||||
LogUtil.info(TAG, 'zoom, clearInterval timeId : ' + timeId);
|
||||
LogUtil.info(TAG, 'ToolBarComp zoom, clearInterval timeId : ' + timeId);
|
||||
clearInterval(timeId);
|
||||
}
|
||||
} else {
|
||||
@@ -687,12 +724,13 @@ export struct ToolBarComp {
|
||||
}
|
||||
this.editModel = !this.editModel;
|
||||
// save continue data
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus);
|
||||
AppStorage.setOrCreate<number>('ContinueSection', this.sectionStatus);
|
||||
LogUtil.info(TAG, 'ToolBarComp, set continue section success');
|
||||
NoteUtil.refreshAll();
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG,
|
||||
`Image ${this.sectionStatus == 1 ? 'narrow' : 'zoom'} click failed.code:${JSON.stringify(error.code)},
|
||||
`ToolBarComp Image ${this.sectionStatus == 1 ? 'narrow' :
|
||||
'zoom'} click failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
})
|
||||
@@ -713,9 +751,10 @@ export struct ToolBarComp {
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
try {
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, recover note');
|
||||
this.selectedNoteData.is_deleted = Delete.No;
|
||||
this.selectedNoteData.deleted_time = 0;
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
let resource: resourceManager.Resource = {
|
||||
bundleName: 'com.ohos.note',
|
||||
moduleName: 'default',
|
||||
@@ -725,18 +764,21 @@ export struct ToolBarComp {
|
||||
if (error != null) {
|
||||
LogUtil.error(TAG, 'error is ' + error);
|
||||
} else {
|
||||
promptAction.showToast({ message: value, duration: 2000 });
|
||||
this.getUIContext().getPromptAction().showToast({ message: value, duration: 2000 });
|
||||
}
|
||||
});
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0);
|
||||
this.chooseNote = false;
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, recover note , update note to db');
|
||||
// update note to db
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid);
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicatesNote, null);
|
||||
|
||||
this.selectedNoteData =
|
||||
NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
|
||||
NoteUtil.getFirstNoteData(AppStorage.get('AllNoteArray')!, this.selectedFolderData.uuid)!;
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp, onClick, recover note, setHtml ' + this.selectedNoteData!.content_text);
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData!.content_text + "')"
|
||||
)
|
||||
@@ -747,7 +789,7 @@ export struct ToolBarComp {
|
||||
NoteUtil.refreshAll();
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG,
|
||||
`recover failed.code:${JSON.stringify(error.code)}, message:${JSON.stringify(error.message)}`);
|
||||
`ToolBarComp recover failed.code:${JSON.stringify(error.code)}, message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
})
|
||||
}.width(72)
|
||||
@@ -760,11 +802,13 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
try {
|
||||
// 清单
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp, onClick, circle_tick1, runJavaScript javascript:RICH_EDITOR.setTodo()');
|
||||
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.setTodo()');
|
||||
// 退出键盘
|
||||
inputMethod.getController().stopInputSession();
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, `Image circle_tick1 click failed.code:${JSON.stringify(error.code)},
|
||||
LogUtil.error(TAG, `ToolBarComp Image circle_tick1 click failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
})
|
||||
@@ -779,6 +823,7 @@ export struct ToolBarComp {
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
// 退出键盘
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, styles, exit keyboard');
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.editContentDialogCtl!.open();
|
||||
})
|
||||
@@ -792,32 +837,34 @@ export struct ToolBarComp {
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(async () => {
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, picture_white');
|
||||
let permissionList: Permissions[] = [
|
||||
'ohos.permission.READ_MEDIA',
|
||||
'ohos.permission.WRITE_MEDIA',
|
||||
];
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
let AtManager = abilityAccessCtrl.createAtManager();
|
||||
await AtManager.requestPermissionsFromUser(context, permissionList).then((data) => {
|
||||
LogUtil.info(TAG, 'data permissions : ' + data.permissions);
|
||||
LogUtil.info(TAG, 'data result: ' + data.authResults);
|
||||
LogUtil.info(TAG, 'ToolBarComp data permissions : ' + data.permissions);
|
||||
LogUtil.info(TAG, 'ToolBarComp data result: ' + data.authResults);
|
||||
let sum = 0;
|
||||
for (let i = 0; i < data.authResults.length; i++) {
|
||||
sum += data.authResults[i];
|
||||
}
|
||||
LogUtil.info(TAG, 'request permissions sum: ' + sum);
|
||||
LogUtil.info(TAG, 'ToolBarComp request permissions sum: ' + sum);
|
||||
}).catch((err: BusinessError) => {
|
||||
LogUtil.warn(TAG, 'failed to requestPermissionsFromUser : ' + err.code);
|
||||
LogUtil.warn(TAG, 'ToolBarComp failed to requestPermissionsFromUser : ' + err.code);
|
||||
})
|
||||
// 退出键盘
|
||||
inputMethod.getController().stopInputSession();
|
||||
LogUtil.info(TAG, 'startAbility start');
|
||||
LogUtil.info(TAG, 'ToolBarComp startAbility start');
|
||||
await noteContext.startAbilityForResult({
|
||||
parameters: { uri: 'singleselect' },
|
||||
bundleName: 'com.ohos.photos',
|
||||
abilityName: 'com.ohos.photos.MainAbility',
|
||||
})
|
||||
.then((v: common.AbilityResult) => {
|
||||
LogUtil.info(TAG, 'ToolBarComp startAbility success');
|
||||
try {
|
||||
let want = v['want'];
|
||||
if (want != null && want != undefined) {
|
||||
@@ -828,22 +875,26 @@ export struct ToolBarComp {
|
||||
imageUri = uri as string;
|
||||
}
|
||||
// 拷贝
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, picture_white, copy image ' + imageUri);
|
||||
if (imageUri != null && imageUri != "") {
|
||||
OperationUtils.copy(imageUri).then((uriPath) => {
|
||||
let path = 'file://' + uriPath;
|
||||
LogUtil.info(TAG, 'image uri is:' + path);
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp, onClick, picture_white, runJavaScript javascript:RICH_EDITOR.insertImage()');
|
||||
this.controllerShow.runJavaScript(
|
||||
"javascript:RICH_EDITOR.insertImage('" + path + "')"
|
||||
);
|
||||
this.issave = 1;
|
||||
// 保存笔记信息到数据库
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, picture_white, runJavaScript getHtmlContent()');
|
||||
this.controllerShow.runJavaScript('getHtmlContent()');
|
||||
})
|
||||
}
|
||||
}
|
||||
NoteUtil.refreshAll();
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, `startAbilityForResult failed.code:${JSON.stringify(error.code)},
|
||||
LogUtil.error(TAG, `ToolBarComp startAbilityForResult failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
});
|
||||
@@ -860,10 +911,11 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
try {
|
||||
// 退出键盘
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, undo, exit keyboard');
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript('RICH_EDITOR.undo()');
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, `Image undo click failed.code:${JSON.stringify(error.code)},
|
||||
LogUtil.error(TAG, `ToolBarComp Image undo click failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
})
|
||||
@@ -879,10 +931,11 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
try {
|
||||
// 退出键盘
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, todo, exit keyboard');
|
||||
inputMethod.getController().stopInputSession();
|
||||
this.controllerShow.runJavaScript('RICH_EDITOR.redo()');
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, `Image todo click failed.code:${JSON.stringify(error.code)},
|
||||
LogUtil.error(TAG, `ToolBarComp Image todo click failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
})
|
||||
@@ -900,14 +953,16 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
try {
|
||||
// 保存笔记信息到数据库
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, tick_thin, runJavaScript getHtmlContent()');
|
||||
this.controllerShow.runJavaScript('getHtmlContent()');
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, tick_thin, runJavaScript getBlur()');
|
||||
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.getBlur()');
|
||||
if (this.selectedNoteData.title == '标题' && this.selectedNoteData.content_text == "") {
|
||||
LogUtil.info(TAG, 'note is empty,save note failed');
|
||||
}
|
||||
this.issave = 1;
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, `Image tick_thin click failed.code:${JSON.stringify(error.code)},
|
||||
LogUtil.error(TAG, `ToolBarComp Image tick_thin click failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
})
|
||||
@@ -924,6 +979,7 @@ export struct ToolBarComp {
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
try {
|
||||
LogUtil.info(TAG, 'ToolBarComp, onClick, favorite, favorite note');
|
||||
this.selectedNoteData.is_favorite =
|
||||
(this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes);
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0);
|
||||
@@ -931,26 +987,32 @@ export struct ToolBarComp {
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid);
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicatesNote, null);
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp, onClick, favorite, selectedFolderData ' + JSON.stringify(this.selectedFolderData));
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp, onClick, favorite, MyFavorites ' + JSON.stringify(SysDefFolderUuid.MyFavorites));
|
||||
if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) {
|
||||
this.selectedNoteData =
|
||||
NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, SysDefFolderUuid.MyFavorites)!;
|
||||
try {
|
||||
LogUtil.info(TAG, `ToolBarComp, favorite, MyFavorites, setHtml` +
|
||||
JSON.stringify(this.selectedNoteData.content_text));
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
);
|
||||
LogUtil.info(TAG, `setHtml success`);
|
||||
LogUtil.info(TAG, `ToolBarComp setHtml success`);
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, `setHtml failed.code:${JSON.stringify(error.code)},
|
||||
LogUtil.error(TAG, `ToolBarComp setHtml failed.code:${JSON.stringify(error.code)},
|
||||
message:${JSON.stringify(error.message)}`);
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject());
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'ToolBarComp, set continue note success');
|
||||
}
|
||||
NoteUtil.refreshAll();
|
||||
} catch (error) {
|
||||
LogUtil.error(TAG, 'favorite error: ' + JSON.stringify(error));
|
||||
LogUtil.error(TAG, 'ToolBarComp favorite error: ' + JSON.stringify(error));
|
||||
}
|
||||
})
|
||||
Image($r('app.media.delete'))
|
||||
|
||||
@@ -36,7 +36,7 @@ import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationU
|
||||
import router from '@system.router'
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import { folderTextMap } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
import abilityAccessCtrl,{ Permissions } from '@ohos.abilityAccessCtrl';
|
||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||
import webview from '@ohos.web.webview';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
@@ -46,7 +46,7 @@ import { wantAgent, WantAgent } from '@kit.AbilityKit';
|
||||
import { backgroundTaskManager } from '@kit.BackgroundTasksKit';
|
||||
|
||||
let time_id: number = 0;
|
||||
let noteContext = AppStorage.Get<common.UIAbilityContext>('noteContext')!;
|
||||
let noteContext = AppStorage.get<common.UIAbilityContext>('noteContext')!;
|
||||
|
||||
const TAG = 'NoteContentCompPortrait';
|
||||
|
||||
@@ -73,8 +73,8 @@ async function routePage() {
|
||||
// Note content component
|
||||
@Component
|
||||
export struct NoteContentCompPortrait {
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote')!;
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('NewFolder')!;
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.get('NewNote')!;
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.get('NewFolder')!;
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Provide('EditModel') editModel: boolean = false
|
||||
@StorageLink('dpi') dpi: number = 240
|
||||
@@ -83,9 +83,11 @@ export struct NoteContentCompPortrait {
|
||||
private isClickBack: boolean = false
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
|
||||
editContentDialogCtl: CustomDialogController | null = new CustomDialogController({
|
||||
builder: EditContentDialogPortrait({ confirm: (newTitle: string) => {
|
||||
this.confirm(newTitle);
|
||||
} }),
|
||||
builder: EditContentDialogPortrait({
|
||||
confirm: (newTitle: string) => {
|
||||
this.confirm(newTitle);
|
||||
}
|
||||
}),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: true,
|
||||
customStyle: true,
|
||||
@@ -94,6 +96,7 @@ export struct NoteContentCompPortrait {
|
||||
@StorageLink('topWidth') topWidth: number = 0; // 窗口规避区域宽
|
||||
|
||||
confirm(excuteJs: string) {
|
||||
LogUtil.info(TAG, 'confirm excuteJs:' + excuteJs)
|
||||
this.controllerShow.runJavaScript(excuteJs)
|
||||
}
|
||||
|
||||
@@ -101,15 +104,15 @@ export struct NoteContentCompPortrait {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight())
|
||||
AppStorage.setOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight())
|
||||
}
|
||||
|
||||
restoreScrollTop() {
|
||||
try {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
if (!AppStorage.has('remoteScrollTopPercent')) {
|
||||
return
|
||||
}
|
||||
let scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')!;
|
||||
let scrollTopPercent = AppStorage.get<number>('remoteScrollTopPercent')!;
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
@@ -123,85 +126,86 @@ export struct NoteContentCompPortrait {
|
||||
}
|
||||
|
||||
restoreFocus() {
|
||||
if (!AppStorage.Has('isRemoteFocusOnSearch')) {
|
||||
if (!AppStorage.has('isRemoteFocusOnSearch')) {
|
||||
return
|
||||
}
|
||||
let isRemoteFocusOnSearch = AppStorage.Get<boolean>('isRemoteFocusOnSearch')
|
||||
let isRemoteFocusOnSearch = AppStorage.get<boolean>('isRemoteFocusOnSearch')
|
||||
if (isRemoteFocusOnSearch) {
|
||||
focusControl.requestFocus('searchInput')
|
||||
}
|
||||
AppStorage.Delete('isRemoteFocusOnSearch')
|
||||
AppStorage.delete('isRemoteFocusOnSearch')
|
||||
}
|
||||
|
||||
noteContent: NoteContentType = {
|
||||
callbackhtml: (html) => {
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData?.uuid)
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData?.uuid);
|
||||
this.selectedNoteData.content_text = NoteUtil.contrastInitType(this.selectedNoteData.content_text);
|
||||
if (this.selectedNoteData.content_text === html ) {
|
||||
if (this.selectedNoteData.content_text === html) {
|
||||
return;
|
||||
};
|
||||
this.selectedNoteData.content_text = html
|
||||
this.selectedNoteData.modified_time = new Date().getTime()
|
||||
}
|
||||
;
|
||||
this.selectedNoteData.content_text = html;
|
||||
this.selectedNoteData.modified_time = new Date().getTime();
|
||||
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)
|
||||
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)
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject());
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'callbackhtml, set continue note success');
|
||||
},
|
||||
callbackImagePath: (imgName) => {
|
||||
// updata note image
|
||||
LogUtil.info(TAG, 'note imgName is:' + imgName)
|
||||
this.selectedNoteData.content_img = imgName
|
||||
LogUtil.info(TAG, 'note imgName is:' + imgName);
|
||||
this.selectedNoteData.content_img = imgName;
|
||||
},
|
||||
|
||||
callbackScheduledSave: (html) => {
|
||||
LogUtil.info(TAG, 'callbackScheduledSave')
|
||||
LogUtil.info(TAG, 'callbackScheduledSave');
|
||||
if (this.selectedNoteData?.content_text == html) {
|
||||
LogUtil.info(TAG, 'callbackScheduledSave the same value return')
|
||||
LogUtil.info(TAG, 'callbackScheduledSave the same value return');
|
||||
return;
|
||||
}
|
||||
this.selectedNoteData.content_text = html
|
||||
this.selectedNoteData.modified_time = new Date().getTime()
|
||||
this.selectedNoteData.content_text = html;
|
||||
this.selectedNoteData.modified_time = new Date().getTime();
|
||||
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)
|
||||
LogUtil.info(TAG, 'callbackScheduledSave, update note success:' + this.selectedNoteData?.uuid);
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, 'callbackScheduledSave, set continue note success')
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject());
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
LogUtil.info(TAG, 'callbackScheduledSave, set continue note success');
|
||||
},
|
||||
callbackPasteImage: (html) => {
|
||||
if (html) {
|
||||
LogUtil.info(TAG, 'paste info' + html)
|
||||
LogUtil.info(TAG, 'paste info' + html);
|
||||
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);
|
||||
let imgData = html.split(',')[1];
|
||||
let imgType = 'png'
|
||||
let imgType = 'png';
|
||||
if (html.indexOf('jpeg') > 0) {
|
||||
imgType = 'jpg'
|
||||
imgType = 'jpg';
|
||||
} else if (html.indexOf('gif') > 0) {
|
||||
imgType = 'gif'
|
||||
imgType = 'gif';
|
||||
}
|
||||
let filePath = '';
|
||||
if (base64regex.test(imgData)) {
|
||||
let base64 = new util.Base64()
|
||||
let decodeArr = base64.decodeSync(imgData)
|
||||
filePath = OperationUtils.saveImageData(decodeArr, imgType)
|
||||
let base64 = new util.Base64Helper();
|
||||
let decodeArr = base64.decodeSync(imgData);
|
||||
filePath = OperationUtils.saveImageData(decodeArr, imgType);
|
||||
} else {
|
||||
filePath = OperationUtils.saveImage(imgData, imgType)
|
||||
filePath = OperationUtils.saveImage(imgData, imgType);
|
||||
}
|
||||
realHtml = 'file://' + filePath;
|
||||
}
|
||||
LogUtil.info(TAG, 'paste info11' + realHtml)
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')")
|
||||
LogUtil.info(TAG, 'paste info11' + realHtml);
|
||||
this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')");
|
||||
} else {
|
||||
LogUtil.info(TAG, 'paste info22224')
|
||||
LogUtil.info(TAG, 'paste info22224');
|
||||
}
|
||||
},
|
||||
callbackGetSize: (fontSize) => {
|
||||
@@ -219,13 +223,16 @@ export struct NoteContentCompPortrait {
|
||||
},
|
||||
addToDo: () => {
|
||||
// 清单
|
||||
LogUtil.info(TAG, 'addToDo');
|
||||
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.setTodo()');
|
||||
},
|
||||
chooseStyle: () => {
|
||||
LogUtil.info(TAG, 'chooseStyle');
|
||||
this.editContentDialogCtl!.open();
|
||||
},
|
||||
openAlbum: async () => {
|
||||
let context: common.UIAbilityContext = AppStorage.Get('context')!;
|
||||
LogUtil.info(TAG, 'openAlbum');
|
||||
let context: common.UIAbilityContext = AppStorage.get('context')!;
|
||||
// 申请长时任务
|
||||
let wantAgentInfo: wantAgent.WantAgentInfo = {
|
||||
wants: [
|
||||
@@ -274,6 +281,7 @@ export struct NoteContentCompPortrait {
|
||||
bundleName: 'com.ohos.photos',
|
||||
abilityName: 'com.ohos.photos.MainAbility',
|
||||
}).then((v: common.AbilityResult) => {
|
||||
LogUtil.info(TAG, 'startAbility success')
|
||||
let want = v['want'];
|
||||
if (want != null && want != undefined) {
|
||||
let param = want['parameters'];
|
||||
@@ -308,19 +316,23 @@ export struct NoteContentCompPortrait {
|
||||
});
|
||||
},
|
||||
getBreakPoint: () => {
|
||||
return AppStorage.Get('breakPoint');
|
||||
return AppStorage.get('breakPoint');
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
|
||||
alignItems: ItemAlign.Start, alignContent: FlexAlign.SpaceAround }) {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
wrap: FlexWrap.NoWrap,
|
||||
alignItems: ItemAlign.Start,
|
||||
alignContent: FlexAlign.SpaceAround
|
||||
}) {
|
||||
Column() {
|
||||
// 窗口顶部规避区域
|
||||
Row()
|
||||
.width(px2vp(this.topWidth))
|
||||
.height(px2vp(this.topHeight))
|
||||
.width(this.getUIContext().px2vp(this.topWidth))
|
||||
.height(this.getUIContext().px2vp(this.topHeight))
|
||||
ToolBarComp({ controllerShow: this.controllerShow })
|
||||
NoteContentOverViewComp()
|
||||
.enabled(this.selectedNoteData && this.selectedNoteData?.is_deleted == Delete.Yes ? false : true)
|
||||
@@ -347,14 +359,16 @@ export struct NoteContentCompPortrait {
|
||||
this.controllerShow.runJavaScript('changeSizeToTablet()');
|
||||
}
|
||||
LogUtil.info(TAG, 'finish loadurl');
|
||||
let self = this
|
||||
let self = this;
|
||||
LogUtil.info(TAG, 'onPageEnd setHtml start');
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')",
|
||||
() => {
|
||||
LogUtil.info(TAG, 'setHtml finish');
|
||||
// wait for the image in the note to load
|
||||
setTimeout(() => {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
self.restoreScrollTop();
|
||||
self.restoreFocus();
|
||||
}, 100)
|
||||
}
|
||||
)
|
||||
@@ -381,6 +395,7 @@ export struct NoteContentCompPortrait {
|
||||
time_id = setInterval(() => {
|
||||
try {
|
||||
if (!this.isClickBack) {
|
||||
LogUtil.info(TAG, 'setInterval runJavaScript scheduledSaveContent')
|
||||
this.controllerShow.runJavaScript('scheduledSaveContent()');
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -399,6 +414,7 @@ export struct NoteContentCompPortrait {
|
||||
}
|
||||
.flexShrink(1)
|
||||
.padding({ left: 24, right: 24 })
|
||||
|
||||
DeleteNoteComp()
|
||||
}
|
||||
.expandSafeArea([SafeAreaType.KEYBOARD, SafeAreaType.SYSTEM])
|
||||
@@ -409,7 +425,7 @@ export struct NoteContentCompPortrait {
|
||||
aboutToAppear(): void {
|
||||
this.isClickBack = false
|
||||
LogUtil.info(TAG, 'aboutToAppear');
|
||||
window.getLastWindow(getContext(this)).then(currentWindow => {
|
||||
window.getLastWindow(this.getUIContext().getHostContext()).then(currentWindow => {
|
||||
currentWindow.setWindowLayoutFullScreen(true);
|
||||
})
|
||||
}
|
||||
@@ -431,9 +447,11 @@ export struct NoteContentOverViewComp {
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
NoteDataMoveArray: FolderData[] = [];
|
||||
editTitleDialogCtl: CustomDialogController | null = new CustomDialogController({
|
||||
builder: EditTitleDialog({ confirm: (newTitle: string) => {
|
||||
this.confirm(newTitle);
|
||||
} }),
|
||||
builder: EditTitleDialog({
|
||||
confirm: (newTitle: string) => {
|
||||
this.confirm(newTitle);
|
||||
}
|
||||
}),
|
||||
alignment: DialogAlignment.Center,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
@@ -460,7 +478,7 @@ export struct NoteContentOverViewComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp, MenuBuilder, set continue note success')
|
||||
NoteUtil.refreshAll()
|
||||
}
|
||||
@@ -483,8 +501,8 @@ export struct NoteContentOverViewComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, 'MenuBuilder, set continue note success')
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, 'NoteContentOverViewComp MenuBuilder, set continue note success')
|
||||
NoteUtil.refreshAll()
|
||||
})
|
||||
}, (noteItem: NoteData) => noteItem?.uuid)
|
||||
@@ -503,8 +521,12 @@ export struct NoteContentOverViewComp {
|
||||
|
||||
build() {
|
||||
if (this.selectedNoteData) {
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween,
|
||||
alignItems: ItemAlign.Center
|
||||
}) {
|
||||
Row() {
|
||||
Text(this.selectedNoteData?.title)
|
||||
.id(this.isUpdate + '')
|
||||
@@ -523,9 +545,11 @@ export struct NoteContentOverViewComp {
|
||||
.padding({ top: 4, bottom: 4 })
|
||||
.fontColor($r('app.color.modified_time_font_color'))
|
||||
Row() {
|
||||
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData?.folder_uuid)) ==
|
||||
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'),
|
||||
this.selectedNoteData?.folder_uuid)) ==
|
||||
folderTextMap.sys_def_myFavorites_uuid ? folderTextMap.sys_def_unClassified_uuid :
|
||||
FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData?.folder_uuid)))
|
||||
FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'),
|
||||
this.selectedNoteData?.folder_uuid)))
|
||||
.id(this.isUpdate + '')
|
||||
.fontColor($r('app.color.folder_color_99182431'))
|
||||
.fontSize(12)
|
||||
@@ -535,10 +559,16 @@ export struct NoteContentOverViewComp {
|
||||
.margin({ left: 4 })
|
||||
}
|
||||
.id(this.isUpdate + '')
|
||||
.padding({ left: 8, right: 8, top: 4, bottom: 4 })
|
||||
.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)
|
||||
}
|
||||
@@ -558,6 +588,8 @@ export struct ToolBarComp {
|
||||
controllerShow: webview.WebviewController = new webview.WebviewController();
|
||||
|
||||
onDeleteConfirm() {
|
||||
LogUtil.info(TAG,
|
||||
'ToolBarComp onDeleteConfirm ' + (this.selectedFolderData.uuid === SysDefFolderUuid.RecentDeletes));
|
||||
if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
|
||||
this.selectedNoteData.is_deleted = Delete.Yes
|
||||
this.selectedNoteData.deleted_time = new Date().getTime()
|
||||
@@ -574,13 +606,15 @@ export struct ToolBarComp {
|
||||
RdbStoreUtil.delete(predicatesNote, null);
|
||||
routePage()
|
||||
}
|
||||
AppStorage.SetOrCreate('isUpdate', true)
|
||||
AppStorage.setOrCreate('isUpdate', true)
|
||||
}
|
||||
|
||||
noteDataDeleteDialogCtl: CustomDialogController | null = new CustomDialogController({
|
||||
builder: DeleteDialog({ onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true }),
|
||||
builder: DeleteDialog({
|
||||
onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true
|
||||
}),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
@@ -591,8 +625,12 @@ export struct ToolBarComp {
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween,
|
||||
alignItems: ItemAlign.Center
|
||||
}) {
|
||||
|
||||
Image($r('app.media.back'))
|
||||
.height(24)
|
||||
@@ -600,6 +638,7 @@ export struct ToolBarComp {
|
||||
.responseRegion({ width: 54, height: 54 })
|
||||
.onClick(() => {
|
||||
try {
|
||||
LogUtil.info(TAG, 'back, runJavaScript getHtmlContent');
|
||||
this.controllerShow.runJavaScript('getHtmlContent()');
|
||||
// 清除定时器
|
||||
if (time_id != undefined) {
|
||||
@@ -608,7 +647,7 @@ export struct ToolBarComp {
|
||||
}
|
||||
setTimeout(() => {
|
||||
LogUtil.info(TAG, 'wait save cotext');
|
||||
router.back()
|
||||
this.getUIContext().getRouter().back()
|
||||
}, 50)
|
||||
NoteUtil.refreshAll()
|
||||
} catch (error) {
|
||||
@@ -618,32 +657,36 @@ export struct ToolBarComp {
|
||||
|
||||
if (this.editModel == false) {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image(this.selectedNoteData?.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel'))
|
||||
Image(this.selectedNoteData?.is_favorite == Favorite.Yes ? $r('app.media.favorite') :
|
||||
$r('app.media.favorite_cancel'))
|
||||
.height(24).width(24)
|
||||
.onClick(() => {
|
||||
try {
|
||||
LogUtil.info(TAG, 'ToolBarComp, favorite')
|
||||
this.selectedNoteData.is_favorite = (this.selectedNoteData?.is_favorite == Favorite.Yes ?
|
||||
Favorite.No : Favorite.Yes)
|
||||
Favorite.No : Favorite.Yes)
|
||||
// update note to db
|
||||
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()
|
||||
}
|
||||
LogUtil.info(TAG, 'ToolBarComp, set favorite ,setHtml ' + this.selectedNoteData.content_text);
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
)
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, 'ToolBarComp, set continue note success');
|
||||
}
|
||||
NoteUtil.refreshAll()
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'favorite error')
|
||||
LogUtil.info(TAG, 'ToolBarComp favorite error')
|
||||
}
|
||||
})
|
||||
Image($r('app.media.delete')).height(24).width(24)
|
||||
@@ -660,9 +703,10 @@ export struct ToolBarComp {
|
||||
try {
|
||||
// 退出键盘
|
||||
inputMethod.getController().stopInputSession();
|
||||
LogUtil.info(TAG, 'ToolBarComp, undo runJavaScript javascript:RICH_EDITOR.undo()');
|
||||
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.undo()');
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'undo error')
|
||||
LogUtil.info(TAG, 'ToolBarComp undo error')
|
||||
}
|
||||
})
|
||||
}.width(42)
|
||||
@@ -676,9 +720,10 @@ export struct ToolBarComp {
|
||||
try {
|
||||
// 退出键盘
|
||||
inputMethod.getController().stopInputSession();
|
||||
LogUtil.info(TAG, 'ToolBarComp, todo runJavaScript javascript:RICH_EDITOR.redo()');
|
||||
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.redo()');
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'todo error')
|
||||
LogUtil.info(TAG, 'ToolBarComp todo error');
|
||||
}
|
||||
})
|
||||
}.width(42)
|
||||
@@ -691,11 +736,13 @@ export struct ToolBarComp {
|
||||
.onClick(() => {
|
||||
try {
|
||||
// 保存笔记信息到数据库
|
||||
LogUtil.info(TAG, 'ToolBarComp, tick_thin runJavaScript getHtmlContent()');
|
||||
this.controllerShow.runJavaScript('getHtmlContent()');
|
||||
this.editModel = false
|
||||
this.editModel = false;
|
||||
LogUtil.info(TAG, 'ToolBarComp, tick_thin runJavaScript getBlur()');
|
||||
this.controllerShow.runJavaScript('javascript:RICH_EDITOR.getBlur()');
|
||||
} catch (error) {
|
||||
LogUtil.info(TAG, 'tick_thin error')
|
||||
LogUtil.info(TAG, 'ToolBarComp tick_thin error');
|
||||
}
|
||||
})
|
||||
}.width(42)
|
||||
@@ -714,43 +761,48 @@ export struct ToolBarComp {
|
||||
|
||||
@Component
|
||||
export struct DeleteNoteComp {
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [];
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray');
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData;
|
||||
@Consume('RefreshFlag') refreshFlag: number;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
noteDataDeleteDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
|
||||
builder: DeleteDialog({ onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true }),
|
||||
builder: DeleteDialog({
|
||||
onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true
|
||||
}),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
aboutToDisappear() {
|
||||
this.noteDataDeleteDialogCtlBottom = null
|
||||
LogUtil.info(TAG, 'DeleteNoteComp aboutToDisappear');
|
||||
this.noteDataDeleteDialogCtlBottom = null;
|
||||
}
|
||||
|
||||
onDeleteConfirm() {
|
||||
LogUtil.info(TAG, 'DeleteNoteComp onDeleteConfirm selectedFolderData' + JSON.stringify(this.selectedFolderData));
|
||||
LogUtil.info(TAG, 'DeleteNoteComp onDeleteConfirm RecentDeletes' + JSON.stringify(SysDefFolderUuid.RecentDeletes));
|
||||
if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
|
||||
this.selectedNoteData.is_deleted = Delete.Yes
|
||||
this.selectedNoteData.deleted_time = new Date().getTime()
|
||||
this.selectedNoteData.is_deleted = Delete.Yes;
|
||||
this.selectedNoteData.deleted_time = new Date().getTime();
|
||||
// update note to db
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
|
||||
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
|
||||
routePage()
|
||||
routePage();
|
||||
} else {
|
||||
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData?.uuid)
|
||||
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData?.uuid);
|
||||
// delete note from db
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
|
||||
RdbStoreUtil.delete(predicatesNote, null);
|
||||
NoteUtil.refreshAll()
|
||||
routePage()
|
||||
NoteUtil.refreshAll();
|
||||
routePage();
|
||||
}
|
||||
AppStorage.SetOrCreate('isUpdate', false)
|
||||
AppStorage.setOrCreate('isUpdate', false)
|
||||
}
|
||||
|
||||
build() {
|
||||
@@ -759,7 +811,12 @@ export struct DeleteNoteComp {
|
||||
Image($r('app.media.delete'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
this.noteDataDeleteDialogCtlBottom!.open();
|
||||
})
|
||||
@@ -778,11 +835,17 @@ export struct DeleteNoteComp {
|
||||
Image($r('app.media.recover'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.is_deleted = Delete.No
|
||||
this.selectedNoteData.deleted_time = 0
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
LogUtil.info(TAG, 'DeleteNoteComp recover');
|
||||
this.selectedNoteData.is_deleted = Delete.No;
|
||||
this.selectedNoteData.deleted_time = 0;
|
||||
let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
let resource: resourceManager.Resource = {
|
||||
bundleName: 'com.ohos.note',
|
||||
moduleName: 'default',
|
||||
@@ -792,14 +855,16 @@ export struct DeleteNoteComp {
|
||||
if (error != null) {
|
||||
LogUtil.error(TAG, 'error is' + error);
|
||||
} else {
|
||||
promptAction.showToast({ message: value, duration: 2000 });
|
||||
this.getUIContext().getPromptAction().showToast({ message: value, duration: 2000 });
|
||||
}
|
||||
});
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0);
|
||||
LogUtil.info(TAG, 'DeleteNoteComp recover start');
|
||||
// update note to db
|
||||
let predicatesNote = RdbStoreUtil.getRdbPredicates(TableName.NoteTable);
|
||||
predicatesNote.equalTo(NoteTableColumn.Uuid, this.selectedNoteData?.uuid);
|
||||
RdbStoreUtil.update(this.selectedNoteData?.toNoteObject(), predicatesNote, null);
|
||||
LogUtil.info(TAG, 'DeleteNoteComp recover update end');
|
||||
NoteUtil.refreshAll()
|
||||
})
|
||||
Text($r('app.string.recover'))
|
||||
@@ -825,7 +890,9 @@ struct NoteDataMoveItemCompMenu {
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
folderItem: FolderData = new FolderData(0, '', new Date().getTime() + '', '', FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime());
|
||||
folderItem: FolderData =
|
||||
new FolderData(0, '', new Date().getTime() + '', '', FolderType.CusDef, Delete.No, new Date().getTime(),
|
||||
new Date().getTime());
|
||||
uuid: string = '';
|
||||
|
||||
build() {
|
||||
@@ -847,7 +914,8 @@ struct NoteDataMoveItemCompMenu {
|
||||
Text(FolderUtil.getFolderText(this.folderItem))
|
||||
.id(this.isUpdate + '')
|
||||
.fontSize(16)
|
||||
.fontColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid == this.uuid ? this.folderItem.uuid : '', this.folderItem.uuid == this.uuid))
|
||||
.fontColor(FolderUtil.getFolderIconColor(this.AllFolderArray,
|
||||
this.folderItem.uuid == this.uuid ? this.folderItem.uuid : '', this.folderItem.uuid == this.uuid))
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
|
||||
@@ -68,20 +68,22 @@ abstract class BasicDataSource<T> implements IDataSource {
|
||||
public abstract totalCount(): number;
|
||||
|
||||
public getData(index: number): T | void {
|
||||
LogUtil.info(TAG, 'getDataindex: '+index);
|
||||
LogUtil.info(TAG, 'getDataindex: ' + index);
|
||||
};
|
||||
|
||||
registerDataChangeListener(listener: DataChangeListener): void {
|
||||
if (this.listeners.indexOf(listener) < 0) {
|
||||
this.listeners.push(listener);
|
||||
};
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
unregisterDataChangeListener(listener: DataChangeListener): void {
|
||||
const pos = this.listeners.indexOf(listener);
|
||||
if (pos >= 0) {
|
||||
this.listeners.splice(pos, 1);
|
||||
};
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
notifyDataReload(): void {
|
||||
@@ -113,7 +115,8 @@ abstract class BasicDataSource<T> implements IDataSource {
|
||||
listener.onDataMove(from, to);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
class noteListData extends BasicDataSource<NoteData> {
|
||||
private noteList: Array<NoteData> = [];
|
||||
@@ -163,7 +166,8 @@ class noteListData extends BasicDataSource<NoteData> {
|
||||
this.noteList = data;
|
||||
this.notifyDataReload();
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
// Note list component
|
||||
@Component
|
||||
@@ -192,26 +196,34 @@ export struct NoteListComp {
|
||||
OperateNoteCompForPortrait()
|
||||
}
|
||||
.flexShrink(0)
|
||||
.padding({ bottom: 90})
|
||||
.padding({ bottom: 90 })
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
AppStorage.SetOrCreate('isUpdate', false)
|
||||
AppStorage.setOrCreate('isUpdate', false)
|
||||
LogUtil.info(TAG, "aboutToAppear")
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
LogUtil.info(TAG, "aboutToDisappear")
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
LogUtil.info(TAG, "onPageShow");
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
LogUtil.info(TAG, "onPageHide");
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct NoteOverViewComp {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')!;
|
||||
@StorageLink('breakPoint') breakPoints: string = AppStorage.Get('breakPoint')!;
|
||||
@StorageLink('breakPoint') breakPoints: string = AppStorage.get('breakPoint')!;
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@@ -252,14 +264,14 @@ struct NoteOverViewComp {
|
||||
.visibility(this.breakPoints == 'lg' && this.sectionStatus == 3 ? Visibility.None : Visibility.Visible)
|
||||
.onClick(() => {
|
||||
if (this.breakPoints == 'sm' || this.breakPoints == 'md') {
|
||||
animateTo({ duration: 200 }, () => {
|
||||
this.getUIContext().animateTo({ duration: 200 }, () => {
|
||||
this.expandStatus = !this.expandStatus
|
||||
})
|
||||
} else {
|
||||
this.asideWidth = 200
|
||||
this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3)
|
||||
// save continue data
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
|
||||
AppStorage.setOrCreate<number>('ContinueSection', this.sectionStatus)
|
||||
LogUtil.info(TAG, "NoteOverViewComp, set continue section success")
|
||||
}
|
||||
})
|
||||
@@ -279,7 +291,7 @@ struct NoteOverViewComp {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Row() {
|
||||
Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString())
|
||||
Text(FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid).toString())
|
||||
.id(this.isUpdate + '')
|
||||
.maxLines(1)
|
||||
.fontSize(14)
|
||||
@@ -308,7 +320,8 @@ struct NoteOverViewComp {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
|
||||
})
|
||||
Text(this.CheckedNoteArray.length == 0 ? $r("app.string.none_selected") : $r("app.string.selected", this.CheckedNoteArray.length))
|
||||
Text(this.CheckedNoteArray.length == 0 ? $r("app.string.none_selected") :
|
||||
$r("app.string.selected", this.CheckedNoteArray.length))
|
||||
.fontSize(20)
|
||||
.fontColor($r("app.color.note_selected_font_color"))
|
||||
.margin({ left: 16 })
|
||||
@@ -335,7 +348,9 @@ struct NoteOverViewComp {
|
||||
|
||||
@Component
|
||||
export struct NoteItemComp {
|
||||
public noteItem: NoteData = new NoteData(0, '标题', new Date().getTime() + '', '', '', '', NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0);
|
||||
public noteItem: NoteData =
|
||||
new NoteData(0, '标题', new Date().getTime() + '', '', '', '', NoteType.SysDef, Top.No, Favorite.No, Delete.No,
|
||||
new Date().getTime(), new Date().getTime(), 0, 0);
|
||||
public spans: TextSpan[] = [];
|
||||
controllerShow: webview.WebviewController = new webview.WebviewController();
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@@ -372,7 +387,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)
|
||||
@@ -439,12 +454,13 @@ export struct NoteItemComp {
|
||||
.borderRadius(24)
|
||||
.linearGradient({
|
||||
direction: GradientDirection.Right,
|
||||
colors: this.selectedNoteData?.uuid == this.noteItem.uuid ? [[0xffcdae, 0.0], [0xFfece2, 1.0]] : [[0xffffff, 0.0], [0xffffff, 1.0]]
|
||||
colors: this.selectedNoteData?.uuid == this.noteItem.uuid ? [[0xffcdae, 0.0], [0xFfece2, 1.0]] :
|
||||
[[0xffffff, 0.0], [0xffffff, 1.0]]
|
||||
})
|
||||
.onClick(() => {
|
||||
if (this.search) {
|
||||
this.search = false
|
||||
AppStorage.SetOrCreate<boolean>('Search', this.search)
|
||||
AppStorage.setOrCreate<boolean>('Search', this.search)
|
||||
return
|
||||
}
|
||||
if (this.longpress) {
|
||||
@@ -463,11 +479,13 @@ export struct NoteItemComp {
|
||||
this.chooseNote = true
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "NoteItemComp, set continue note success")
|
||||
}
|
||||
if (this.portraitModel == false) {
|
||||
try {
|
||||
LogUtil.info(TAG,
|
||||
`portraitModel is false, runJavaScript setHtml ----------- ` + this.selectedNoteData?.content_text)
|
||||
this.controllerShow.runJavaScript(
|
||||
"RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')"
|
||||
)
|
||||
@@ -490,17 +508,17 @@ export struct NoteItemComp {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
})
|
||||
.gesture(
|
||||
GestureGroup(GestureMode.Exclusive,
|
||||
// 长按:对笔记列表进行操作
|
||||
LongPressGesture()
|
||||
.onAction(() => {
|
||||
if (this.longpress == false) {
|
||||
this.longpress = true
|
||||
NoteUtil.setNoteChecked(this.CheckedNoteArray, this.noteItem)
|
||||
this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)
|
||||
}
|
||||
})
|
||||
)
|
||||
GestureGroup(GestureMode.Exclusive,
|
||||
// 长按:对笔记列表进行操作
|
||||
LongPressGesture()
|
||||
.onAction(() => {
|
||||
if (this.longpress == false) {
|
||||
this.longpress = true
|
||||
NoteUtil.setNoteChecked(this.CheckedNoteArray, this.noteItem)
|
||||
this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
@@ -524,7 +542,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,15 +551,17 @@ 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() {
|
||||
if (this.inputKeyword.length == 0) {
|
||||
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 +569,8 @@ 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(
|
||||
@@ -579,7 +600,8 @@ export struct NoteItemListComp {
|
||||
.id(this.isUpdate + '')
|
||||
.width("100%")
|
||||
.padding({ left: 24, right: 24, bottom: 12 })
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ?
|
||||
Visibility.None : Visibility.Visible)
|
||||
|
||||
Stack() {
|
||||
Flex({ direction: FlexDirection.Column }) {
|
||||
@@ -591,7 +613,8 @@ export struct NoteItemListComp {
|
||||
.padding({ bottom: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 12 : 0 })
|
||||
.width('100%')
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes
|
||||
&& FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) > 0 ? Visibility.Visible : Visibility.None)
|
||||
&& FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid) > 0 ?
|
||||
Visibility.Visible : Visibility.None)
|
||||
|
||||
Column() {
|
||||
List({ initialIndex: 0 }) {
|
||||
@@ -609,7 +632,8 @@ export struct NoteItemListComp {
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.padding({ bottom: 120 })
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.Visible : Visibility.None)
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ?
|
||||
Visibility.Visible : Visibility.None)
|
||||
|
||||
LazyForEach(this.noteList, (noteItem: NoteData) => {
|
||||
ListItem() {
|
||||
@@ -622,15 +646,16 @@ export struct NoteItemListComp {
|
||||
}
|
||||
.padding({ left: 24, right: 24, bottom: 12 })
|
||||
}
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid) ==
|
||||
0) ? Visibility.None : Visibility.Visible)
|
||||
}, (noteItem: NoteData) => JSON.stringify(noteItem))
|
||||
}
|
||||
.id(this.isUpdate + '')
|
||||
.margin((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? {
|
||||
bottom: 0
|
||||
} : {
|
||||
bottom: 56
|
||||
})
|
||||
.margin((FolderUtil.getNoteCount(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? {
|
||||
bottom: 0
|
||||
} : {
|
||||
bottom: 56
|
||||
})
|
||||
.layoutWeight(1)
|
||||
.listDirection(Axis.Vertical)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
@@ -656,7 +681,7 @@ export struct NoteItemListComp {
|
||||
.onClick(() => {
|
||||
this.search = false
|
||||
inputMethod.getController().stopInputSession()
|
||||
AppStorage.SetOrCreate<boolean>('Search', this.search)
|
||||
AppStorage.setOrCreate<boolean>('Search', this.search)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -674,9 +699,11 @@ export struct OperateNoteComp {
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
controllerShow: webview.WebviewController = new webview.WebviewController();
|
||||
noteDataMoveDialogCtl: CustomDialogController | null = new CustomDialogController({
|
||||
builder: NoteDataMoveDialog({ onConfirm: (folderUuid: string) => {
|
||||
this.onMoveConfirm(folderUuid);
|
||||
} }),
|
||||
builder: NoteDataMoveDialog({
|
||||
onConfirm: (folderUuid: string) => {
|
||||
this.onMoveConfirm(folderUuid);
|
||||
}
|
||||
}),
|
||||
alignment: DialogAlignment.Center,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
@@ -698,7 +725,7 @@ export struct OperateNoteComp {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "onMoveConfirm, set continue note success")
|
||||
if (this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')")
|
||||
@@ -710,9 +737,11 @@ export struct OperateNoteComp {
|
||||
}
|
||||
|
||||
noteDataDeleteDialogCtl: CustomDialogController | null = new CustomDialogController({
|
||||
builder: DeleteDialog({ onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true }),
|
||||
builder: DeleteDialog({
|
||||
onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true
|
||||
}),
|
||||
alignment: DialogAlignment.Center,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
@@ -740,13 +769,13 @@ export struct OperateNoteComp {
|
||||
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 + "')")
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "OperateNoteComp, set continue note success")
|
||||
NoteUtil.refreshAll()
|
||||
}
|
||||
@@ -759,7 +788,8 @@ export struct OperateNoteComp {
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
.enabled(this.CheckedNoteArray.length == 0 ? false : true)
|
||||
.margin({ right: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 0 : 18 })
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None :
|
||||
Visibility.Visible)
|
||||
.onClick(() => {
|
||||
this.CheckedNoteArray.forEach((noteItem) => {
|
||||
noteItem.is_top = (noteItem.is_top == Top.Yes) ? Top.No : Top.Yes
|
||||
@@ -778,7 +808,8 @@ export struct OperateNoteComp {
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
.enabled(this.CheckedNoteArray.length == 0 ? false : true)
|
||||
.margin({ right: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 0 : 18 })
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None :
|
||||
Visibility.Visible)
|
||||
.onClick(() => {
|
||||
this.noteDataMoveDialogCtl!.open();
|
||||
})
|
||||
@@ -797,12 +828,13 @@ export struct OperateNoteComp {
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
.enabled(this.CheckedNoteArray.length == 0 ? false : true)
|
||||
.margin({ right: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 18 : 0 })
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.Visible : Visibility.None)
|
||||
.visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.Visible :
|
||||
Visibility.None)
|
||||
.onClick(() => {
|
||||
this.CheckedNoteArray.forEach((noteItem) => {
|
||||
noteItem.is_deleted = Delete.No
|
||||
noteItem.deleted_time = 0
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
let resource: resourceManager.Resource = {
|
||||
bundleName: "com.ohos.note",
|
||||
moduleName: "default",
|
||||
@@ -812,7 +844,7 @@ export struct OperateNoteComp {
|
||||
if (error != null) {
|
||||
LogUtil.error(TAG, "error is " + error);
|
||||
} else {
|
||||
promptAction.showToast({ message: value, duration: 2000 });
|
||||
this.getUIContext().getPromptAction().showToast({ message: value, duration: 2000 });
|
||||
}
|
||||
});
|
||||
// update note to db
|
||||
@@ -824,7 +856,8 @@ export struct OperateNoteComp {
|
||||
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
|
||||
NoteUtil.refreshAll()
|
||||
})
|
||||
Image(this.CheckedNoteArray.length == NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
Image(this.CheckedNoteArray.length ==
|
||||
NoteUtil.getNoteDataArray(AppStorage.get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
.length ? $r('app.media.check_all1') : $r('app.media.check_all'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
@@ -832,8 +865,9 @@ 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)
|
||||
}
|
||||
@@ -865,13 +899,23 @@ export struct AddNoteComp {
|
||||
.width(24)
|
||||
.height(24)
|
||||
.margin({ right: 12 })
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
let noteData: NoteData;
|
||||
if (this.selectedFolderData.uuid == SysDefFolderUuid.AllNotes || this.selectedFolderData.uuid == SysDefFolderUuid.MyFavorites) {
|
||||
noteData = new NoteData(0, "标题", new Date().getTime() + "", SysDefFolderUuid.UnClassified, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0)
|
||||
if (this.selectedFolderData.uuid == SysDefFolderUuid.AllNotes ||
|
||||
this.selectedFolderData.uuid == SysDefFolderUuid.MyFavorites) {
|
||||
noteData =
|
||||
new NoteData(0, "标题", new Date().getTime() + "", SysDefFolderUuid.UnClassified, "", "", NoteType.SysDef,
|
||||
Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0)
|
||||
} else {
|
||||
noteData = new NoteData(0, "标题", new Date().getTime() + "", this.selectedFolderData.uuid, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0)
|
||||
noteData =
|
||||
new NoteData(0, "标题", new Date().getTime() + "", this.selectedFolderData.uuid, "", "", NoteType.SysDef,
|
||||
Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0)
|
||||
}
|
||||
|
||||
this.AllNoteArray.push(noteData)
|
||||
@@ -879,7 +923,7 @@ export struct AddNoteComp {
|
||||
LogUtil.info(TAG, 'insert new note is:' + noteData.uuid)
|
||||
|
||||
this.selectedNoteData = noteData
|
||||
AppStorage.SetOrCreate<NoteData>('NewNote', noteData)
|
||||
AppStorage.setOrCreate<NoteData>('NewNote', noteData)
|
||||
if (this.portraitModel == false) {
|
||||
try {
|
||||
this.controllerShow.runJavaScript(
|
||||
@@ -896,13 +940,14 @@ export struct AddNoteComp {
|
||||
this.chooseNote = true
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<FolderData>('NewFolder', this.selectedFolderData)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<FolderData>('NewFolder', this.selectedFolderData)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "addNote, set continue note success")
|
||||
AppStorage.SetOrCreate('isUpdate', true)
|
||||
AppStorage.setOrCreate('isUpdate', true)
|
||||
routePage()
|
||||
})
|
||||
.visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
.visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None :
|
||||
Visibility.Visible)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,7 +964,12 @@ export struct SearchComp {
|
||||
Image($r('app.media.back'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.margin({ right: this.search ? 16 : 0 })
|
||||
.visibility(this.search ? Visibility.Visible : Visibility.None)
|
||||
.onClick(() => {
|
||||
@@ -927,7 +977,7 @@ export struct SearchComp {
|
||||
this.search = false
|
||||
// 退出键盘
|
||||
inputMethod.getController().stopInputSession();
|
||||
AppStorage.SetOrCreate<boolean>('Search', this.search)
|
||||
AppStorage.setOrCreate<boolean>('Search', this.search)
|
||||
})
|
||||
|
||||
Flex({ justifyContent: FlexAlign.Start }) {
|
||||
@@ -938,10 +988,16 @@ export struct SearchComp {
|
||||
.key('searchFocus')
|
||||
.defaultFocus(true)
|
||||
TextInput({ placeholder: $r('app.string.searchNote'), text: this.text })
|
||||
.backgroundColor(this.longpress ? $r("app.color.search_longpress_bgcolor_f7f8f9") : $r("app.color.color_ffffff"))
|
||||
.backgroundColor(this.longpress ? $r("app.color.search_longpress_bgcolor_f7f8f9") :
|
||||
$r("app.color.color_ffffff"))
|
||||
.caretColor($r("app.color.search_note_caret_color"))
|
||||
.enabled(this.longpress ? false : true)
|
||||
.padding({ left: 6, top: 0, bottom: 0, right: 0 })
|
||||
.padding({
|
||||
left: 6,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
right: 0
|
||||
})
|
||||
.onEditChange((isEditing: boolean) => {
|
||||
// this.search = isEditing
|
||||
})
|
||||
@@ -955,27 +1011,32 @@ export struct SearchComp {
|
||||
.onClick(() => {
|
||||
if (this.longpress) {
|
||||
this.search = false
|
||||
AppStorage.SetOrCreate<boolean>('Search', this.search)
|
||||
AppStorage.setOrCreate<boolean>('Search', this.search)
|
||||
} else {
|
||||
this.search = true
|
||||
AppStorage.SetOrCreate<boolean>('Search', this.search)
|
||||
AppStorage.setOrCreate<boolean>('Search', this.search)
|
||||
}
|
||||
})
|
||||
// whether the focus is on the search input before coutinue
|
||||
// whether the focus is on the search input before coutinue
|
||||
.onFocus(() => {
|
||||
this.isFocusOnSearch = true
|
||||
})
|
||||
.onBlur(() => {
|
||||
this.isFocusOnSearch = false
|
||||
})
|
||||
// key for request focus after coutinue
|
||||
// key for request focus after coutinue
|
||||
.key('searchInput')
|
||||
.restoreId(3)
|
||||
}
|
||||
.backgroundColor(this.longpress ? $r("app.color.search_longpress_bgcolor_f7f8f9") : $r("app.color.color_ffffff"))
|
||||
.height(40)
|
||||
.opacity(this.longpress ? 0.4 : 1)
|
||||
.padding({ left: 6, right: 12, top: 9, bottom: 9 })
|
||||
.padding({
|
||||
left: 6,
|
||||
right: 12,
|
||||
top: 9,
|
||||
bottom: 9
|
||||
})
|
||||
.borderRadius(20)
|
||||
.border({ width: 1.5, color: $r("app.color.divider_color_e4e4e4") })
|
||||
.margin({ right: this.search ? 40 : 0 })
|
||||
@@ -995,9 +1056,11 @@ export struct OperateNoteCompForPortrait {
|
||||
@State greyOpacity: boolean = false
|
||||
@StorageLink('isUpdate') isUpdate: boolean = false
|
||||
noteDataMoveDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
|
||||
builder: NoteDataMoveDialog({ onConfirm: (folderUuid: string) => {
|
||||
this.onMoveConfirm(folderUuid);
|
||||
} }),
|
||||
builder: NoteDataMoveDialog({
|
||||
onConfirm: (folderUuid: string) => {
|
||||
this.onMoveConfirm(folderUuid);
|
||||
}
|
||||
}),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
@@ -1029,7 +1092,7 @@ export struct OperateNoteCompForPortrait {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "onMoveConfirm, set continue note success")
|
||||
this.longpress = false
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
@@ -1038,9 +1101,11 @@ export struct OperateNoteCompForPortrait {
|
||||
}
|
||||
|
||||
noteDataDeleteDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
|
||||
builder: DeleteDialog({ onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true }),
|
||||
builder: DeleteDialog({
|
||||
onConfirm: () => {
|
||||
this.onDeleteConfirm();
|
||||
}, multiSelect: true
|
||||
}),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
@@ -1071,7 +1136,7 @@ export struct OperateNoteCompForPortrait {
|
||||
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)
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote)
|
||||
LogUtil.info(TAG, "OperateNoteCompForPortrait, set continue note success")
|
||||
NoteUtil.refreshAll()
|
||||
}
|
||||
@@ -1084,7 +1149,12 @@ export struct OperateNoteCompForPortrait {
|
||||
.opacity(this.greyOpacity ? 0.4 : 1)
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
this.CheckedNoteArray.forEach((noteItem) => {
|
||||
noteItem.is_top = (noteItem.is_top == Top.Yes) ? Top.No : Top.Yes
|
||||
@@ -1117,10 +1187,15 @@ export struct OperateNoteCompForPortrait {
|
||||
.opacity(this.greyOpacity ? 0.4 : 1)
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
this.noteDataDeleteDialogCtlBottom!.open();
|
||||
AppStorage.SetOrCreate('isUpdate', true)
|
||||
AppStorage.setOrCreate('isUpdate', true)
|
||||
})
|
||||
Text($r("app.string.delete"))
|
||||
.opacity(this.greyOpacity ? 0.4 : 1)
|
||||
@@ -1141,10 +1216,15 @@ export struct OperateNoteCompForPortrait {
|
||||
.opacity(this.greyOpacity ? 0.4 : 1)
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
this.noteDataMoveDialogCtlBottom!.open();
|
||||
AppStorage.SetOrCreate('isUpdate', true)
|
||||
AppStorage.setOrCreate('isUpdate', true)
|
||||
})
|
||||
Text($r("app.string.move"))
|
||||
.opacity(this.greyOpacity ? 0.4 : 1)
|
||||
@@ -1166,7 +1246,12 @@ export struct OperateNoteCompForPortrait {
|
||||
Image($r('app.media.recover'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.onClick(() => {
|
||||
this.CheckedNoteArray.forEach((noteItem) => {
|
||||
noteItem.is_deleted = Delete.No
|
||||
@@ -1181,7 +1266,7 @@ export struct OperateNoteCompForPortrait {
|
||||
if (error != null) {
|
||||
LogUtil.error(TAG, "error is " + error);
|
||||
} else {
|
||||
promptAction.showToast({ message: value, duration: 2000 });
|
||||
this.getUIContext().getPromptAction().showToast({ message: value, duration: 2000 });
|
||||
}
|
||||
});
|
||||
// update note to db
|
||||
@@ -1192,7 +1277,7 @@ export struct OperateNoteCompForPortrait {
|
||||
this.longpress = false
|
||||
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
AppStorage.SetOrCreate('isUpdate', true)
|
||||
AppStorage.setOrCreate('isUpdate', true)
|
||||
NoteUtil.refreshAll()
|
||||
})
|
||||
Text($r("app.string.recover"))
|
||||
@@ -1212,13 +1297,18 @@ export struct OperateNoteCompForPortrait {
|
||||
Image($r('app.media.check_all'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
|
||||
.responseRegion({
|
||||
x: -15.0,
|
||||
y: -15.0,
|
||||
width: 54,
|
||||
height: 54
|
||||
})
|
||||
.id(this.isUpdate + '')
|
||||
.onClick(() => {
|
||||
if (this.CheckedNoteArray.length < NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!,
|
||||
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));
|
||||
AppStorage.get('AllNoteArray')!, this.selectedFolderData.uuid));
|
||||
} else {
|
||||
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
|
||||
import fileio from '@ohos.fileio';
|
||||
import fileio from '@ohos.file.fs';
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil';
|
||||
import display from '@ohos.display';
|
||||
@@ -25,22 +25,22 @@ import util from '@ohos.util';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import relationalStore from '@ohos.data.relationalStore';
|
||||
|
||||
AppStorage.SetOrCreate<relationalStore.RdbStore>('rdbStore', undefined);
|
||||
AppStorage.setOrCreate<relationalStore.RdbStore>('rdbStore', undefined);
|
||||
|
||||
export default class MainAbility extends UIAbility {
|
||||
private Tag = 'MainAbility_Tablet';
|
||||
|
||||
onCreate(want, launchParam) {
|
||||
|
||||
AppStorage.SetOrCreate('context', this.context);
|
||||
AppStorage.setOrCreate('context', this.context);
|
||||
LogUtil.info(this.Tag, " onCreate, launchReason is " + launchParam.launchReason + ", deviceType" + deviceInfo.deviceType);
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
AppStorage.SetOrCreate<boolean>('Expand', false);
|
||||
AppStorage.SetOrCreate<boolean>('Choose', true);
|
||||
AppStorage.setOrCreate<boolean>('Expand', false);
|
||||
AppStorage.setOrCreate<boolean>('Choose', true);
|
||||
}
|
||||
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
|
||||
// 设置迁移标记
|
||||
AppStorage.SetOrCreate<boolean>('IsContinue', true);
|
||||
AppStorage.setOrCreate<boolean>('IsContinue', true);
|
||||
// 获取对端的迁移数据
|
||||
let Search: boolean = want.parameters["Search"];
|
||||
let continueNote: string = want.parameters["ContinueNote"];
|
||||
@@ -48,24 +48,24 @@ export default class MainAbility extends UIAbility {
|
||||
let scrollTopPercent: number = want.parameters["ScrollTopPercent"];
|
||||
let isFocusOnSearch: boolean = want.parameters["isFocusOnSearch"];
|
||||
LogUtil.info(this.Tag, " continueSection : " + continueSection);
|
||||
AppStorage.SetOrCreate<boolean>('Search', Search);
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', continueSection);
|
||||
AppStorage.setOrCreate<boolean>('Search', Search);
|
||||
AppStorage.setOrCreate<string>('ContinueNote', continueNote);
|
||||
AppStorage.setOrCreate<number>('ContinueSection', continueSection);
|
||||
// 使用新的key保存数据,防止迁移过来的数据在使用前被本地操作覆盖
|
||||
AppStorage.SetOrCreate<number>('remoteScrollTopPercent', scrollTopPercent);
|
||||
AppStorage.SetOrCreate<boolean>('isRemoteFocusOnSearch', isFocusOnSearch);
|
||||
AppStorage.setOrCreate<number>('remoteScrollTopPercent', scrollTopPercent);
|
||||
AppStorage.setOrCreate<boolean>('isRemoteFocusOnSearch', isFocusOnSearch);
|
||||
// 来自手机的迁移
|
||||
let continueChoose: boolean = want.parameters["ContinueChoose"];
|
||||
if (continueChoose) {
|
||||
LogUtil.info(this.Tag, " continue from phone");
|
||||
AppStorage.SetOrCreate<boolean>('ContinueFromPhone', true);
|
||||
AppStorage.setOrCreate<boolean>('ContinueFromPhone', true);
|
||||
} else {
|
||||
AppStorage.SetOrCreate<boolean>('ContinueFromTablet', true);
|
||||
AppStorage.setOrCreate<boolean>('ContinueFromTablet', true);
|
||||
LogUtil.error(this.Tag, " continue from tablet");
|
||||
}
|
||||
this.context.restoreWindowStage(null);
|
||||
}
|
||||
AppStorage.SetOrCreate<common.UIAbilityContext>('noteContext', this.context);
|
||||
AppStorage.setOrCreate<common.UIAbilityContext>('noteContext', this.context);
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ export default class MainAbility extends UIAbility {
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
windowStage.getMainWindow((err, data) => {
|
||||
LogUtil.info(this.Tag, " getMainWindow");
|
||||
let windowClass = data;
|
||||
try {
|
||||
windowClass.on('windowSizeChange', (data) => {
|
||||
@@ -133,27 +134,27 @@ export default class MainAbility extends UIAbility {
|
||||
onContinue(wantParam: { [key: string]: any }) {
|
||||
LogUtil.info(this.Tag, " onContinue");
|
||||
// 获取本端的迁移数据
|
||||
let Search = AppStorage.Get<boolean>('Search');
|
||||
let continueNote = AppStorage.Get<string>('ContinueNote');
|
||||
let Search = AppStorage.get<boolean>('Search');
|
||||
let continueNote = AppStorage.get<string>('ContinueNote');
|
||||
if (continueNote == undefined || continueNote == null) {
|
||||
LogUtil.info(this.Tag, " onContinue, continueNote is error, default [0]");
|
||||
continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject());
|
||||
continueNote = JSON.stringify(AppStorage.get('AllNoteArray')[0].toNoteObject());
|
||||
}
|
||||
|
||||
let continueSection = AppStorage.Get<number>('ContinueSection');
|
||||
let continueSection = AppStorage.get<number>('ContinueSection');
|
||||
if (continueSection == undefined || continueSection == null) {
|
||||
LogUtil.info(this.Tag, " onContinue, continueSection is error, default 3");
|
||||
continueSection = 3;
|
||||
}
|
||||
LogUtil.info(this.Tag, " onContinue, continueSection : " + continueSection);
|
||||
|
||||
let scrollTopPercent = AppStorage.Get<number>('ScrollTopPercent');
|
||||
let scrollTopPercent = AppStorage.get<number>('ScrollTopPercent');
|
||||
if (scrollTopPercent == undefined || scrollTopPercent == null) {
|
||||
LogUtil.info(this.Tag, " onContinue, scrollTopPercent is error, default 0");
|
||||
scrollTopPercent = 0;
|
||||
}
|
||||
|
||||
let isFocusOnSearch = AppStorage.Get<boolean>('isFocusOnSearch');
|
||||
let isFocusOnSearch = AppStorage.get<boolean>('isFocusOnSearch');
|
||||
if (isFocusOnSearch == undefined || isFocusOnSearch == null) {
|
||||
LogUtil.info(this.Tag, " onContinue, isFocusOnSearch is error, default true");
|
||||
isFocusOnSearch = true;
|
||||
@@ -185,6 +186,7 @@ export default class MainAbility extends UIAbility {
|
||||
}
|
||||
|
||||
getSrcFromHtml(html: string): any {
|
||||
LogUtil.info(this.Tag, " getSrcFromHtml "+ html);
|
||||
let srcArray = [];
|
||||
if (html == undefined || html == null || html == "") {
|
||||
return srcArray;
|
||||
@@ -231,15 +233,15 @@ export default class MainAbility extends UIAbility {
|
||||
let screenDpi = null;
|
||||
displayClass = display.getDefaultDisplaySync();
|
||||
screenDpi = displayClass.densityDPI;
|
||||
AppStorage.SetOrCreate('dpi', screenDpi);
|
||||
AppStorage.setOrCreate('dpi', screenDpi);
|
||||
let windowWidth = data / (screenDpi / 160);
|
||||
LogUtil.debug(this.Tag, " screenBreakPoints windowWidth: " + windowWidth);
|
||||
if (windowWidth >= 320 && windowWidth < 520 || windowWidth < 320) {
|
||||
AppStorage.SetOrCreate('breakPoint', 'sm');
|
||||
AppStorage.setOrCreate('breakPoint', 'sm');
|
||||
} else if (windowWidth >= 520 && windowWidth < 840) {
|
||||
AppStorage.SetOrCreate('breakPoint', 'md');
|
||||
AppStorage.setOrCreate('breakPoint', 'md');
|
||||
} else if (windowWidth >= 840) {
|
||||
AppStorage.SetOrCreate('breakPoint', 'lg');
|
||||
AppStorage.setOrCreate('breakPoint', 'lg');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fileio from '@ohos.fileio'
|
||||
import fileio from '@ohos.file.fs'
|
||||
import { NoteHomeComp } from './NoteHome'
|
||||
import { NoteHomePortraitComp } from './NoteHomePortrait'
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
|
||||
import inputMethod from '@ohos.inputMethod';
|
||||
import router from '@system.router';
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
import webview from '@ohos.web.webview';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
@@ -34,11 +33,12 @@ export struct MyNoteHomeComp {
|
||||
@Provide('PortraitModel') portraitModel: boolean = true
|
||||
@Provide('RefreshFlag') refreshFlag: number = 0
|
||||
private controllerShow: WebviewController = new webview.WebviewController()
|
||||
private context = getContext(this) as common.UIAbilityContext;
|
||||
private context = this.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
TAG = "MyNoteHomeComp_Tablet"
|
||||
@StorageLink('breakPoint') @Watch('onBreakPointChange') breakPoints: string = 'lg'
|
||||
|
||||
onBreakPointChange() {
|
||||
LogUtil.info(this.TAG, "onBreakPointChange, breakPoints = "+this.breakPoints)
|
||||
if (this.breakPoints == 'sm' || this.breakPoints == 'md') {
|
||||
this.portraitModel = true
|
||||
} else {
|
||||
@@ -50,8 +50,8 @@ export struct MyNoteHomeComp {
|
||||
Column() {
|
||||
// 窗口顶部规避区域
|
||||
Row()
|
||||
.width(px2vp(this.topWidth))
|
||||
.height(px2vp(this.topHeight))
|
||||
.width(this.getUIContext().px2vp(this.topWidth))
|
||||
.height(this.getUIContext().px2vp(this.topHeight))
|
||||
Row() {
|
||||
if (this.dBQueryFinished == 1) {
|
||||
if (this.breakPoints == 'sm') {
|
||||
@@ -69,7 +69,7 @@ export struct MyNoteHomeComp {
|
||||
|
||||
aboutToAppear(): void {
|
||||
LogUtil.info(this.TAG, "aboutToAppear")
|
||||
this.breakPoints = AppStorage.Get('breakPoint')!;
|
||||
this.breakPoints = AppStorage.get('breakPoint')!;
|
||||
if (this.breakPoints == 'sm' || this.breakPoints == 'md') {
|
||||
this.portraitModel = true
|
||||
} else {
|
||||
@@ -127,13 +127,13 @@ export struct MyNoteHomeComp {
|
||||
onPageShow(): void {
|
||||
LogUtil.info(this.TAG, "onPageShow")
|
||||
// continue from tablet
|
||||
let continueFromTablet = AppStorage.Get<boolean>('ContinueFromTablet')
|
||||
let continueFromTablet = AppStorage.get<boolean>('ContinueFromTablet')
|
||||
LogUtil.info(this.TAG, "onPageShow, continueFromTablet : " + continueFromTablet)
|
||||
let noteContentHomeExist = AppStorage.Get<boolean>('NoteContentHomeExist')
|
||||
let noteContentHomeExist = AppStorage.get<boolean>('NoteContentHomeExist')
|
||||
LogUtil.info(this.TAG, "onPageShow, noteContentHomeExist : " + noteContentHomeExist)
|
||||
if (continueFromTablet && !noteContentHomeExist) {
|
||||
router.push({ uri: 'pages/NoteContentHome' })
|
||||
AppStorage.SetOrCreate<boolean>('ContinueFromTablet', false)
|
||||
this.getUIContext().getRouter().pushUrl({ url: 'pages/NoteContentHome' })
|
||||
AppStorage.setOrCreate<boolean>('ContinueFromTablet', false)
|
||||
}
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
}
|
||||
|
||||
@@ -62,16 +62,24 @@ struct NoteContentHome {
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
let noteContext = AppStorage.Get<common.UIAbilityContext>('noteContext')!;
|
||||
this.breakPoints = AppStorage.Get('breakPoint')!;
|
||||
let noteContext = AppStorage.get<common.UIAbilityContext>('noteContext')!;
|
||||
this.breakPoints = AppStorage.get('breakPoint')!;
|
||||
LogUtil.info(this.TAG, "aboutToAppear")
|
||||
let isContinue = AppStorage.Get<boolean>('IsContinue')
|
||||
let isContinue = AppStorage.get<boolean>('IsContinue')
|
||||
LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue)
|
||||
if (isContinue) {
|
||||
RdbStoreUtil.initAppStorage(noteContext);
|
||||
}
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
AppStorage.SetOrCreate<boolean>('NoteContentHomeExist', true)
|
||||
AppStorage.setOrCreate<boolean>('NoteContentHomeExist', true)
|
||||
}
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
LogUtil.info(this.TAG, "onPageShow")
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
LogUtil.info(this.TAG, "onPageHide")
|
||||
}
|
||||
}
|
||||
@@ -157,13 +157,13 @@ export struct NoteHomeComp {
|
||||
|
||||
aboutToAppear(): void {
|
||||
LogUtil.info(this.TAG, "aboutToAppear")
|
||||
let isContinue = AppStorage.Get<boolean>('IsContinue')
|
||||
let isContinue = AppStorage.get<boolean>('IsContinue')
|
||||
LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue)
|
||||
if (isContinue) {
|
||||
this.sectionStatus = AppStorage.Get('Section')!;
|
||||
this.sectionStatus = AppStorage.get('Section')!;
|
||||
}
|
||||
// continue from phone
|
||||
let continueFromPhone = AppStorage.Get<boolean>('ContinueFromPhone')
|
||||
let continueFromPhone = AppStorage.get<boolean>('ContinueFromPhone')
|
||||
LogUtil.info(this.TAG, "aboutToAppear, continueFromPhone : " + continueFromPhone)
|
||||
if (continueFromPhone) {
|
||||
this.sectionStatus = 1
|
||||
@@ -176,4 +176,12 @@ export struct NoteHomeComp {
|
||||
aboutToDisappear(): void {
|
||||
LogUtil.info(this.TAG, "aboutToDisappear")
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
LogUtil.info(this.TAG, "onPageShow");
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
LogUtil.info(this.TAG, "onPageHide");
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteD
|
||||
@Component
|
||||
export struct NoteHomePortraitComp {
|
||||
// 当前文件夹、笔记、分栏
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')!;
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')!;
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.get('Folder')!;
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.get('Note')!;
|
||||
@Provide('SectionStatus') sectionStatus: number = 1; // 表示分栏状态, 3表示三分栏, 2表示二分栏,1表示一分栏
|
||||
@Provide('LastSectionStatus') lastSectionStatus: number = 1; // 记录分栏上一次的状态
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0];
|
||||
@@ -34,7 +34,7 @@ export struct NoteHomePortraitComp {
|
||||
|
||||
// 分栏状态
|
||||
@Provide('ExpandStatus') expandStatus: boolean = false // 笔记本折叠展开状态
|
||||
@Provide('ChooseNote') chooseNote: boolean = AppStorage.Get<boolean>('Choose')!; // 是否选择笔记进行打开
|
||||
@Provide('ChooseNote') chooseNote: boolean = AppStorage.get<boolean>('Choose')!; // 是否选择笔记进行打开
|
||||
|
||||
@Provide('Search') search: boolean = false // 是否处于搜索状态
|
||||
@Provide('SearchResultList') searchResultList: NoteData[] = [] // 搜索得到的笔记列表
|
||||
@@ -84,4 +84,12 @@ export struct NoteHomePortraitComp {
|
||||
aboutToDisappear(): void {
|
||||
LogUtil.info(this.TAG, "aboutToDisappear")
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
LogUtil.info(this.TAG, "onPageShow")
|
||||
}
|
||||
|
||||
onPageHide(): void {
|
||||
LogUtil.info(this.TAG, "onPageHide")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user