更新输入法选择弹框、修改bug

Signed-off-by: zhouyongfei <zhouyongfei@huawei.com>
This commit is contained in:
zhouyongfei 2022-02-26 16:26:44 +08:00
parent 502674d387
commit c11407911b
7 changed files with 29 additions and 50 deletions

View File

@ -18,7 +18,7 @@
namespace OHOS {
namespace MiscServices {
const char *ParaHandle::DEFAULT_IME_KEY = "persist.sys.default_ime";
const char *ParaHandle::DEFAULT_IME_NAME = "com.example.kikakeyboard/com.example.kikakeyboard.ServiceExtAbility";
const char *ParaHandle::DEFAULT_IME_NAME = "com.example.kikakeyboard/ServiceExtAbility";
bool ParaHandle::SetDefaultIme(int32_t userId, const std::string &imeName)
{
if (userId != main_userId) {

View File

@ -166,13 +166,7 @@ namespace MiscServices {
std::lock_guard<std::mutex> lock(mMutex);
IMSA_HILOGI("JsInputMethodEngineListener::OnInputStop");
NativeValue* nativeValue = engine_->CreateObject();
NativeObject* object = ConvertNativeValueTo<NativeObject>(nativeValue);
if (object == nullptr) {
IMSA_HILOGI("Failed to convert rect to jsObject");
return;
}
object->SetProperty("imeId", CreateJsValue(*engine_, imeId));
NativeValue* nativeValue = CreateJsValue(*engine_, imeId);
NativeValue* argv[] = {nativeValue};
std::string methodName = "inputStop";

View File

@ -103,7 +103,7 @@ namespace MiscServices {
}
bool JsKeyboardDelegateListener::CallJsMethodReturnBool(std::string methodName,
NativeValue* const* argv, size_t argc)
NativeValue* const* argv, size_t argc)
{
IMSA_HILOGI("JsKeyboardDelegateListener::CallJsMethodReturnBool");
if (engine_ == nullptr) {

View File

@ -1,5 +1,4 @@
import router from '@ohos.router'
import resourceManager from '@ohos.resourceManager';
export default {
data: {
@ -8,7 +7,6 @@ export default {
onInit() {
this.dialogTitle = this.$t('strings.dialogTitle');
this.setIme = this.$t('strings.setIme');
this.initString()
},
changeDefaultIme(ime) {
console.info('ImsaKit-dialog changeDefaultIme: ' + ime);
@ -18,40 +16,4 @@ export default {
console.info('ImsaKit-dialog startImeSetting');
callNativeHandler("EVENT_START_IME_SETTING", "");
},
initString() {
for (var i = 0; i < this.imeList.length; i++) {
let bundle = this.imeList[i].ime;
console.info('ImsaKit-dialog initString bundle ' + bundle);
let index = bundle.indexOf("/");
let pn = bundle.substring(0, index);
let labelId = Number(this.imeList[i].labelId);
let discriptionId = Number(this.imeList[i].discriptionId);
resourceManager.getResourceManager(pn).then(mgr => {
mgr.getString(labelId).then(value => {
this.updateLabelData(bundle, value, '');
}).catch(error => {
console.info("ImsaKit-dialog initString resource getString error:" + error);
})
mgr.getString(discriptionId).then(value => {
this.updateLabelData(bundle, '', value);
}).catch(error => {
console.info("ImsaKit-dialog initString resource getString error:" + error);
})
}).catch(error => {
console.info("ImsaKit-dialog initString getResourceManager error:" + error);
});
}
},
updateLabelData(bundle, label, discription) {
for (var i = 0; i < this.imeList.length; i++) {
if (this.imeList[i].ime == bundle) {
if (label != '') {
this.imeList[i].label = label;
}
if (discription != '') {
this.imeList[i].discription = discription;
}
}
}
}
}

View File

@ -33,6 +33,8 @@ namespace MiscServices {
std::vector<KeyboardType*> mTypes;
int32_t labelId;
int32_t descriptionId;
std::u16string label;
std::u16string description;
InputMethodProperty();
~InputMethodProperty();

View File

@ -47,6 +47,8 @@ namespace MiscServices {
mDefaultImeId = property.mDefaultImeId;
labelId = property.labelId;
descriptionId = property.descriptionId;
label = property.label;
description = property.description;
for (int i = 0; i < (int)mTypes.size(); i++) {
KeyboardType *type = new KeyboardType(*property.mTypes[i]);
@ -71,6 +73,8 @@ namespace MiscServices {
mDefaultImeId = property.mDefaultImeId;
labelId = property.labelId;
descriptionId = property.descriptionId;
label = property.label;
description = property.description;
for (int i = 0; i < (int)mTypes.size(); i++) {
KeyboardType *type = new KeyboardType(*property.mTypes[i]);
@ -93,7 +97,9 @@ namespace MiscServices {
&& parcel.WriteBool(isSystemIme)
&& parcel.WriteInt32(mDefaultImeId)
&& parcel.WriteInt32(labelId)
&& parcel.WriteInt32(descriptionId)))
&& parcel.WriteInt32(descriptionId)
&& parcel.WriteString16(label)
&& parcel.WriteString16(description)))
return false;
int32_t size = (int32_t)mTypes.size();
parcel.WriteInt32(size);
@ -122,6 +128,8 @@ namespace MiscServices {
info->mDefaultImeId = parcel.ReadInt32();
info->labelId = parcel.ReadInt32();
info->descriptionId = parcel.ReadInt32();
info->label = parcel.ReadString16();
info->description = parcel.ReadString16();
int32_t size = parcel.ReadInt32();
if (size == 0)

View File

@ -30,6 +30,7 @@
#include "application_info.h"
#include "common_event_support.h"
#include "im_common_event_manager.h"
#include "resource_manager.h"
namespace OHOS {
namespace MiscServices {
@ -387,12 +388,24 @@ namespace MiscServices {
return ErrorCode::ERROR_STATUS_UNKNOWN_ERROR;
}
for (auto extension : extensionInfos) {
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager());
if (resourceManager == nullptr) {
IMSA_HILOGI("InputMethodSystemAbility::listInputMethodByUserId resourcemanager is nullptr");
break;
}
AppExecFwk::ApplicationInfo applicationInfo = extension.applicationInfo;
InputMethodProperty *property = new InputMethodProperty();
property->mPackageName = Str8ToStr16(extension.bundleName);
property->mAbilityName = Str8ToStr16(extension.name);
property->labelId = applicationInfo.labelId;
property->descriptionId = applicationInfo.descriptionId;
resourceManager->AddResource(extension.resourcePath.c_str());
std::string labelString;
resourceManager->GetStringById(applicationInfo.labelId, labelString);
property->label = Str8ToStr16(labelString);
std::string descriptionString;
resourceManager->GetStringById(applicationInfo.descriptionId, descriptionString);
property->description = Str8ToStr16(descriptionString);
properties->push_back(property);
}
return ErrorCode::NO_ERROR;
@ -876,8 +889,8 @@ namespace MiscServices {
params += "\"discriptionId\": \"" + std::to_string(property->descriptionId) + "\",";
std::string isDefaultIme = defaultIme == imeId ? "true" : "false";
params += "\"isDefaultIme\": \"" + isDefaultIme + "\",";
params += "\"label\": \"\",";
params += "\"discription\": \"\"";
params += "\"label\": \"" + Str16ToStr8(property->label) + "\",";
params += "\"discription\": \"" + Str16ToStr8(property->description) + "\"";
}
params += "}]}";