Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaa29ca6 authored by Selim Cinek's avatar Selim Cinek
Browse files

Migrated the systemUI based notification header

Previously the notification header had a seperate implementation
in SystemUI from which the platform implementation was derived.
Now that everything is in the framework, we’re migrating the
implementation for notification groups.ß

Change-Id: Ia61a75bd6c85e1805d4364a9e7e4587a020c1271
parent aef6c76f
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import com.android.internal.util.NotificationColorUtil;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -2986,7 +2985,7 @@ public class Notification implements Parcelable
        }

        private void resetStandardTemplate(RemoteViews contentView) {
            resetHeader(contentView);
            resetNotificationHeader(contentView);
            resetContentMargins(contentView);
            contentView.setViewVisibility(R.id.right_icon, View.GONE);
            contentView.setTextViewText(R.id.title, null);
@@ -2996,7 +2995,10 @@ public class Notification implements Parcelable
            contentView.setViewVisibility(R.id.progress, View.GONE);
        }

        private void resetHeader(RemoteViews contentView) {
        /**
         * Resets the notification header to its original state
         */
        private void resetNotificationHeader(RemoteViews contentView) {
            contentView.setImageViewResource(R.id.icon, 0);
            contentView.setTextViewText(R.id.app_name_text, null);
            contentView.setViewVisibility(R.id.chronometer, View.GONE);
@@ -3091,6 +3093,7 @@ public class Notification implements Parcelable

        private void bindNotificationHeader(RemoteViews contentView) {
            bindSmallIcon(contentView);
            bindChildCountColor(contentView);
            bindHeaderAppName(contentView);
            bindHeaderSubText(contentView);
            bindContentInfo(contentView);
@@ -3098,6 +3101,10 @@ public class Notification implements Parcelable
            bindExpandButton(contentView);
        }

        private void bindChildCountColor(RemoteViews contentView) {
            contentView.setTextColor(R.id.number_of_children, resolveColor());
        }

        private void bindContentInfo(RemoteViews contentView) {
            boolean visible = false;
            if (mN.extras.getCharSequence(EXTRA_INFO_TEXT) != null) {
@@ -3251,6 +3258,19 @@ public class Notification implements Parcelable
            return result;
        }

        /**
         * Construct a RemoteViews for the final notification header only
         *
         * @hide
         */
        public RemoteViews makeNotificationHeader() {
            RemoteViews header = new BuilderRemoteViews(mContext.getApplicationInfo(),
                    R.layout.notification_template_header);
            resetNotificationHeader(header);
            bindNotificationHeader(header);
            return header;
        }

        private void hideLine1Text(RemoteViews result) {
            result.setViewVisibility(R.id.text_line_1, View.GONE);
        }
+14 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;

import java.util.ArrayList;

@@ -40,6 +41,7 @@ public class NotificationHeaderView extends LinearLayout {
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private View mExpandButton;
    private View mIcon;
    private TextView mChildCount;

    public NotificationHeaderView(Context context) {
        this(context, null);
@@ -66,6 +68,7 @@ public class NotificationHeaderView extends LinearLayout {
        mSubTextView = findViewById(com.android.internal.R.id.header_sub_text);
        mExpandButton = findViewById(com.android.internal.R.id.expand_button);
        mIcon = findViewById(com.android.internal.R.id.icon);
        mChildCount = (TextView) findViewById(com.android.internal.R.id.number_of_children);
    }

    @Override
@@ -132,6 +135,17 @@ public class NotificationHeaderView extends LinearLayout {
        updateTouchListener();
    }

    public void setChildCount(int childCount) {
        if (childCount > 0) {
            mChildCount.setText(getContext().getString(
                    com.android.internal.R.string.notification_children_count_bracketed,
                    childCount));
            mChildCount.setVisibility(VISIBLE);
        } else {
            mChildCount.setVisibility(GONE);
        }
    }

    public class HeaderTouchListener implements View.OnTouchListener {

        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
+3 −0
Original line number Diff line number Diff line
@@ -531,6 +531,9 @@
         [CHAR LIMIT=4] -->
    <string name="status_bar_notification_info_overflow">999+</string>

    <!-- The number of notifications in the notification header. An example would be (2) or (12) -->
    <string name="notification_children_count_bracketed">(<xliff:g id="notificationCount" example="1">%d</xliff:g>)</string>

    <!-- The divider symbol between different parts of the notification header. not translatable [CHAR LIMIT=1] -->
    <string name="notification_header_divider_symbol" translatable="false"></string>

+2 −0
Original line number Diff line number Diff line
@@ -2345,6 +2345,7 @@
  <java-symbol type="id" name="addToDictionaryButton" />
  <java-symbol type="id" name="deleteButton" />

  <java-symbol type="string" name="notification_children_count_bracketed" />
  <java-symbol type="id" name="app_name_text" />
  <java-symbol type="id" name="number_of_children" />
  <java-symbol type="id" name="header_sub_text" />
@@ -2356,6 +2357,7 @@
  <java-symbol type="id" name="content_info_divider" />
  <java-symbol type="id" name="text_line_1" />
  <java-symbol type="drawable" name="ic_arrow_up_14dp" />
  <java-symbol type="dimen" name="notification_header_height" />
  <java-symbol type="dimen" name="notification_big_picture_content_min_height_with_picture" />
  <java-symbol type="dimen" name="notification_header_shrink_min_width" />
  <java-symbol type="dimen" name="notification_content_margin_start" />
+0 −83
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2015 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<com.android.systemui.statusbar.notification.NotificationHeaderView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/notification_header_height"
    android:clipChildren="false">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/notification_header_height"
        android:layout_gravity="start"
        android:gravity="center_vertical"
        android:paddingStart="@dimen/notification_content_margin_start">
        <ImageView
            android:id="@+id/header_notification_icon"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_marginEnd="4dp"
            />
        <TextView
            android:id="@+id/number_of_children"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@*android:style/TextAppearance.Material.Notification"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="1dp"
            />
        <TextView
            android:id="@+id/app_name_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.Material.Notification.HeaderTitle"
            android:layout_marginStart="4dp"
            android:layout_marginEnd="8dp"
            />
        <TextView
            android:id="@+id/app_title_sub_text_divider"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.Material.Notification.HeaderTitle"
            android:layout_marginEnd="8dp"
            android:text="@string/notification_header_divider_symbol"/>
        <TextView
            android:id="@+id/title_sub_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.Material.Notification.HeaderTitle"
            android:layout_marginEnd="8dp" />
        <TextView
            android:id="@+id/post_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|center_vertical"
            android:textAppearance="@*android:style/TextAppearance.Material.Notification.Time"
            android:paddingEnd="8dp"
            />
    </LinearLayout>
    <ImageButton
        android:id="@+id/notification_expand_button"
        android:background="@null"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_gravity="end|center_vertical"
        android:src="@drawable/notification_expand_more"
        android:layout_marginEnd="8dp"
        />
</com.android.systemui.statusbar.notification.NotificationHeaderView>
Loading