Add a triangluar pointer to indicate the currently expanded bubble
Introduces BubbleExpandedViewContainer to wrap the currently expanded view and render the triangle * This view should also handle rendering the header * ActivityView will live here too eventually maybe Test: visual - enable bubbles, open a bubble, note the pointer Bug: 111236845 Change-Id: I49569a0355eab29c9f1b6bb9abe1cd2d10b9b27b
This commit is contained in:
30
packages/SystemUI/res/layout/bubble_expanded_view.xml
Normal file
30
packages/SystemUI/res/layout/bubble_expanded_view.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2018 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.bubbles.BubbleExpandedViewContainer
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/bubble_expanded_view">
|
||||
|
||||
<!-- TODO: header -->
|
||||
|
||||
<View
|
||||
android:id="@+id/pointer_view"
|
||||
android:layout_width="@dimen/bubble_pointer_width"
|
||||
android:layout_height="@dimen/bubble_pointer_height"
|
||||
/>
|
||||
</com.android.systemui.bubbles.BubbleExpandedViewContainer>
|
||||
@@ -991,4 +991,8 @@
|
||||
<dimen name="bubble_icon_size">24dp</dimen>
|
||||
<!-- Default height of the expanded view shown when the bubble is expanded -->
|
||||
<dimen name="bubble_expanded_default_height">400dp</dimen>
|
||||
<!-- Height of the triangle that points to the expanded bubble -->
|
||||
<dimen name="bubble_pointer_height">4dp</dimen>
|
||||
<!-- Width of the triangle that points to the expanded bubble -->
|
||||
<dimen name="bubble_pointer_width">6dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.bubbles;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.recents.TriangleShape;
|
||||
|
||||
/**
|
||||
* Container for the expanded bubble view, handles rendering the caret and header of the view.
|
||||
*/
|
||||
public class BubbleExpandedViewContainer extends LinearLayout {
|
||||
|
||||
// The triangle pointing to the expanded view
|
||||
private View mPointerView;
|
||||
// The view that is being displayed for the expanded state
|
||||
private View mExpandedView;
|
||||
|
||||
public BubbleExpandedViewContainer(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BubbleExpandedViewContainer(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public BubbleExpandedViewContainer(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public BubbleExpandedViewContainer(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
setOrientation(VERTICAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
Resources res = getResources();
|
||||
mPointerView = findViewById(R.id.pointer_view);
|
||||
int width = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
|
||||
int height = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);
|
||||
ShapeDrawable triangleDrawable = new ShapeDrawable(
|
||||
TriangleShape.create(width, height, true /* pointUp */));
|
||||
triangleDrawable.setTint(Color.WHITE); // TODO: dark mode
|
||||
mPointerView.setBackground(triangleDrawable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x position that the tip of the triangle should point to.
|
||||
*/
|
||||
public void setPointerPosition(int x) {
|
||||
// Adjust for the pointer size
|
||||
x -= (mPointerView.getWidth() / 2);
|
||||
mPointerView.setTranslationX(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view to display for the expanded state. Passing null will clear the view.
|
||||
*/
|
||||
public void setExpandedView(View view) {
|
||||
if (mExpandedView != null) {
|
||||
removeView(mExpandedView);
|
||||
}
|
||||
mExpandedView = view;
|
||||
if (mExpandedView != null) {
|
||||
addView(mExpandedView);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the view containing the expanded content, can be null.
|
||||
*/
|
||||
@Nullable
|
||||
public View getExpandedView() {
|
||||
return mExpandedView;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.RectF;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -52,7 +53,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
|
||||
private Point mDisplaySize;
|
||||
|
||||
private FrameLayout mBubbleContainer;
|
||||
private FrameLayout mExpandedViewContainer;
|
||||
private BubbleExpandedViewContainer mExpandedViewContainer;
|
||||
|
||||
private int mBubbleSize;
|
||||
private int mBubblePadding;
|
||||
@@ -111,7 +112,9 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
|
||||
|
||||
int padding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding);
|
||||
int elevation = res.getDimensionPixelSize(R.dimen.bubble_elevation);
|
||||
mExpandedViewContainer = new FrameLayout(context);
|
||||
mExpandedViewContainer = (BubbleExpandedViewContainer)
|
||||
LayoutInflater.from(context).inflate(R.layout.bubble_expanded_view,
|
||||
this /* parent */, false /* attachToRoot */);
|
||||
mExpandedViewContainer.setElevation(elevation);
|
||||
mExpandedViewContainer.setPadding(padding, padding, padding, padding);
|
||||
mExpandedViewContainer.setClipChildren(false);
|
||||
@@ -390,16 +393,19 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
|
||||
ExpandableNotificationRow row = mExpandedBubble.getRowView();
|
||||
if (!row.equals(mExpandedViewContainer.getChildAt(0))) {
|
||||
// Different expanded view than what we have
|
||||
mExpandedViewContainer.removeAllViews();
|
||||
mExpandedViewContainer.setExpandedView(null);
|
||||
}
|
||||
mExpandedViewContainer.addView(row);
|
||||
int pointerPosition = mExpandedBubble.getPosition().x
|
||||
+ (mExpandedBubble.getWidth() / 2);
|
||||
mExpandedViewContainer.setPointerPosition(pointerPosition);
|
||||
mExpandedViewContainer.setExpandedView(row);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyCurrentState() {
|
||||
mExpandedViewContainer.setVisibility(mIsExpanded ? VISIBLE : GONE);
|
||||
if (!mIsExpanded) {
|
||||
mExpandedViewContainer.removeAllViews();
|
||||
mExpandedViewContainer.setExpandedView(null);
|
||||
} else {
|
||||
mExpandedViewContainer.setTranslationY(mBubbleContainer.getHeight());
|
||||
ExpandableNotificationRow row = mExpandedBubble.getRowView();
|
||||
|
||||
Reference in New Issue
Block a user