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

Commit 310c7c60 authored by Mady Mellor's avatar Mady Mellor
Browse files

Some visual fixes for when header is in footer position + proper radius

* Uses the radius value from the theme
* Applies that to the header / permission viewWrapper based on orientation
  of the bubbles
* Also swaps position of the divider when its a footer

Test: manual / visual
      - toggle bubbles to show at bottom with a footer and make sure
        rounded corners are in right place

Change-Id: Ieb6db4aedfda125ddf590876aa8b0ee0ee7fc473
parent aab81fa8
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
<?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
  -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="?android:attr/colorBackgroundFloating"/>
            <corners
                    android:topLeftRadius="@dimen/corner_size"
                    android:topRightRadius="@dimen/corner_size"/>
        </shape>
    </item>
</layer-list>
 No newline at end of file
+2 −3
Original line number Diff line number Diff line
@@ -29,10 +29,9 @@

    <FrameLayout
        android:id="@+id/header_permission_wrapper"
        android:layout_width="wrap_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        android:background="@drawable/bubble_expanded_header_bg">
        android:animateLayoutChanges="true">

        <LinearLayout
            android:id="@+id/header_layout"
+26 −0
Original line number Diff line number Diff line
@@ -39,6 +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;
@@ -189,6 +190,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        mPointerView.setBackground(triangleDrawable);

        FrameLayout viewWrapper = findViewById(R.id.header_permission_wrapper);
        viewWrapper.setBackground(createHeaderPermissionBackground(bgColor));

        LayoutTransition transition = new LayoutTransition();
        transition.setDuration(200);

@@ -204,6 +207,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        viewWrapper.setLayoutTransition(transition);
        viewWrapper.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);


        mHeaderHeight = getContext().getResources().getDimensionPixelSize(
                R.dimen.bubble_expanded_header_height);
        mPermissionHeight = getContext().getResources().getDimensionPixelSize(
@@ -243,13 +247,35 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        if (!mShowOnTop) {
            removeView(mPointerView);
            if (mUseFooter) {
                View divider = findViewById(R.id.divider);
                viewWrapper.removeView(divider);
                removeView(viewWrapper);
                addView(divider);
                addView(viewWrapper);
            }
            addView(mPointerView);
        }
    }

    /**
     * Creates a background with corners rounded based on how the view is configured to display
     */
    private Drawable createHeaderPermissionBackground(int bgColor) {
        TypedArray ta2 = getContext().obtainStyledAttributes(
                new int[] {android.R.attr.dialogCornerRadius});
        final float cr = ta2.getDimension(0, 0f);
        ta2.recycle();

        float[] radii = mUseFooter
                ? new float[] {0, 0, 0, 0, cr, cr, cr, cr}
                : 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.
     */