Remove bubble permission view

Bug: 131630936
Test: manual
Change-Id: I4023b3a32770fe42d67dd907d6c7a570d41583ee
This commit is contained in:
Lyn Han
2019-04-30 12:03:12 -07:00
parent d20d4b1d65
commit 6914912842
4 changed files with 12 additions and 241 deletions

View File

@@ -27,35 +27,14 @@
android:layout_height="@dimen/bubble_pointer_height"
/>
<FrameLayout
android:id="@+id/permission_or_settings"
android:layout_width="match_parent"
<com.android.systemui.statusbar.AlphaOptimizedButton
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/settings_button"
android:layout_gravity="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<com.android.systemui.statusbar.AlphaOptimizedButton
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/settings_button"
android:layout_gravity="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:text="@string/manage_bubbles_text"
android:textColor="?attr/wallpaperTextColor"/>
<include layout="@layout/bubble_permission_view"
android:id="@+id/permission_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="?android:attr/dividerHorizontal"/>
</FrameLayout>
android:focusable="true"
android:text="@string/manage_bubbles_text"
android:textColor="?attr/wallpaperTextColor"/>
</com.android.systemui.bubbles.BubbleExpandedView>

View File

@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019, 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/bubble_permission_height"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingStart="@dimen/bubble_expanded_header_horizontal_padding"
android:paddingEnd="@dimen/bubble_expanded_header_horizontal_padding">
<!-- App info -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/bubble_expanded_header_horizontal_padding" >
<ImageView
android:id="@+id/pkgicon"
android:layout_width="@dimen/bubble_permission_icon_size"
android:layout_height="@dimen/bubble_permission_icon_size"
android:layout_centerVertical="true"
android:layout_marginEnd="3dp"
/>
<TextView
android:id="@+id/pkgname"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="@*android:style/TextAppearance.Material.Body2"
android:layout_marginStart="3dp"
android:layout_marginEnd="2dp"
android:singleLine="true"
android:gravity="center_vertical"
android:layout_centerVertical="true"
/>
</LinearLayout>
<!-- Actual permission -->
<TextView
android:id="@+id/prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/bubbles_prompt"
style="@*android:style/TextAppearance.DeviceDefault.Notification.Title"/>
<!-- Buttons -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal">
<TextView
android:id="@+id/no_bubbles_button"
android:text="@string/no_bubbles"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/ripple_drawable"
style="@style/TextAppearance.NotificationInfo.Button"/>
<TextView
android:id="@+id/yes_bubbles_button"
android:text="@string/yes_bubbles"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/ripple_drawable"
style="@style/TextAppearance.NotificationInfo.Button"/>
</LinearLayout>
</LinearLayout>

View File

@@ -1123,12 +1123,8 @@
<dimen name="bubble_stack_starting_offset_y">100dp</dimen>
<!-- Size of image buttons in the bubble header -->
<dimen name="bubble_header_icon_size">48dp</dimen>
<!-- Size of the app icon shown in the bubble permission view -->
<dimen name="bubble_permission_icon_size">24dp</dimen>
<!-- Space between the pointer triangle and the bubble expanded view -->
<dimen name="bubble_pointer_margin">8dp</dimen>
<!-- Height of the permission prompt shown with bubbles -->
<dimen name="bubble_permission_height">120dp</dimen>
<!-- Size of the RAT type for CellularTile -->
<dimen name="celltile_rat_type_size">10sp</dimen>

View File

