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

Commit e1d2a833 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Remove obsolete screenshot action chip class

Bug: 329659738
Test: manual, atest
Flag: EXEMPT removing unused code

Change-Id: I5712b1021a8235ef57d535defd00e55a7eea1288
parent 9cda256f
Loading
Loading
Loading
Loading
+0 −47
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 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.
  -->
<com.android.systemui.screenshot.OverlayActionChip
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:id="@+id/overlay_action_chip"
    android:theme="@style/FloatingOverlay"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/overlay_action_chip_margin_start"
    android:layout_gravity="center"
    android:gravity="center"
    android:alpha="0.0">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingVertical="@dimen/overlay_action_chip_padding_vertical"
        android:background="@drawable/action_chip_background"
        android:gravity="center">
        <ImageView
            android:id="@+id/overlay_action_chip_icon"
            android:tint="?androidprv:attr/materialColorOnSecondary"
            android:layout_width="@dimen/overlay_action_chip_icon_size"
            android:layout_height="@dimen/overlay_action_chip_icon_size"/>
        <TextView
            android:id="@+id/overlay_action_chip_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
            android:textSize="@dimen/overlay_action_chip_text_size"
            android:textColor="?androidprv:attr/materialColorOnSecondary"/>
    </LinearLayout>
</com.android.systemui.screenshot.OverlayActionChip>
+0 −162
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.
  -->
<com.android.systemui.screenshot.DraggableConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:id="@+id/actions_container_background"
        android:visibility="gone"
        android:layout_height="0dp"
        android:layout_width="0dp"
        android:elevation="4dp"
        android:background="@drawable/action_chip_container_background"
        android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
        android:layout_marginBottom="@dimen/overlay_action_container_margin_bottom"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/actions_container"
        app:layout_constraintEnd_toEndOf="@+id/actions_container"
        app:layout_constraintBottom_toTopOf="@id/guideline"/>
    <HorizontalScrollView
        android:id="@+id/actions_container"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/overlay_action_container_margin_horizontal"
        android:paddingEnd="@dimen/overlay_action_container_padding_end"
        android:paddingVertical="@dimen/overlay_action_container_padding_vertical"
        android:elevation="4dp"
        android:scrollbars="none"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintWidth_percent="1.0"
        app:layout_constraintWidth_max="wrap"
        app:layout_constraintStart_toEndOf="@+id/screenshot_preview_border"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="@id/actions_container_background">
        <LinearLayout
            android:id="@+id/screenshot_actions"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <include layout="@layout/overlay_action_chip"
                     android:id="@+id/screenshot_share_chip"/>
            <include layout="@layout/overlay_action_chip"
                     android:id="@+id/screenshot_edit_chip"/>
            <include layout="@layout/overlay_action_chip"
                     android:id="@+id/screenshot_scroll_chip"
                     android:visibility="gone" />
        </LinearLayout>
    </HorizontalScrollView>
    <View
        android:id="@+id/screenshot_preview_border"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="@dimen/overlay_preview_container_margin"
        android:layout_marginTop="@dimen/overlay_border_width_neg"
        android:layout_marginEnd="@dimen/overlay_border_width_neg"
        android:layout_marginBottom="@dimen/overlay_preview_container_margin"
        android:elevation="8dp"
        android:alpha="0"
        android:background="@drawable/overlay_border"
        app:layout_constraintStart_toStartOf="@id/actions_container_background"
        app:layout_constraintTop_toTopOf="@id/screenshot_preview"
        app:layout_constraintEnd_toEndOf="@id/screenshot_preview"
        app:layout_constraintBottom_toBottomOf="@id/actions_container_background"/>
    <ImageView
        android:id="@+id/screenshot_preview"
        android:visibility="invisible"
        android:layout_width="@dimen/overlay_x_scale"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/overlay_border_width"
        android:layout_marginBottom="@dimen/overlay_border_width"
        android:layout_gravity="center"
        android:elevation="8dp"
        android:contentDescription="@string/screenshot_edit_description"
        android:scaleType="fitEnd"
        android:background="@drawable/overlay_preview_background"
        android:adjustViewBounds="true"
        android:clickable="true"
        app:layout_constraintStart_toStartOf="@id/screenshot_preview_border"
        app:layout_constraintBottom_toBottomOf="@id/screenshot_preview_border"/>
    <ImageView
        android:id="@+id/screenshot_badge"
        android:layout_width="56dp"
        android:layout_height="56dp"
        android:visibility="gone"
        android:elevation="9dp"
        app:layout_constraintBottom_toBottomOf="@id/screenshot_preview_border"
        app:layout_constraintEnd_toEndOf="@id/screenshot_preview_border"/>
    <FrameLayout
        android:id="@+id/screenshot_dismiss_button"
        android:layout_width="@dimen/overlay_dismiss_button_tappable_size"
        android:layout_height="@dimen/overlay_dismiss_button_tappable_size"
        android:elevation="11dp"
        android:visibility="gone"
        app:layout_constraintStart_toEndOf="@id/screenshot_preview"
        app:layout_constraintEnd_toEndOf="@id/screenshot_preview"
        app:layout_constraintTop_toTopOf="@id/screenshot_preview"
        app:layout_constraintBottom_toTopOf="@id/screenshot_preview"
        android:contentDescription="@string/screenshot_dismiss_description">
        <ImageView
            android:id="@+id/screenshot_dismiss_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/overlay_dismiss_button_margin"
            android:background="@drawable/circular_background"
            android:backgroundTint="?androidprv:attr/materialColorPrimary"
            android:tint="?androidprv:attr/materialColorOnPrimary"
            android:padding="4dp"
            android:src="@drawable/ic_close"/>
    </FrameLayout>
    <ImageView
        android:id="@+id/screenshot_scrollable_preview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="matrix"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="@id/screenshot_preview"
        app:layout_constraintTop_toTopOf="@id/screenshot_preview"
        android:elevation="7dp"/>

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_end="0dp" />

    <FrameLayout
        android:id="@+id/screenshot_message_container"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="@dimen/overlay_action_container_margin_horizontal"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="@dimen/overlay_action_container_margin_bottom"
        android:paddingHorizontal="@dimen/overlay_action_container_padding_end"
        android:paddingVertical="@dimen/overlay_action_container_padding_vertical"
        android:elevation="4dp"
        android:background="@drawable/action_chip_container_background"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@id/guideline"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintWidth_max="450dp"
        app:layout_constraintHorizontal_bias="0">
        <include layout="@layout/screenshot_work_profile_first_run" />
        <include layout="@layout/screenshot_detection_notice" />
    </FrameLayout>
