mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-24 00:50:03 +00:00
del permission
Signed-off-by: zhaojunxia <zhaojunxia@kaihong.com>
This commit is contained in:
parent
127a41fe77
commit
606bfb3496
@ -11,12 +11,6 @@ import { BusinessError } from '@ohos.base';
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
// inputMethod.getSetting().showOptionalInputMethods();
|
||||
// try {
|
||||
// this.getPermission();
|
||||
// } catch (err) {
|
||||
// hilog.info(0x0000, 'testTag', '%{public}s', 'err is ' + err);
|
||||
// }
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
@ -50,23 +44,4 @@ export default class EntryAbility extends UIAbility {
|
||||
// Ability has back to background
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
|
||||
}
|
||||
|
||||
getPermission(): void {
|
||||
let array: Array<Permissions> = [
|
||||
'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED',
|
||||
'ohos.permission.START_ABILITIES_FROM_BACKGROUND'
|
||||
];
|
||||
|
||||
let atManager = abilityAccessCtrl.createAtManager();
|
||||
|
||||
// requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
|
||||
atManager.requestPermissionsFromUser(this.context, array).then((data) => {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'data type:' + typeof (data));
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'data:' + data);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'data permissions:' + data.permissions);
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'data result:' + data.authResults);
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(0x0000, 'Failed to start ability',JSON.stringify(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ interface CursorInfo {
|
||||
y: number;
|
||||
height: number
|
||||
}
|
||||
const previewContent: string = "hello world";// hello world
|
||||
const previewContent: string = "hello world";
|
||||
const InputMethodEngine: inputMethodEngine.InputMethodAbility = inputMethodEngine.getInputMethodAbility();
|
||||
const TAG: string = 'KeyboardController->';
|
||||
const isDebug: boolean = false;
|
||||
@ -181,13 +181,16 @@ export class InputHandler {
|
||||
|
||||
//设置预上屏数据
|
||||
let length = 2;
|
||||
let textPre: string = this.mTextInputClient.getForwardSync(length); // 取出的内容为当前输入之前的字符,不包含当前的字符
|
||||
let textPre: string = this.mTextInputClient.getForwardSync(length);
|
||||
this.addLog('insertText textPre:' + textPre);
|
||||
|
||||
// 取出的内容为当前输入之前的字符,不包含当前的字符,需将当前字符加上
|
||||
textPre = textPre + text;
|
||||
if (textPre == "hel") {
|
||||
this.addLog('insertText hel');
|
||||
try {
|
||||
let endRange: number = indexCursor + 1; //把当前字符计算在内
|
||||
//把当前字符计算在内
|
||||
let endRange: number = indexCursor + 1;
|
||||
this.addLog('insertText start ' + (indexCursor - length).toString());
|
||||
this.addLog('insertText end ' + (indexCursor).toString());
|
||||
let range: inputMethodEngine.Range = { start: indexCursor - length, end: endRange };
|
||||
@ -206,12 +209,13 @@ export class InputHandler {
|
||||
let indexSubStrStart: number = this.intputText.lastIndexOf("hel");
|
||||
this.addLog('insertText indexSubStrStart ' + indexSubStrStart.toString());
|
||||
|
||||
if (indexSubStrStart >= 0) { // 当前文本框存在预上屏的部分内容
|
||||
if (indexSubStrStart >= 0) {
|
||||
// 当前文本框存在预上屏的部分内容
|
||||
let subStr: string = this.intputText.substring(indexSubStrStart, indexCursor);
|
||||
this.addLog('insertText indexSubStrStart subStr ' + subStr);
|
||||
|
||||
if((previewContent != subStr) && (previewContent.includes(subStr))) { // 文本框的子串与预上屏内容吻合,则调用预上屏接口,替换文本框的子串
|
||||
|
||||
if((previewContent != subStr) && (previewContent.includes(subStr))) {
|
||||
// 文本框的子串与预上屏内容吻合,则调用预上屏接口,替换文本框的子串
|
||||
this.addLog('insertText previewContent indexSubStrStart ' + indexSubStrStart.toString());
|
||||
this.addLog('insertText previewContent end ' + (indexCursor).toString());
|
||||
let range: inputMethodEngine.Range = { start: indexSubStrStart, end: indexCursor + 1 };
|
||||
|
Loading…
Reference in New Issue
Block a user