!72 平板竖屏适配

Merge pull request !72 from abc123/master
This commit is contained in:
openharmony_ci 2022-10-19 11:34:24 +00:00 committed by Gitee
commit cbb2ddc840
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
14 changed files with 116 additions and 35 deletions

View File

@ -137,6 +137,7 @@ export default class Constants {
static PASSWORD_TEXT_HEIGHT =40
static PASSWORD_TEXT_BORDER =20
static ACCOUNT_SPACE = 24
static ACCOUNT_SPACE_PORTRAIT = 40
}
export class StatusBarGroupComponentData {

View File

@ -99,7 +99,9 @@ export default class AccountsModel {
Log.showInfo(TAG, `eventListener:typeName ${typeName}`);
osAccount.getAccountManager().on(typeName, name, (userId: number) => {
Log.showInfo(TAG, `on ${typeName} callback userId = ${userId}`)
this.mCurrentUserId = userId
if (typeName == "activate"){
this.mCurrentUserId = userId
}
callback()
})
}

View File

@ -26,6 +26,7 @@ const TAG = 'ScreenLock-Accounts'
export default struct Accounts {
@State accountList: UserData[] = [];
private mViewModel: ViewModel = new ViewModel();
@StorageLink('screenlockdirection') screenlockdirection: number = 1
unSubscriber?: unsubscribe;
aboutToAppear() {
@ -44,7 +45,7 @@ export default struct Accounts {
build() {
Row() {
if (this.accountList.length > 1) {
List({ space: Constants.ACCOUNT_SPACE }) {
List({ space: this.screenlockdirection == 1 ? Constants.ACCOUNT_SPACE : Constants.ACCOUNT_SPACE_PORTRAIT }) {
ForEach(this.accountList, (item: any) => {
ListItem() {
UserItem({ userItem: item, viewModel: this.mViewModel })

View File

@ -25,6 +25,7 @@ const TAG = 'ScreenLock-CustomPSD'
export default struct CustomPSD {
@State mViewModel: ViewModel = new ViewModel()
@StorageLink('passwordArr') passwordArr: any[] = this.mViewModel.passwordArr
@StorageLink('screenlockdirection') screenlockdirection: number = 1
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
@ -79,14 +80,14 @@ export default struct CustomPSD {
.listDirection(Axis.Horizontal)
.height($r("app.float.custompsd_digitalpsd_ic_diameter"))
}
.width($r('app.float.custompsd_input_width'))
.width(this.screenlockdirection == 1 ? $r('app.float.custompsd_input_width'):$r('app.float.custompsd_input_width_portrait'))
.height($r('app.float.custompsd_input_height'))
Button($r('app.string.done'), {
type: ButtonType.Capsule,
stateEffect: true
})
.width($r('app.float.custompsd_input_width'))
.width(this.screenlockdirection == 1 ? $r('app.float.custompsd_input_width'):$r('app.float.custompsd_input_width_portrait'))
.height($r("app.float.custompsd_button_height"))
.enabled(this.passwordArr.length >= 1)
.opacity(deviceInfo.deviceType === 'tablet' ? 1 : (this.passwordArr.length >= 1 ? 1 : 0.4))
@ -110,7 +111,7 @@ export default struct CustomPSD {
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height($r('app.float.custompsd_key_area_height'))
.margin({ bottom: $r('app.float.custompsd_key_area_margin_bottom') })
.margin({ bottom: this.screenlockdirection == 1 ? $r('app.float.custompsd_key_area_margin_bottom') : $r('app.float.custompsd_key_area_margin_bottom_portrait')})
}
.width(Constants.FULL_CONTAINER_WIDTH)
}

View File

@ -24,6 +24,7 @@ const TAG = 'ScreenLock-DigitalPSD'
export default struct DigitalPSD {
@State mViewModel: ViewModel = new ViewModel()
@StorageLink('passwdMaskArr') passwdMaskArr: any[] = this.mViewModel.passwdMaskArr
@StorageLink('screenlockdirection') screenlockdirection: number = 1
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
@ -87,7 +88,7 @@ export default struct DigitalPSD {
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height($r('app.float.digitalpsd_key_area_height'))
.margin({ bottom: $r('app.float.digitalpsd_key_area_margin_bottom') })
.margin({ bottom: this.screenlockdirection == 1 ? $r('app.float.digitalpsd_key_area_margin_bottom') : $r('app.float.digitalpsd_key_area_margin_bottom_portrait') })
.flexShrink(0)
}
.width(Constants.FULL_CONTAINER_WIDTH)

View File

@ -122,7 +122,7 @@ export default struct MixedPSD {
.fontSize($r('app.float.mixedpsd_prompt_text_fontsize'))
.width($r('app.float.mixedpsd_input_width'))
.height($r('app.float.mixedpsd_input_height'))
.backgroundColor(Color.White)
.backgroundColor(Color.Gray)
.enterKeyType(EnterKeyType.Done)
.border({ width: 2, color: Color.Gray, radius: 15 })
.enabled(!this.mViewModel.inhibitInput)
@ -132,30 +132,42 @@ export default struct MixedPSD {
Log.showInfo(TAG, `onSubmit callback prompt:${this.mViewModel.prompt} inhibitInput:${this.mViewModel.inhibitInput}`)
})
})
.margin({ bottom: $r('app.float.mixedpsd_input_margin_bottom') })
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text($r('app.string.emergency_call'))
.fontSize($r('app.float.mixedpsd_prompt_fontsize'))
.fontWeight(FontWeight.Bold)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.onClick(this.mViewModel.onCallPhone.bind(this.mViewModel));
Text($r('app.string.done'))
.fontSize($r('app.float.mixedpsd_prompt_fontsize'))
.fontWeight(FontWeight.Bold)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.onClick(() => {
Log.showInfo(TAG, `onClick`)
this.mViewModel.onAuthPassword(() => {
Log.showInfo(TAG, `onClick callback prompt:${this.mViewModel.prompt} inhibitInput:${this.mViewModel.inhibitInput}`)
});
})
}
.width(Constants.HALF_CONTAINER_WIDTH)
Button('确认', {
type: ButtonType.Capsule,
stateEffect: true
})
.width($r('app.float.mixedpsd_input_width'))
.height($r('app.float.mixedpsd_input_height'))
.onClick(() => {
Log.showInfo(TAG, `onClick`)
this.mViewModel.onAuthPassword(() => {
Log.showInfo(TAG, `onClick callback prompt:${this.mViewModel.prompt} inhibitInput:${this.mViewModel.inhibitInput}`)
});
})
.margin({ top: $r('sys.float.ohos_id_elements_margin_vertical_l'),bottom: $r('app.float.mixedpsd_input_margin_bottom')})
Text($r('app.string.emergency_call'))
.fontSize($r('app.float.mixedpsd_prompt_fontsize'))
.fontWeight(FontWeight.Bold)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.onClick(this.mViewModel.onCallPhone.bind(this.mViewModel));
/* Text($r('app.string.done'))
.fontSize($r('app.float.mixedpsd_prompt_fontsize'))
.fontWeight(FontWeight.Bold)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.onClick(() => {
Log.showInfo(TAG, `onClick`)
this.mViewModel.onAuthPassword(() => {
Log.showInfo(TAG, `onClick callback prompt:${this.mViewModel.prompt} inhibitInput:${this.mViewModel.inhibitInput}`)
});
})*/
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)

View File

@ -108,6 +108,10 @@
"name": "digitalpsd_key_area_margin_bottom",
"value": "64"
},
{
"name": "digitalpsd_key_area_margin_bottom_portrait",
"value": "128"
},
{
"name": "mixedpsd_prompt_fontsize",
"value": "32"
@ -146,7 +150,7 @@
},
{
"name": "mixedpsd_input_margin_bottom",
"value": "128"
"value": "64"
},
{
"name": "custompsd_prompt_fontsize",
@ -168,6 +172,10 @@
"name": "custompsd_input_width",
"value": "600"
},
{
"name": "custompsd_input_width_portrait",
"value": "700"
},
{
"name": "custompsd_input_height",
"value": "72"
@ -196,6 +204,10 @@
"name": "custompsd_key_area_margin_bottom",
"value": "64"
},
{
"name": "custompsd_key_area_margin_bottom_portrait",
"value": "128"
},
{
"name": "custompsd_text_opacity",
"value": "1"

View File

@ -108,6 +108,10 @@
"name": "digitalpsd_key_area_margin_bottom",
"value": "52vp"
},
{
"name": "digitalpsd_key_area_margin_bottom_portrait",
"value": "52vp"
},
{
"name": "mixedpsd_prompt_fontsize",
"value": "16fp"
@ -168,6 +172,10 @@
"name": "custompsd_input_width",
"value": "288vp"
},
{
"name": "custompsd_input_width_portrait",
"value": "288vp"
},
{
"name": "custompsd_input_height",
"value": "36vp"
@ -196,6 +204,10 @@
"name": "custompsd_key_area_margin_bottom",
"value": "52vp"
},
{
"name": "custompsd_key_area_margin_bottom_portrait",
"value": "52vp"
},
{
"name": "custompsd_text_opacity",
"value": "0.2"

View File

@ -25,13 +25,41 @@ import sTimeManager from '../../../../../../common/src/main/ets/default/TimeMana
const TAG = "ScreenLock-ServiceExtAbility"
class ServiceExtAbility extends ServiceExtension {
private direction :number;
onCreate(want) {
Log.showInfo(TAG, 'onCreate, want:' + want.abilityName);
AbilityManager.setContext(AbilityManager.ABILITY_NAME_SCREEN_LOCK, this.context)
sTimeManager.init(this.context)
display.on("change", (id) => {
Log.showInfo(TAG, "screenlock display change, data: " + JSON.stringify(id))
display.getAllDisplay().then(async (arrayDisplay) => {
Log.showInfo(TAG, "getAllDisplay : " + JSON.stringify(arrayDisplay))
for (let display of arrayDisplay) {
Log.showInfo(TAG, "getAllDisplay start : " + JSON.stringify(display));
if (id == display.id) {
if (display.width > display.height) {
this.direction = 1;
} else {
this.direction = 2;
}
Log.showInfo(TAG, "direction change : " + this.direction)
AppStorage.SetOrCreate('screenlockdirection', this.direction)
this.resetWindow(display.width,display.height)
}
}
})
})
this.statusBarWindow()
this.createWindow(Constants.WIN_NAME)
}
private async resetWindow(width: number,height:number) {
Log.showInfo(TAG, "resetWindow width: " + width +",height:"+height)
let window = await windowManager.find(Constants.WIN_NAME);
Log.showInfo(TAG, "screenlock window : " + JSON.stringify(window));
await window.resetSize(width,height)
}
private createWindow(name: string) {
Log.showDebug(TAG, `createWindow name:${name}`)
@ -63,6 +91,7 @@ class ServiceExtAbility extends ServiceExtension {
width: '100%',
height: (44 * dis.width) / 1280,
}
this.direction =1
} else { // Phone verticalScreen Mode
rect = {
left: 0,
@ -70,7 +99,9 @@ class ServiceExtAbility extends ServiceExtension {
width: '100%',
height: (44 * dis.width) / 800
}
}
this.direction =2
};
AppStorage.SetOrCreate('screenlockdirection', this.direction);
AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, "rect", rect);
AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, "dis", {
width: dis.width,

View File

@ -27,6 +27,7 @@ export default class Constants {
static NOTIFICATION_LIST_AREA_WIDTH = '834'
static NOTIFICATION_AREA_HEIGHT = '40%'
static PASSWORD_AREA_WIDTH = '33.33%'
static PASSWORD_AREA_WIDTH_PORTRAIT = '50%'
static NOTIFICATION_LIST_AREA_HEIGHT = '300'
static STATUS_ABOUT_TO_APPEAR = 1

View File

@ -28,6 +28,7 @@ const TAG = 'ScreenLock-CustomPassword'
@Component
export default struct CustomPassword {
@State mHeightPx: number = 44
@StorageLink('screenlockdirection') screenlockdirection: number = 1
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
@ -61,7 +62,7 @@ export default struct CustomPassword {
Column() {
CustomPSD()
}
.width(Constants.PASSWORD_AREA_WIDTH)
.width(this.screenlockdirection == 1 ? Constants.PASSWORD_AREA_WIDTH : Constants.PASSWORD_AREA_WIDTH_PORTRAIT)
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)

View File

@ -28,6 +28,7 @@ const TAG = 'ScreenLock-DigitalPassword'
@Component
export default struct DigitalPassword {
@State mHeightPx: number = 44
@StorageLink('screenlockdirection') screenlockdirection: number = 1
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
@ -60,7 +61,7 @@ export default struct DigitalPassword {
Column() {
DigitalPSD()
}
.width(Constants.PASSWORD_AREA_WIDTH)
.width(this.screenlockdirection == 1 ? Constants.PASSWORD_AREA_WIDTH : Constants.PASSWORD_AREA_WIDTH_PORTRAIT)
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)

View File

@ -34,6 +34,7 @@ export default struct SlideScreenlock {
@Prop @Watch("onStatusChange") pageStatus: number
@StorageLink('deviceStatus') @Watch('onDeviceStatusChange') deviceStatus: string = ""
@StorageLink('isWallpaperShow') isWallpaperShow: boolean = true
@StorageLink('screenlockdirection') screenlockdirection: number = 1
private mHeightPx : number = 44
aboutToAppear() {
@ -94,7 +95,7 @@ export default struct SlideScreenlock {
Accounts()
}
.width(Constants.NOTIFICATION_AREA_WIDTH)
.height($r('app.float.shortcut_area_height'))
.height(this.screenlockdirection == 1 ? $r('app.float.shortcut_area_height'):$r('app.float.shortcut_area_height_portrait'))
}
.margin({ top: $r('app.float.shortcut_area_margin_top') })

View File

@ -24,6 +24,10 @@
"name": "shortcut_area_height",
"value": "120"
},
{
"name": "shortcut_area_height_portrait",
"value": "146"
},
{
"name": "notificationList_margin_top",
"value": "32"