mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-13 01:45:45 +00:00
OpenHarmony: shell update
This commit is contained in:
parent
e954eb544f
commit
cb58ba5cc3
6 changed files with 45 additions and 13 deletions
|
|
@ -3,6 +3,10 @@
|
|||
{
|
||||
"name": "app_name",
|
||||
"value": "MyApplication"
|
||||
},
|
||||
{
|
||||
"name": "perm_reason",
|
||||
"value": "Subsystem for SDL / SDL 子系统"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"meta": {
|
||||
"stableOrder": true
|
||||
"stableOrder": true,
|
||||
"enableUnifiedLockfile": false
|
||||
},
|
||||
"lockfileVersion": 3,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "SDL3/SDL_timer.h"
|
||||
#include "SDL3/SDL_video.h"
|
||||
#include "SDL3/SDL_vulkan.h"
|
||||
#include "SDL3/SDL_locale.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "SDL3/SDL_log.h"
|
||||
#include "SDL3/SDL_hints.h"
|
||||
|
|
@ -73,7 +74,9 @@ int main()
|
|||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
SDL_Log("Main func invoke !!!");
|
||||
int i = 0;
|
||||
auto t = SDL_GetPreferredLocales(&i);
|
||||
SDL_Log("Main func invoke !!! %s %s", t[0]->country, t[0]->language);
|
||||
// SDL_GL_LoadLibrary("libGLESv2.so");
|
||||
SDL_Log("sdl error: %s", SDL_GetError());
|
||||
SDL_Window* win = SDL_CreateWindow("test", 1024, 1024, SDL_WINDOW_OPENGL);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,35 @@
|
|||
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
|
||||
import { abilityAccessCtrl, AbilityConstant,
|
||||
common,
|
||||
ConfigurationConstant,
|
||||
Permissions,
|
||||
UIAbility, Want } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { promptAction, window } from '@kit.ArkUI';
|
||||
import { KeyboardAvoidMode } from '@ohos.arkui.UIContext';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
const DOMAIN = 0x0000;
|
||||
|
||||
const permissions: Array<Permissions> = ['ohos.permission.INPUT_KEYBOARD_CONTROLLER'];
|
||||
function reqPermissionsFromUser(permissions: Array<Permissions>, context: common.UIAbilityContext): void {
|
||||
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
|
||||
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
|
||||
let grantStatus: Array<number> = data.authResults;
|
||||
let length: number = grantStatus.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (grantStatus[i] === 0) {
|
||||
promptAction.showDialog({title: "permissions", message: "granted", buttons: [{text: 'Ok', color: '#999999'}]});
|
||||
} else {
|
||||
promptAction.showDialog({title: "permissions", message: "not granted", buttons: [{text: 'Ok', color: '#999999'}]});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 授权成功
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`);
|
||||
})
|
||||
}
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
||||
|
|
@ -20,6 +45,7 @@ export default class EntryAbility extends UIAbility {
|
|||
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/Index', (err) => {
|
||||
reqPermissionsFromUser(permissions, this.context);
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -10,18 +10,15 @@ export class ArkNapiCallback {
|
|||
sdltest.sdlLaunchMain("libentry.so", "main")
|
||||
}
|
||||
showDialog(title: string, message: string) {
|
||||
promptAction.showDialog({title: title, message: message, buttons: [{text: 'Ok', color: '#999999'}]});
|
||||
promptAction.showDialog({title: title, message: message, buttons: [{text: 'Ok', color: '#999999'}]})
|
||||
}
|
||||
fetchLocale(): string {
|
||||
let locale = new intl.Locale();
|
||||
return locale.toString();
|
||||
let locale = new intl.Locale()
|
||||
return locale.language + "_" + locale.region
|
||||
}
|
||||
test(): number {
|
||||
hilog.info(DOMAIN, 'testTag', 'Call from native !!!');
|
||||
focusControl.requestFocus("inputHandler")
|
||||
let locale = new intl.Locale();
|
||||
hilog.info(DOMAIN, 'testTag', locale.toString());
|
||||
return 1;
|
||||
hilog.info(DOMAIN, 'testTag', 'Call from native !!!')
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"meta": {
|
||||
"stableOrder": true
|
||||
"stableOrder": true,
|
||||
"enableUnifiedLockfile": false
|
||||
},
|
||||
"lockfileVersion": 3,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue