diff --git a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css
index 7afe50dcd4bab9a60f6f5c77b691ed2f200d5cca..815f5fd8e07ccc70eac155a4d5be5b268df06374 100644
--- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css
+++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css
@@ -18,21 +18,45 @@
flex-direction: column;
justify-content: center;
align-items: center;
- left: 0px;
- top: 0px;
- width: 100%;
- height: 100%;
- background-color: aqua;
+ width: 397vp;
+ height: 117vp;
+ border-radius: 24vp;
+ background-color: rgba(255, 255, 255, 1);
+}
+
+.btn-group {
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
}
.btn {
- width: 50%;
- height: 100px;
- font-size: 80px;
- margin: 10px;
+ width: 116vp;
+ height: 40vp;
+ font-size: 16fp;
+ background-color: rgba(255, 255, 255, 1);
+ text-color: rgba(13, 129, 242, 1);
+ text-align: center;
+ line-height: 22vp;
+ font-weight: 500;
+ margin: 9vp 8vp;
}
text {
- font-size: 100px;
- margin: 10px;
+ align-items: center;
+ margin-top: 24vp;
+ width: 350vp;
+ height: 21vp;
+ opacity: 1;
+ font-size: 16fp;
+ text-color: rgba(24, 36, 49, 1);
+ text-align: center;
+ font-weight: 400;
+}
+
+.spli {
+ width: 0.5vp;
+ height: 24vp;
+ background-color: rgba(0, 0, 0, 2);
+ margin-top: 24vp;
}
\ No newline at end of file
diff --git a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml
index 73e8c517ae776509ae3d4a2cb803c5b6acb6fd52..f5eff4a82390de812329bf5cc324c74a5db5007a 100644
--- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml
+++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml
@@ -1,4 +1,4 @@
-
-
+
{{ requestNotification }}
-
-
-
+
+
+
+
+
+
+
+
diff --git a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js
index b12e1e95c1cdbb76d968ffa61e2ca9cbc4800a09..9c9463b90b63bc234247f02fa3a5982b471defb7 100644
--- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js
+++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js
@@ -25,6 +25,9 @@ export default {
},
onInit() {
console.info('getParams: ' + JSON.stringify(router.getParams()));
+ this.requestNotification = this.$t('message.requestNotification');
+ this.allowButton = this.$t('message.allowButton');
+ this.cancelButton = this.$t('message.cancelButton');
},
onAllow() {
console.info('clicked allow');
diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h
index a6d4a388fa894ed03d8b7b77def2c37752dd301f..d180de930c08a8bc370fc5f83c4130d1cb26083d 100644
--- a/services/ans/include/advanced_notification_service.h
+++ b/services/ans/include/advanced_notification_service.h
@@ -191,6 +191,7 @@ private:
void TriggerRemoveWantAgent(const sptr
&request);
bool CheckApiCompatibility(const sptr &bundleOption);
ErrCode IsAllowedNotifySelf(const sptr &bundleOption, bool &allowed);
+ void GetDisplayPosition(int& offsetX, int& offsetY, int& width, int& height, bool& wideScreen);
ErrCode SetNotificationRemindType(sptr notification, bool isLocal);
#ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED
diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp
index 972b3265769b64ea20578507c0bf7c2f913c7023..5578b88135444101820ccc37b7de6dd00cf05154 100644
--- a/services/ans/src/advanced_notification_service.cpp
+++ b/services/ans/src/advanced_notification_service.cpp
@@ -28,6 +28,7 @@
#include "ans_log_wrapper.h"
#include "ans_permission_def.h"
#include "bundle_manager_helper.h"
+#include "display_manager.h"
#include "ipc_skeleton.h"
#include "notification_constant.h"
#include "notification_filter.h"
@@ -67,10 +68,11 @@ constexpr int32_t DEFAULT_RECENT_COUNT = 16;
constexpr int HOURS_IN_ONE_DAY = 24;
-constexpr int DIALOG_POSTION_X = 150;
-constexpr int DIALOG_POSTION_Y = 300;
-constexpr int DIALOG_WIDTH = 450;
-constexpr int DIALOG_HEIGHT = 300;
+constexpr int DIALOG_DEFAULT_WIDTH = 400;
+constexpr int DIALOG_DEFAULT_HEIGHT = 240;
+constexpr int WINDOW_DEFAULT_WIDTH = 720;
+constexpr int WINDOW_DEFAULT_HEIGHT = 1280;
+constexpr int UI_HALF = 2;
struct RecentNotification {
sptr notification = nullptr;
@@ -1391,17 +1393,24 @@ ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string
return result;
}
+ int positionX;
+ int positionY;
+ int width;
+ int height;
+ bool wideScreen;
+ GetDisplayPosition(positionX, positionY, width, height, wideScreen);
+
const std::string params = std::string("{\"requestNotification\":\"Allowed to send notification?\", ") +
std::string("\"allowButton\":\"Allow\", \"cancelButton\":\"Cancel\", \"uid\":\"") +
std::to_string(bundleOption->GetUid()) + std::string("\"}");
Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
"notification_dialog",
params,
- OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
- DIALOG_POSTION_X,
- DIALOG_POSTION_Y,
- DIALOG_WIDTH,
- DIALOG_HEIGHT,
+ Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
+ positionX,
+ positionY,
+ width,
+ height,
[this](int32_t id, const std::string& event, const std::string& params) {
ANS_LOGD("Dialog callback: %{public}s, %{public}s", event.c_str(), params.c_str());
int32_t uid = std::stoi(params, nullptr);
@@ -3307,5 +3316,43 @@ void AdvancedNotificationService::OnBundleDataCleared(const sptrGetWidth(), display->GetHeight());
+ if (display->GetWidth() < display->GetHeight()) {
+ float widthRatio = 0.75f;
+ int heightRatio = 5;
+ width = static_cast(display->GetWidth() * widthRatio);
+ height = display->GetHeight() / heightRatio;
+ } else {
+ int widthRatio = 3;
+ int heightRatio = 4;
+ wideScreen = true;
+ width = display->GetWidth() / widthRatio;
+ height = display->GetHeight() / heightRatio;
+ }
+ offsetX = (display->GetWidth() - width) / UI_HALF;
+ offsetY = (display->GetHeight() - height) / UI_HALF;
+ } else {
+ ANS_LOGD("dialog get display fail, use default wide.");
+ width = DIALOG_DEFAULT_WIDTH;
+ height = DIALOG_DEFAULT_HEIGHT;
+ offsetX = (WINDOW_DEFAULT_WIDTH - width) / UI_HALF;
+ offsetY = (WINDOW_DEFAULT_HEIGHT - height) / UI_HALF;
+ }
+ ANS_LOGD("GetDisplayPosition: %{public}d, %{public}d (%{public}d x %{public}d)",
+ offsetX, offsetY, width, height);
+}
} // namespace Notification
} // namespace OHOS