mirror of
https://github.com/openharmony/applications_notes.git
synced 2026-07-18 18:24:27 -04:00
hap only use one module name
Signed-off-by: yiqiang <tangyiqiang@huawei.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import Ability from '@ohos.application.Ability'
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import AbilityConstant from '@ohos.application.AbilityConstant'
|
||||
import fileio from '@ohos.fileio'
|
||||
import inputMethod from '@ohos.inputmethod';
|
||||
@@ -23,6 +24,11 @@ export default class MainAbility extends Ability {
|
||||
|
||||
onCreate(want, launchParam) {
|
||||
console.info(this.Tag + " onCreate, launchReason is " + launchParam.launchReason)
|
||||
console.info(this.Tag + " onCreate, deviceType" + deviceInfo.deviceType)
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
AppStorage.SetOrCreate<boolean>('Expand', false)
|
||||
AppStorage.SetOrCreate<boolean>('Choose', true)
|
||||
}
|
||||
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
|
||||
// 设置迁移标记
|
||||
AppStorage.SetOrCreate<boolean>('IsContinue', true)
|
||||
@@ -37,6 +43,9 @@ export default class MainAbility extends Ability {
|
||||
if (continueChoose) {
|
||||
console.info(this.Tag + " continue from phone")
|
||||
AppStorage.SetOrCreate<boolean>('ContinueFromPhone', true)
|
||||
} else {
|
||||
AppStorage.SetOrCreate<boolean>('ContinueFromTablet', true)
|
||||
console.info(this.Tag + " continue from tablet")
|
||||
}
|
||||
this.context.restoreWindowStage(null)
|
||||
}
|
||||
@@ -85,6 +94,9 @@ export default class MainAbility extends Ability {
|
||||
// 保存本端的迁移数据
|
||||
wantParam["ContinueNote"] = continueNote
|
||||
wantParam["ContinueSection"] = continueSection
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
wantParam["ContinueChoose"] = true
|
||||
}
|
||||
|
||||
// save img to DisFileDir
|
||||
console.info(this.Tag + " onContinue, save img to DisFileDir")
|
||||
|
||||
@@ -14,19 +14,20 @@
|
||||
*/
|
||||
|
||||
import fileio from '@ohos.fileio'
|
||||
import bundle from '@ohos.bundle'
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
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 NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
|
||||
import inputMethod from '@ohos.inputmethod';
|
||||
import router from '@system.router';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct MyNoteHomeComp {
|
||||
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
|
||||
@Provide('PortraitModel') portraitModel: boolean = false
|
||||
@Provide('PortraitModel') portraitModel: boolean = (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default')
|
||||
@Provide('RefreshFlag') refreshFlag: number = 0
|
||||
private controllerShow: WebController = new WebController()
|
||||
private context = getContext(this)
|
||||
@@ -35,7 +36,12 @@ export struct MyNoteHomeComp {
|
||||
build() {
|
||||
Row() {
|
||||
if (this.dBQueryFinished == 1) {
|
||||
NoteHomeComp({ controllerShow: this.controllerShow })
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
NoteHomePortraitComp()
|
||||
} else {
|
||||
NoteHomeComp({ controllerShow: this.controllerShow })
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
@@ -54,6 +60,13 @@ export struct MyNoteHomeComp {
|
||||
"ohos.permission.READ_MEDIA",
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
]
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
permissionList = [
|
||||
"ohos.permission.READ_MEDIA",
|
||||
"ohos.permission.MEDIA_LOCATION",
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
]
|
||||
}
|
||||
LogUtil.info(this.TAG, 'permissions need to require from user')
|
||||
let context: any = getContext(this);
|
||||
context.requestPermissionsFromUser(permissionList).then((data) => {
|
||||
@@ -85,12 +98,25 @@ export struct MyNoteHomeComp {
|
||||
|
||||
onPageShow(): void{
|
||||
LogUtil.info(this.TAG, "onPageShow")
|
||||
let currentNote = AppStorage.Get<NoteData>('NewNote')
|
||||
let needRefesh = AppStorage.Get<boolean>('needRefresh')
|
||||
if (currentNote != null && needRefesh == true) {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + currentNote.content_text + "')" })
|
||||
AppStorage.SetOrCreate<boolean>('needRefresh',false)
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
// continue from tablet
|
||||
let continueFromTablet = AppStorage.Get<boolean>('ContinueFromTablet')
|
||||
LogUtil.info(this.TAG, "onPageShow, continueFromTablet : " + continueFromTablet)
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
let currentNote = AppStorage.Get<NoteData>('NewNote')
|
||||
let needRefresh = AppStorage.Get<boolean>('needRefresh')
|
||||
if (currentNote != null && needRefresh == true) {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + currentNote.content_text + "')" })
|
||||
AppStorage.SetOrCreate<boolean>('needRefresh',false)
|
||||
}
|
||||
}
|
||||
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import {NoteContentCompPortrait} from '@ohos/component/src/main/ets/components/NoteContentCompPortrait'
|
||||
import {NoteContent} from '@ohos/component/src/main/ets/components/NoteContent'
|
||||
import {LogUtil} from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
|
||||
@@ -21,6 +23,7 @@ import inputMethod from '@ohos.inputmethod'
|
||||
@Entry
|
||||
@Component
|
||||
struct NoteContentHome {
|
||||
@Provide('RefreshFlag') refreshFlag: number = 0
|
||||
private controllerShow: WebController = new WebController()
|
||||
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
|
||||
TAG = "NoteContentHome_Tablet"
|
||||
@@ -29,7 +32,12 @@ struct NoteContentHome {
|
||||
// Note content display area
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
|
||||
if (this.dBQueryFinished == 1) {
|
||||
NoteContent({ controllerShow: this.controllerShow })
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
NoteContentCompPortrait({ controllerShow: this.controllerShow })
|
||||
} else {
|
||||
NoteContent({ controllerShow: this.controllerShow })
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.backgroundColor($r("app.color.notecontent_color_ffffff"))
|
||||
@@ -41,7 +49,9 @@ struct NoteContentHome {
|
||||
LogUtil.info(this.TAG, "onBackPress")
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
|
||||
inputMethod.getInputMethodController().stopInput()
|
||||
if (deviceInfo.deviceType !== 'phone' && deviceInfo.deviceType !== 'default') {
|
||||
inputMethod.getInputMethodController().stopInput()
|
||||
}
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
@@ -51,6 +61,9 @@ struct NoteContentHome {
|
||||
if (isContinue) {
|
||||
RdbStoreUtil.initAppStorage(globalThis.noteContext)
|
||||
}
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
AppStorage.SetOrCreate<boolean>('NoteContentHomeExist', true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FolderListComp, FolderListBackGround } from '@ohos/component/src/main/ets/components/FolderListComp'
|
||||
import { NoteListComp } from '@ohos/component/src/main/ets/components/NoteListComp'
|
||||
import { NoteContentCompPortrait } from '@ohos/component/src/main/ets/components/NoteContentCompPortrait'
|
||||
import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants'
|
||||
import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
|
||||
import { circleColorArray } from '@ohos/utils/src/main/ets/default/model/NoteBaseData'
|
||||
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 { SysDefFolderUuid } from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'
|
||||
import LayoutUtil from '@ohos/utils/src/main/ets/default/baseUtil/LayoutUtil'
|
||||
import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct NoteHomePortraitComp {
|
||||
// 当前文件夹、笔记、分栏
|
||||
@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];
|
||||
@Provide('Longpress') longpress: boolean = false // 第二栏长按状态
|
||||
|
||||
// 分栏状态
|
||||
@Provide('ExpandStatus') expandStatus: boolean = AppStorage.Get<boolean>('Expand') // 笔记本折叠展开状态
|
||||
@Provide('ChooseNote') chooseNote: boolean = AppStorage.Get<boolean>('Choose') // 是否选择笔记进行打开
|
||||
|
||||
@Provide('Search') search: boolean = false // 是否处于搜索状态
|
||||
@Provide('SearchResultList') searchResultList: NoteData[] = [] // 搜索得到的笔记列表
|
||||
@Provide('InputKeyword') inputKeyword: string = '' // 搜索的字串
|
||||
@Provide('SelectedAll') selectedAll: boolean = false;
|
||||
@Provide('EditModel') editModel: boolean = false
|
||||
TAG = "NoteHomePortraitComp_Phone"
|
||||
|
||||
build() {
|
||||
Stack({ alignContent: Alignment.Start }) {
|
||||
|
||||
// Note list display area
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
|
||||
NoteListComp()
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.enabled(this.expandStatus ? false : true)
|
||||
.backgroundColor($r("app.color.notelist_bgcolor_f1f3f5"))
|
||||
|
||||
//Folder list display area
|
||||
Stack() {
|
||||
FolderListBackGround()
|
||||
FolderListComp()
|
||||
}
|
||||
.width(200)
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.visibility(this.expandStatus == false ? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100).height(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info(this.TAG, "aboutToAppear")
|
||||
}
|
||||
|
||||
aboutToDisappear(): void{
|
||||
LogUtil.info(this.TAG, "aboutToDisappear")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user