asysbang

 找回密码
 立即注册
查看: 6622|回复: 0
打印 上一主题 下一主题

通知栏修改---MTK平台5.1

[复制链接]

513

主题

2

好友

6404

积分

管理员

Rank: 80Rank: 80Rank: 80Rank: 80Rank: 80

最佳新人 活跃会员 热心会员 推广达人 宣传达人 灌水之王 突出贡献 优秀版主 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2016-3-14 14:22:01 |只看该作者 |倒序浏览
系统默认的通知

有普通的还有一种“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"



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

Archiver|手机版|aSys-帮 ( 京ICP备13033689号 )

GMT+8, 2024-10-5 18:33 , Processed in 0.042864 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部