</com.android.systemui.screenshot.DraggableConstraintLayout>
+0 −0

File moved.

+0 −144
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.screenshot;

import static java.util.Objects.requireNonNull;

import android.app.ActivityOptions;
import android.app.BroadcastOptions;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.drawable.Icon;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.systemui.res.R;

/**
 * View for a chip with an icon and text.
 */
public class OverlayActionChip extends FrameLayout {

    private static final String TAG = "ScreenshotActionChip";

    private ImageView mIconView;
    private TextView mTextView;
    private boolean mIsPending = false;

    public OverlayActionChip(Context context) {
        this(context, null);
    }

    public OverlayActionChip(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public OverlayActionChip(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public OverlayActionChip(
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onFinishInflate() {
        mIconView = requireNonNull(findViewById(R.id.overlay_action_chip_icon));
        mTextView = requireNonNull(findViewById(R.id.overlay_action_chip_text));
        updatePadding(mTextView.getText().length() > 0);
    }

    @Override
    public void setPressed(boolean pressed) {
        // override pressed state to true if there is an action pending
        super.setPressed(mIsPending || pressed);
    }

    /**
     * Set chip icon and whether to tint with theme color
     */
    public void setIcon(Icon icon, boolean tint) {
        mIconView.setImageIcon(icon);
        if (!tint) {
            mIconView.setImageTintList(null);
        }
    }

    /**
     * Set chip text
     */
    public void setText(CharSequence text) {
        mTextView.setText(text);
        updatePadding(text.length() > 0);
    }

    /**
     * Set PendingIntent to be sent and Runnable to be run, when chip is clicked
     */
    public void setPendingIntent(PendingIntent intent, Runnable finisher) {
        setOnClickListener(v -> {
            try {
                BroadcastOptions options = BroadcastOptions.makeBasic();
                options.setInteractive(true);
                options.setPendingIntentBackgroundActivityStartMode(
                        ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
                intent.send(options.toBundle());
                finisher.run();
            } catch (PendingIntent.CanceledException e) {
                Log.e(TAG, "Intent cancelled", e);
            }
        });
    }

    /**
     * Set pressed state of chip (to be used when chip is clicked before underlying intent is ready)
     */
    public void setIsPending(boolean isPending) {
        mIsPending = isPending;
        setPressed(mIsPending);
    }

    private void updatePadding(boolean hasText) {
        LinearLayout.LayoutParams iconParams =
                (LinearLayout.LayoutParams) mIconView.getLayoutParams();
        LinearLayout.LayoutParams textParams =
                (LinearLayout.LayoutParams) mTextView.getLayoutParams();
        if (hasText) {
            int paddingStart = mContext.getResources().getDimensionPixelSize(
                    R.dimen.overlay_action_chip_padding_start);
            int spacing = mContext.getResources().getDimensionPixelSize(
                    R.dimen.overlay_action_chip_spacing);
            int paddingEnd = mContext.getResources().getDimensionPixelSize(
                    R.dimen.overlay_action_chip_padding_end);
            iconParams.setMarginStart(paddingStart);
            iconParams.setMarginEnd(spacing);
            textParams.setMarginEnd(paddingEnd);
        } else {
            int paddingHorizontal = mContext.getResources().getDimensionPixelSize(
                    R.dimen.overlay_action_chip_icon_only_padding_horizontal);
            iconParams.setMarginStart(paddingHorizontal);
            iconParams.setMarginEnd(paddingHorizontal);
        }
        mIconView.setLayoutParams(iconParams);
        mTextView.setLayoutParams(textParams);
    }
}