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

Commit 50123ff5 authored by Valentin Iftime's avatar Valentin Iftime
Browse files

Affordance view for notification summaries and bundles onboarding

 Add layout, view and strings.

Flag: android.app.nm_summarization_onboarding_ui
Test: tbd
Bug: 391568054
Change-Id: Ib4431ce965e32ec3c34c0d73130decd73e254b49
parent d3680bf4
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="32dp"
    android:height="32dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <group>
        <clip-path
            android:pathData="M0,0h24v24h-24z"/>
        <path
            android:pathData="M12,22C11.45,22 10.975,21.808 10.575,21.425C10.192,21.025 10,20.55 10,20H14C14,20.55 13.8,21.025 13.4,21.425C13.017,21.808 12.55,22 12,22ZM8,19V17H16V19H8ZM8.25,16C7.1,15.317 6.183,14.4 5.5,13.25C4.833,12.1 4.5,10.85 4.5,9.5C4.5,7.417 5.225,5.65 6.675,4.2C8.142,2.733 9.917,2 12,2C14.083,2 15.85,2.733 17.3,4.2C18.767,5.65 19.5,7.417 19.5,9.5C19.5,10.85 19.158,12.1 18.475,13.25C17.808,14.4 16.9,15.317 15.75,16H8.25Z"
            android:fillColor="#ffffff"/>
    </group>
</vector>
+103 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2025 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
  -->

<!-- Extends FrameLayout -->
<com.android.systemui.statusbar.notification.stack.OnboardingAffordanceView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="8dp"
    android:background="@drawable/rounded_bg_full"
    android:backgroundTint="@androidprv:color/materialColorTertiaryFixed">

  <LinearLayout
      android:id="@+id/content"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:clipChildren="false"
      android:forceHasOverlappingRendering="false"
      android:gravity="center_vertical"
      android:orientation="vertical"
      android:padding="16dp">

    <LinearLayout
        android:id="@+id/row1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:clipChildren="false"
        android:forceHasOverlappingRendering="false"
        android:gravity="center"
        android:orientation="horizontal">
          <ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:paddingRight="16dp"
              android:src="@drawable/ic_lightbulb"
              android:tint="@androidprv:color/materialColorOnTertiaryFixed" />

          <TextView
              android:id="@+id/message"
              android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:focusable="true"
              android:forceHasOverlappingRendering="false"
              android:text="@string/notification_onboarding_summaries_message"
              android:textColor="@androidprv:color/materialColorOnTertiaryFixed" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/row2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:clipChildren="false"
        android:forceHasOverlappingRendering="false"
        android:gravity="end"
        android:orientation="horizontal">
          <TextView
              android:id="@+id/btn_turn_on"
              style="@*android:style/Widget.DeviceDefault.Notification.Text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:focusable="true"
              android:forceHasOverlappingRendering="false"
              android:paddingHorizontal="16dp"
              android:paddingTop="10dp"
              android:paddingBottom="4dp"
              android:text="@string/notification_onboarding_summaries_turn_on"
              android:textColor="@androidprv:color/materialColorOnTertiaryFixedVariant" />
          <TextView
              android:id="@+id/btn_dismiss"
              style="@*android:style/Widget.DeviceDefault.Notification.Text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:focusable="true"
              android:forceHasOverlappingRendering="false"
              android:paddingHorizontal="16dp"
              android:paddingTop="10dp"
              android:paddingBottom="4dp"
              android:text="@string/got_it"
              android:textColor="@androidprv:color/materialColorOnTertiaryFixedVariant" />
    </LinearLayout>

  </LinearLayout>

</com.android.systemui.statusbar.notification.stack.OnboardingAffordanceView>
+6 −0
Original line number Diff line number Diff line
@@ -2123,6 +2123,12 @@
    <!-- [CHAR LIMIT=100] Notification bundle inline settings summary -->
    <string name="notification_guts_recs_summary">Newsletters, recommended media, and more</string>

    <!-- Battery saver confirmation dialog ok text [CHAR LIMIT=40]-->
    <string name="notification_onboarding_summaries_turn_on">Turn on</string>

    <!-- Battery saver confirmation dialog ok text [CHAR LIMIT=NONE]-->
    <string name="notification_onboarding_summaries_message">Your longer conversations can now be summarized to give you quick recaps</string>

    <!-- Notification Inline controls: button to dismiss the blocking helper [CHAR_LIMIT=20] -->
    <string name="inline_done_button">Done</string>

+117 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

package com.android.systemui.statusbar.notification.stack;

import android.annotation.Nullable;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.systemui.res.R;
import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;

/**
 * Affordance view for notification summaries and bundles onboarding
 */
public class OnboardingAffordanceView extends StackScrollerDecorView {

    private ViewGroup mContents;
    private TextView mTurnOnButton;
    private TextView mDismissButton;
    @Nullable private View.OnClickListener mTurnOnClickListener = null;
    @Nullable private View.OnClickListener mOnDismissClickListener = null;

    public OnboardingAffordanceView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        mContents = requireViewById(R.id.content);
        bindContents();
        super.onFinishInflate();
        setVisible(true /* visible */, false /* animate */);
    }

    private void bindContents() {
        mDismissButton = requireViewById(R.id.btn_dismiss);
        if (mOnDismissClickListener != null) {
            mDismissButton.setOnClickListener(mOnDismissClickListener);
        }
        mTurnOnButton = requireViewById(R.id.btn_turn_on);
        if (mTurnOnClickListener != null) {
            mTurnOnButton.setOnClickListener(mTurnOnClickListener);
        }
    }

    @Override
    protected View findContentView() {
        return mContents;
    }

    @Override
    protected View findSecondaryView() {
        return null;
    }

    @Override
    public boolean isTransparent() {
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return super.onInterceptTouchEvent(ev);
    }


    @Override
    protected void applyContentTransformation(float contentAlpha, float translationY) {
        super.applyContentTransformation(contentAlpha, translationY);
        mDismissButton.setAlpha(contentAlpha);
        mDismissButton.setTranslationY(translationY);
        mTurnOnButton.setAlpha(contentAlpha);
        mTurnOnButton.setTranslationY(translationY);
    }

    /**
     * Click listener for "Got it" button
     * @param listener click listener
     */
    public void setOnDismissClickListener(View.OnClickListener listener) {
        mOnDismissClickListener = listener;
        mDismissButton.setOnClickListener(listener);
    }

    /**
     * Click listener for "Turn on" button
     * @param listener click listener
     */
    public void setOnTurnOnClickListener(View.OnClickListener listener) {
        mTurnOnClickListener = listener;
        mTurnOnButton.setOnClickListener(listener);
    }

    @Override
    public boolean needsClippingToShelf() {
        return true;
    }

}