@@ -22,8 +22,6 @@ import static android.util.StatsLogInternal.BUBBLE_DEVELOPER_ERROR_REPORTED__ERR
import static android.util.StatsLogInternal.BUBBLE_DEVELOPER_ERROR_REPORTED__ERROR__DOCUMENT_LAUNCH_NOT_ALWAYS;
import static android.view.Display.INVALID_DISPLAY;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.ActivityView;
@@ -41,9 +39,7 @@ import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
@@ -54,13 +50,9 @@ import android.util.StatsLog;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.recents.TriangleShape;
import com.android.systemui.statusbar.AlphaOptimizedButton;
@@ -80,10 +72,6 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
private AlphaOptimizedButton mSettingsIcon;
// Permission view
private View mPermissionView;
private TextView mPermissionPrompt;
// Views for expanded state
private ExpandableNotificationRow mNotifRow;
private ActivityView mActivityView;
@@ -97,7 +85,6 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
private int mMinHeight;
private int mSettingsIconHeight;
private int mBubbleHeight;
private int mPermissionHeight;
private int mPointerWidth;
private int mPointerHeight;
@@ -194,36 +181,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
triangleDrawable.setTint(bgColor);
mPointerView.setBackground(triangleDrawable);
FrameLayout permissionOrSettings = findViewById(R.id.permission_or_settings);
LayoutTransition transition = new LayoutTransition();
transition.setDuration(200);
ObjectAnimator appearAnimator = ObjectAnimator.ofFloat(null, View.ALPHA, 0f, 1f);
transition.setAnimator(LayoutTransition.APPEARING, appearAnimator);
transition.setInterpolator(LayoutTransition.APPEARING, Interpolators.ALPHA_IN);
ObjectAnimator disappearAnimator = ObjectAnimator.ofFloat(null, View.ALPHA, 1f, 0f);
transition.setAnimator(LayoutTransition.DISAPPEARING, disappearAnimator);
transition.setInterpolator(LayoutTransition.DISAPPEARING, Interpolators.ALPHA_OUT);
transition.setAnimateParentHierarchy(false);
permissionOrSettings.setLayoutTransition(transition);
permissionOrSettings.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
mSettingsIconHeight = getContext().getResources().getDimensionPixelSize(
R.dimen.bubble_expanded_header_height);
mSettingsIcon = findViewById(R.id.settings_button);
mSettingsIcon.setOnClickListener(this);
mPermissionHeight = getContext().getResources().getDimensionPixelSize(
R.dimen.bubble_permission_height);
mPermissionView = findViewById(R.id.permission_layout);
mPermissionPrompt = mPermissionView.findViewById(R.id.prompt);
findViewById(R.id.no_bubbles_button).setOnClickListener(this);
findViewById(R.id.yes_bubbles_button).setOnClickListener(this);
mActivityView = new ActivityView(mContext, null /* attrs */, 0 /* defStyle */,
true /* singleTaskInstance */);
addView(mActivityView);
@@ -272,23 +234,6 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
}
}
/**
* Creates a background with corners rounded based on how the view is configured to display
*/
private Drawable createPermissionBackground(int bgColor) {
TypedArray ta2 = getContext().obtainStyledAttributes(
new int[] {android.R.attr.dialogCornerRadius});
final float cr = ta2.getDimension(0, 0f);
ta2.recycle();
float[] radii = new float[] {cr, cr, cr, cr, 0, 0, 0, 0};
GradientDrawable chromeBackground = new GradientDrawable();
chromeBackground.setShape(GradientDrawable.RECTANGLE);
chromeBackground.setCornerRadii(radii);
chromeBackground.setColor(bgColor);
return chromeBackground;
}
/**
* Sets the listener to notify when a bubble has been blocked.
*/
@@ -323,7 +268,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
mAppIcon = mPm.getDefaultActivityIcon();
}
updateTheme();
togglePermissionOrSettings();
showSettingsIcon();
updateExpandedView();
}
@@ -370,10 +315,6 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
int foregroundColor = ta.getColor(1, Color.BLACK /* default */);
ta.recycle();
// Update permission prompt color.
mPermissionView.setBackground(createPermissionBackground(backgroundColor));
mPermissionPrompt.setTextColor(foregroundColor);
// Update triangle color.
ShapeDrawable triangleDrawable = new ShapeDrawable(
TriangleShape.create(mPointerWidth, mPointerHeight, false /* pointUp */));
@@ -381,22 +322,6 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
mPointerView.setBackground(triangleDrawable);
}
void togglePermissionOrSettings() {
boolean hasUserApprovedBubblesForPackage = false;
try {
hasUserApprovedBubblesForPackage =
mNotificationManagerService.hasUserApprovedBubblesForPackage(
mEntry.notification.getPackageName(), mEntry.notification.getUid());
} catch (RemoteException e) {
Log.w(TAG, e);
}
if (hasUserApprovedBubblesForPackage) {
showSettingsIcon();
} else {
showPermissionView();
}
}
private void updateExpandedView() {
mBubbleIntent = getBubbleIntent(mEntry);
if (mBubbleIntent != null) {
@@ -427,11 +352,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
* @return total height that the expanded view occupies.
*/
int getExpandedSize() {
int chromeHeight = mPermissionView.getVisibility() != View.VISIBLE
? mSettingsIconHeight
: mPermissionHeight;
return mBubbleHeight + mPointerView.getHeight() + mPointerMargin
+ chromeHeight;
+ mSettingsIconHeight;
}
void updateHeight() {
@@ -455,11 +377,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
}
desiredHeight = desiredPx > 0 ? desiredPx : mMinHeight;
}
int chromeHeight = mPermissionView.getVisibility() != View.VISIBLE
? mSettingsIconHeight
: mPermissionHeight;
int max = mStackView.getMaxExpandedHeight() - chromeHeight - mPointerView.getHeight()
- mPointerMargin;
int max = mStackView.getMaxExpandedHeight() - mSettingsIconHeight
- mPointerView.getHeight() - mPointerMargin;
float height = Math.min(desiredHeight, max);
height = Math.max(height, mMinHeight);
LayoutParams lp = (LayoutParams) mActivityView.getLayoutParams();
@@ -492,30 +411,6 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
logBubbleClickEvent(mEntry,
StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
});
} else if (id == R.id.no_bubbles_button) {
setBubblesAllowed(false);
} else if (id == R.id.yes_bubbles_button) {
setBubblesAllowed(true);
}
}
private void setBubblesAllowed(boolean allowed) {
try {
mNotificationManagerService.setBubblesAllowed(
mEntry.notification.getPackageName(),
mEntry.notification.getUid(),
allowed);
if (allowed) {
showSettingsIcon();
} else if (mOnBubbleBlockedListener != null) {
mOnBubbleBlockedListener.onBubbleBlocked(mEntry);
}
mStackView.onExpandedHeightChanged();
logBubbleClickEvent(mEntry,
allowed ? StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_IN :
StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_OUT);
} catch (RemoteException e) {
Log.w(TAG, e);
}
}
@@ -526,23 +421,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
void showSettingsIcon() {
updateSettingsContentDescription();
mPermissionView.setVisibility(GONE);
mSettingsIcon.setVisibility(VISIBLE);
}
void showPermissionView() {
((ImageView) mPermissionView.findViewById(R.id.pkgicon)).setImageDrawable(mAppIcon);
((TextView) mPermissionView.findViewById(R.id.pkgname)).setText(mAppName);
mPermissionPrompt.setText(
getResources().getString(R.string.bubbles_prompt, mAppName));
logBubbleClickEvent(mEntry,
StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_DIALOG_SHOWN);
mSettingsIcon.setVisibility(GONE);
mPermissionView.setVisibility(VISIBLE);
}
/**
* Update appearance of the expanded view being displayed.
*/