- 注册时间
- 2013-4-19
- 最后登录
- 2024-9-26
- 阅读权限
- 200
- 积分
- 6404
- 精华
- 0
- 帖子
- 640
|
系统默认的通知
有普通的还有一种“heads up ”模式
http://developer.android.com/int ... /notifications.html
查看 “浮动通知”
这个模式默认的布局比较小 样式也比较单调,需要进行修改
写了一个通知的app然后运行观察log
V/NotificationService( 731): pkg=com.asysbang.developerheavn canInterrupt=true intercept=false
V/NotificationService( 731): Interrupting!
D/NotificationService( 731): useDefaultSound=false
D/NotificationService( 731): notification.sound=null
D/PhoneStatusBar( 914): addNotification key=0|com.asysbang.developerheavn|0|null|10055
D/KeyguardViewMediator( 914): isInputRestricted: showing=false, needReshow=false, provisioned=true
D/PhoneStatusBar( 914): launching notification in heads up mode
发现PhoneStatusBar 有打印对应的log
PhoneStatusBar继承 BaseStatusBar.java
其中private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent, boolean isHeadsUp) {
====================
关于样式的修改
framework-res
下面的styles_material.xml里面的TextAppearance.Material.Notification 可以改变time和title的字体大小和颜色
SystemUI
heads_up.xml是浮动通知的布局文件 通过修改 notification_panel_width 可以控制通知栏的宽度
res/layout/status_bar_notification_row.xml 添加android:paddingLeft="50dip" 生效
===================================
修改宽度 SystemUI res/values/dimens.xml 中 standard_notification_panel_width
修改高度 SystemUI res/values/dimens.xml 中 notification_min_height
修改字体 frameworks/base/core/res/res/values/styles_material.xml TextAppearance.Material.Notification.xxxxxx
icon大小 frameworks/base/core/res/res/values/dimens.xml notification_large_icon_width notification_large_icon_height (建议都是按原来的比例调整)
heads up消失时间 SystemUI res/values/config.xml 中 heads_up_notification_decay
待解决问题
布局文字 图片居中
屏蔽不需要的通知
自动弹出
=========================给heads_up notification 添加队列 不采用默认的覆盖的方式=======
commit 0bceaa00360d11132ca959a43633dfe18f410d13
Author: ligang <ligang@360.cn>
Date: Fri Mar 18 10:20:40 2016 +0800
add queue for heads up notification
diff --git a/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 3022d0d..2d7c099 100644
--- a/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -199,6 +199,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.LinkedList;
+import java.util.Queue;
import java.util.Map;
///M:add for multi window,@{
import com.mediatek.multiwindow.MultiWindowProxy;
@@ -1571,11 +1573,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return new UserHandle(mCurrentUserId);
}
+ private Queue<StatusBarNotification> mHeadsupWaitingForShow = new LinkedList<StatusBarNotification>();
+
@Override
public void addNotification(StatusBarNotification notification, RankingMap ranking) {
if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey());
if (mUseHeadsUp && shouldInterrupt(notification)) {
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
+ if(mHeadsUpNotificationView.isShowing()) {
+ mHeadsupWaitingForShow.add(notification);
+ Log.d(TAG, "qihoo add heads up notification to mHeadsupWaitingForShow");
+ return;
+ }
Entry interruptionCandidate = new Entry(notification, null);
ViewGroup holder = mHeadsUpNotificationView.getHolder();
if (inflateViewsForHeadsUp(interruptionCandidate, holder)) {
@@ -3552,6 +3561,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
vis ? mHeadsUpNotificationView.getKey() : "",
vis ? 1 : 0);
mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
+ if (!mHeadsupWaitingForShow.isEmpty()) {
+ Log.e(TAG,"qihoo show heads up noificaiton from queue");
+ addNotification(mHeadsupWaitingForShow.poll(),null);
+ }
}
public void onHeadsUpDismissed() {
diff --git a/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 43f9cba..f35d037 100644
--- a/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -160,6 +160,11 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
return mHeadsUp != null && mHeadsUp.key.equals(key);
}
+ //qihoo : added only for phonestatusbar to queue heads up notification
+ public boolean isShowing() {
+ return mHeadsUp != null;
+ }
+
/** Discard the Heads Up notification. */
public void clear() {
mHeadsUp = null;
@@ -287,7 +292,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- Log.v(TAG, "========HeadsUpNotificationView onInterceptTouchEvent()========");
+ //Log.v(TAG, "========HeadsUpNotificationView onInterceptTouchEvent()========");
if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()");
if (SystemClock.elapsedRealtime() < mStartTouchTime) {
Log.v(TAG, "onInterceptTouchEvent() SystemClock.elapsedRealtime < mStartTouchTime"
|
|