modify UIExtension of AppBar

Signed-off-by: caocan <caocan6@huawei.com>
Change-Id: Ic91f2e54713e9b1393ee9658b7e6e494c7a971e9
This commit is contained in:
caocan 2023-07-12 17:55:20 +08:00
parent 9b02587eb7
commit 2d9a406c14
8 changed files with 38 additions and 62 deletions

View File

@ -880,6 +880,12 @@ void UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window, const std::str
LOGI("Initialize for current process.");
SetHwIcuDirectory();
Container::UpdateCurrent(INSTANCE_ID_PLATFORM);
auto abilityContext = OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(context);
if (abilityContext) {
int32_t missionId = -1;
abilityContext->GetMissionId(missionId);
AceApplicationInfo::GetInstance().SetMissionId(abilityContext->GetMissionId(missionId));
}
AceApplicationInfo::GetInstance().SetProcessName(context->GetBundleName());
AceApplicationInfo::GetInstance().SetPackageName(context->GetBundleName());
AceApplicationInfo::GetInstance().SetDataFileDirPath(context->GetFilesDir());

View File

@ -13,22 +13,12 @@
* limitations under the License.
*/
#include "base/ui_extension/ui_extension_helper.h"
#include "core/common/ui_extension_helper.h"
#include "core/components_ng/pattern/ui_extension/ui_extension_model_ng.h"
namespace OHOS::Ace {
UIExtensionHelper& UIExtensionHelper::GetInstance()
{
static UIExtensionHelper instance;
return instance;
}
UIExtensionHelper::UIExtensionHelper() {}
UIExtensionHelper::~UIExtensionHelper() {}
RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string& bundleName,
const std::string& abilityName, const std::map<std::string, std::string>& params,
std::function<void(int32_t)>&& onRelease,
@ -37,4 +27,4 @@ RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string
return NG::UIExtensionModelNG::Create(bundleName, abilityName, params, std::move(onRelease), std::move(onError));
}
}
} // namespace OHOS::Ace

View File

@ -13,22 +13,12 @@
* limitations under the License.
*/
#include "base/ui_extension/ui_extension_helper.h"
#include "core/common/ui_extension_helper.h"
#include "core/components_ng/pattern/ui_extension/ui_extension_model_ng.h"
namespace OHOS::Ace {
UIExtensionHelper& UIExtensionHelper::GetInstance()
{
static UIExtensionHelper instance;
return instance;
}
UIExtensionHelper::UIExtensionHelper() {}
UIExtensionHelper::~UIExtensionHelper() {}
RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string& bundleName,
const std::string& abilityName, const std::map<std::string, std::string>& params,
std::function<void(int32_t)>&& onRelease,
@ -37,4 +27,4 @@ RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string
return nullptr;
}
}
} // namespace OHOS::Ace

View File

@ -192,6 +192,15 @@ public:
return pid_;
}
void SetMissionId(int32_t missionId)
{
missionId_ = missionId;
}
int32_t GetMissionId() const
{
return missionId_;
}
protected:
std::string countryOrRegion_;
std::string language_;
@ -219,6 +228,7 @@ protected:
int32_t apiVersion_ = 0;
std::string versionName_;
uint32_t versionCode_ = 0;
int32_t missionId_ = -1;
};
} // namespace OHOS::Ace

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_UI_EXTENSION_UI_EXTENSION_HELPER_H
#define FOUNDATION_ACE_FRAMEWORKS_BASE_UI_EXTENSION_UI_EXTENSION_HELPER_H
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_UI_EXTENSION_HELPER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_UI_EXTENSION_HELPER_H
#include <map>
#include <string>
@ -25,16 +25,11 @@ namespace OHOS::Ace {
class ACE_EXPORT UIExtensionHelper final {
public:
static UIExtensionHelper& GetInstance();
RefPtr<NG::FrameNode> CreateUIExtensionNode(const std::string& bundleName,
static RefPtr<NG::FrameNode> CreateUIExtensionNode(const std::string& bundleName,
const std::string& abilityName, const std::map<std::string, std::string>& params,
std::function<void(int32_t)>&& onRelease,
std::function<void(int32_t, const std::string&, const std::string&)>&& onError);
private:
UIExtensionHelper();
~UIExtensionHelper();
};
}
#endif // FOUNDATION_ACE_FRAMEWORKS_BASE_UI_EXTENSION_UI_EXTENSION_HELPER_H
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_UI_EXTENSION_HELPER_H

View File

@ -17,9 +17,9 @@
#include <map>
#include "base/ui_extension/ui_extension_helper.h"
#include "base/want/want_wrap.h"
#include "core/common/container.h"
#include "core/common/ui_extension_helper.h"
#include "core/components_ng/pattern/app_bar/app_bar_theme.h"
#include "core/components_ng/pattern/button/button_layout_property.h"
#include "core/components_ng/pattern/button/button_pattern.h"
@ -229,14 +229,19 @@ void AppBarView::BindContentCover(int32_t targetId)
auto onRelease = [overlayManager, &modalStyle, targetId](int32_t releaseCode) {
overlayManager->BindContentCover(false, nullptr, nullptr, modalStyle, nullptr, nullptr, targetId);
};
auto onError = [overlayManager, &modalStyle, targetId](int32_t code, const std::string& name, const std::string& message) {
auto onError =
[overlayManager, &modalStyle, targetId](int32_t code, const std::string& name, const std::string& message) {
overlayManager->BindContentCover(false, nullptr, nullptr, modalStyle, nullptr, nullptr, targetId);
};
auto missionId = AceApplicationInfo::GetInstance().GetMissionId();
std::map<std::string, std::string> params;
params.try_emplace("bundleName", AceApplicationInfo::GetInstance().GetProcessName());
params.try_emplace("abilityName", AceApplicationInfo::GetInstance().GetAbilityName());
params.try_emplace("module", Container::Current()->GetModuleName());
auto uiExtNode = OHOS::Ace::UIExtensionHelper::GetInstance().CreateUIExtensionNode(
if (missionId != -1) {
params.try_emplace("missionId", std::to_string(missionId));
}
auto uiExtNode = OHOS::Ace::UIExtensionHelper::CreateUIExtensionNode(
bundleName, abilityName, params, std::move(onRelease), std::move(onError));
auto layoutProperty = uiExtNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, uiExtNode);

View File

@ -13,20 +13,10 @@
* limitations under the License.
*/
#include "base/ui_extension/ui_extension_helper.h"
#include "core/common/ui_extension_helper.h"
namespace OHOS::Ace {
UIExtensionHelper& UIExtensionHelper::GetInstance()
{
static UIExtensionHelper instance;
return instance;
}
UIExtensionHelper::UIExtensionHelper() {}
UIExtensionHelper::~UIExtensionHelper() {}
RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string& bundleName,
const std::string& abilityName, const std::map<std::string, std::string>& params,
std::function<void(int32_t)>&& onRelease)

View File

@ -13,20 +13,10 @@
* limitations under the License.
*/
#include "base/ui_extension/ui_extension_helper.h"
#include "core/common/ui_extension_helper.h"
namespace OHOS::Ace {
UIExtensionHelper& UIExtensionHelper::GetInstance()
{
static UIExtensionHelper instance;
return instance;
}
UIExtensionHelper::UIExtensionHelper() {}
UIExtensionHelper::~UIExtensionHelper() {}
RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string& bundleName,
const std::string& abilityName, const std::map<std::string, std::string>& params,
std::function<void(int32_t)>&& onRelease,