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

Commit 32f6df1d authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Adds DismissCircleView, a shared dismiss target for Bubbles/PIP. am: cfbf88c2 am: 9c869b2b

Change-Id: Id953f00eca6e8de2f2b88aedc2c3cbc499a7abf2
parents 21688558 9c869b2b
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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.
  -->

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <stroke
        android:width="1dp"
        android:color="#66FFFFFF" />

    <solid android:color="#B3000000" />

</shape>
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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.
  -->

<!-- 'X' icon. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24.0dp"
        android:height="24.0dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M19.000000,6.400000l-1.400000,-1.400000 -5.600000,5.600000 -5.600000,-5.600000 -1.400000,1.400000 5.600000,5.600000 -5.600000,5.600000 1.400000,1.400000 5.600000,-5.600000 5.600000,5.600000 1.400000,-1.400000 -5.600000,-5.600000z"
        android:fillColor="#FFFFFFFF"
        android:strokeColor="#FF000000"/>
</vector>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -1183,6 +1183,9 @@
    <dimen name="bubble_dismiss_target_padding_x">40dp</dimen>
    <dimen name="bubble_dismiss_target_padding_y">20dp</dimen>

    <dimen name="dismiss_circle_size">52dp</dimen>
    <dimen name="dismiss_target_x_size">24dp</dimen>

    <!-- Bubbles user education views -->
    <dimen name="bubbles_manage_education_width">160dp</dimen>
    <!-- The inset from the top bound of the manage button to place the user education. -->
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.util;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.android.systemui.R;

/**
 * Circular view with a semitransparent, circular background with an 'X' inside it.
 *
 * This is used by both Bubbles and PIP as the dismiss target.
 */
public class DismissCircleView extends FrameLayout {

    private final ImageView mIconView = new ImageView(getContext());

    public DismissCircleView(Context context) {
        super(context);
        final Resources res = getResources();

        setBackground(res.getDrawable(R.drawable.dismiss_circle_background));

        mIconView.setImageDrawable(res.getDrawable(R.drawable.dismiss_target_x));
        addView(mIconView);

        setViewSizes();
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        setViewSizes();
    }

    /** Retrieves the current dimensions for the icon and circle and applies them. */
    private void setViewSizes() {
        final Resources res = getResources();

        int iconSize = res.getDimensionPixelSize(R.dimen.dismiss_target_x_size);
        int targetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size);

        setLayoutParams(new ViewGroup.LayoutParams(targetSize, targetSize));

        mIconView.setLayoutParams(
                new FrameLayout.LayoutParams(iconSize, iconSize, Gravity.CENTER));
    }
}