Loading packages/SystemUI/res/layout/global_screenshot_action_chip.xml +24 −9 Original line number Diff line number Diff line Loading @@ -14,12 +14,27 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" <com.android.systemui.screenshot.ScreenshotActionChip xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/global_screenshot_action_chip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/screenshot_action_chip_margin_horizontal" android:layout_gravity="center" android:paddingVertical="@dimen/screenshot_action_chip_padding_vertical" android:paddingHorizontal="@dimen/screenshot_action_chip_padding_horizontal" android:background="@drawable/action_chip_background" android:gravity="center"> <ImageView android:id="@+id/screenshot_action_chip_icon" android:layout_width="@dimen/screenshot_action_chip_icon_size" android:layout_height="@dimen/screenshot_action_chip_icon_size" android:layout_marginStart="@dimen/screenshot_action_chip_padding_start" android:layout_marginEnd="@dimen/screenshot_action_chip_padding_middle"/> <TextView android:id="@+id/screenshot_action_chip_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="@dimen/screenshot_action_chip_padding_end" android:textSize="@dimen/screenshot_action_chip_text_size" android:textColor="@color/global_screenshot_button_text"/> </com.android.systemui.screenshot.ScreenshotActionChip> packages/SystemUI/res/values/dimens.xml +8 −3 Original line number Diff line number Diff line Loading @@ -291,12 +291,17 @@ <dimen name="global_screenshot_legacy_bg_padding">20dp</dimen> <dimen name="global_screenshot_bg_padding">20dp</dimen> <dimen name="screenshot_action_container_corner_radius">10dp</dimen> <dimen name="screenshot_action_container_padding">20dp</dimen> <dimen name="screenshot_action_container_padding">10dp</dimen> <!-- Radius of the chip background on global screenshot actions --> <dimen name="screenshot_button_corner_radius">20dp</dimen> <dimen name="screenshot_action_chip_margin_horizontal">10dp</dimen> <dimen name="screenshot_action_chip_margin_horizontal">4dp</dimen> <dimen name="screenshot_action_chip_padding_vertical">10dp</dimen> <dimen name="screenshot_action_chip_padding_horizontal">15dp</dimen> <dimen name="screenshot_action_chip_icon_size">20dp</dimen> <dimen name="screenshot_action_chip_padding_start">4dp</dimen> <!-- Padding between icon and text --> <dimen name="screenshot_action_chip_padding_middle">8dp</dimen> <dimen name="screenshot_action_chip_padding_end">12dp</dimen> <dimen name="screenshot_action_chip_text_size">14sp</dimen> <!-- The width of the view containing navigation buttons --> Loading packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +4 −4 Original line number Diff line number Diff line Loading @@ -64,7 +64,6 @@ import android.view.WindowManager; import android.view.animation.Interpolator; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import com.android.systemui.R; Loading Loading @@ -529,9 +528,10 @@ public class GlobalScreenshot { mActionsView.removeAllViews(); for (Notification.Action action : actions) { TextView actionChip = (TextView) inflater.inflate( ScreenshotActionChip actionChip = (ScreenshotActionChip) inflater.inflate( R.layout.global_screenshot_action_chip, mActionsView, false); actionChip.setText(action.title); actionChip.setIcon(action.getIcon(), true); actionChip.setOnClickListener(v -> { try { action.actionIntent.send(); Loading @@ -545,11 +545,11 @@ public class GlobalScreenshot { } if (DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI, SCREENSHOT_SCROLLING_ENABLED, false)) { TextView scrollChip = (TextView) inflater.inflate( ScreenshotActionChip scrollChip = (ScreenshotActionChip) inflater.inflate( R.layout.global_screenshot_action_chip, mActionsView, false); Toast scrollNotImplemented = Toast.makeText( mContext, "Not implemented", Toast.LENGTH_SHORT); scrollChip.setText("Scroll"); // TODO (mkephart): add resource and translate scrollChip.setText("Extend"); // TODO (mkephart): add resource and translate scrollChip.setOnClickListener(v -> scrollNotImplemented.show()); mActionsView.addView(scrollChip); } Loading packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionChip.java 0 → 100644 +73 −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.screenshot; import android.annotation.ColorInt; import android.content.Context; import android.graphics.drawable.Icon; import android.util.AttributeSet; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.systemui.R; /** * View for a chip with an icon and text. */ public class ScreenshotActionChip extends LinearLayout { private ImageView mIcon; private TextView mText; private @ColorInt int mIconColor; public ScreenshotActionChip(Context context) { this(context, null); } public ScreenshotActionChip(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ScreenshotActionChip(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public ScreenshotActionChip(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mIconColor = context.getColor(R.color.global_screenshot_button_text); } @Override protected void onFinishInflate() { mIcon = findViewById(R.id.screenshot_action_chip_icon); mText = findViewById(R.id.screenshot_action_chip_text); } void setIcon(Icon icon, boolean tint) { if (tint) { icon.setTint(mIconColor); } mIcon.setImageIcon(icon); } void setText(CharSequence text) { mText.setText(text); } } Loading
packages/SystemUI/res/layout/global_screenshot_action_chip.xml +24 −9 Original line number Diff line number Diff line Loading @@ -14,12 +14,27 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" <com.android.systemui.screenshot.ScreenshotActionChip xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/global_screenshot_action_chip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/screenshot_action_chip_margin_horizontal" android:layout_gravity="center" android:paddingVertical="@dimen/screenshot_action_chip_padding_vertical" android:paddingHorizontal="@dimen/screenshot_action_chip_padding_horizontal" android:background="@drawable/action_chip_background" android:gravity="center"> <ImageView android:id="@+id/screenshot_action_chip_icon" android:layout_width="@dimen/screenshot_action_chip_icon_size" android:layout_height="@dimen/screenshot_action_chip_icon_size" android:layout_marginStart="@dimen/screenshot_action_chip_padding_start" android:layout_marginEnd="@dimen/screenshot_action_chip_padding_middle"/> <TextView android:id="@+id/screenshot_action_chip_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="@dimen/screenshot_action_chip_padding_end" android:textSize="@dimen/screenshot_action_chip_text_size" android:textColor="@color/global_screenshot_button_text"/> </com.android.systemui.screenshot.ScreenshotActionChip>
packages/SystemUI/res/values/dimens.xml +8 −3 Original line number Diff line number Diff line Loading @@ -291,12 +291,17 @@ <dimen name="global_screenshot_legacy_bg_padding">20dp</dimen> <dimen name="global_screenshot_bg_padding">20dp</dimen> <dimen name="screenshot_action_container_corner_radius">10dp</dimen> <dimen name="screenshot_action_container_padding">20dp</dimen> <dimen name="screenshot_action_container_padding">10dp</dimen> <!-- Radius of the chip background on global screenshot actions --> <dimen name="screenshot_button_corner_radius">20dp</dimen> <dimen name="screenshot_action_chip_margin_horizontal">10dp</dimen> <dimen name="screenshot_action_chip_margin_horizontal">4dp</dimen> <dimen name="screenshot_action_chip_padding_vertical">10dp</dimen> <dimen name="screenshot_action_chip_padding_horizontal">15dp</dimen> <dimen name="screenshot_action_chip_icon_size">20dp</dimen> <dimen name="screenshot_action_chip_padding_start">4dp</dimen> <!-- Padding between icon and text --> <dimen name="screenshot_action_chip_padding_middle">8dp</dimen> <dimen name="screenshot_action_chip_padding_end">12dp</dimen> <dimen name="screenshot_action_chip_text_size">14sp</dimen> <!-- The width of the view containing navigation buttons --> Loading
packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +4 −4 Original line number Diff line number Diff line Loading @@ -64,7 +64,6 @@ import android.view.WindowManager; import android.view.animation.Interpolator; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import com.android.systemui.R; Loading Loading @@ -529,9 +528,10 @@ public class GlobalScreenshot { mActionsView.removeAllViews(); for (Notification.Action action : actions) { TextView actionChip = (TextView) inflater.inflate( ScreenshotActionChip actionChip = (ScreenshotActionChip) inflater.inflate( R.layout.global_screenshot_action_chip, mActionsView, false); actionChip.setText(action.title); actionChip.setIcon(action.getIcon(), true); actionChip.setOnClickListener(v -> { try { action.actionIntent.send(); Loading @@ -545,11 +545,11 @@ public class GlobalScreenshot { } if (DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI, SCREENSHOT_SCROLLING_ENABLED, false)) { TextView scrollChip = (TextView) inflater.inflate( ScreenshotActionChip scrollChip = (ScreenshotActionChip) inflater.inflate( R.layout.global_screenshot_action_chip, mActionsView, false); Toast scrollNotImplemented = Toast.makeText( mContext, "Not implemented", Toast.LENGTH_SHORT); scrollChip.setText("Scroll"); // TODO (mkephart): add resource and translate scrollChip.setText("Extend"); // TODO (mkephart): add resource and translate scrollChip.setOnClickListener(v -> scrollNotImplemented.show()); mActionsView.addView(scrollChip); } Loading
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionChip.java 0 → 100644 +73 −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.screenshot; import android.annotation.ColorInt; import android.content.Context; import android.graphics.drawable.Icon; import android.util.AttributeSet; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.systemui.R; /** * View for a chip with an icon and text. */ public class ScreenshotActionChip extends LinearLayout { private ImageView mIcon; private TextView mText; private @ColorInt int mIconColor; public ScreenshotActionChip(Context context) { this(context, null); } public ScreenshotActionChip(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ScreenshotActionChip(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public ScreenshotActionChip(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mIconColor = context.getColor(R.color.global_screenshot_button_text); } @Override protected void onFinishInflate() { mIcon = findViewById(R.id.screenshot_action_chip_icon); mText = findViewById(R.id.screenshot_action_chip_text); } void setIcon(Icon icon, boolean tint) { if (tint) { icon.setTint(mIconColor); } mIcon.setImageIcon(icon); } void setText(CharSequence text) { mText.setText(text); } }