Merge "[1/n] Letterbox Education: Add UI layouts"

This commit is contained in:
Tom Natan
2022-01-25 14:22:32 +00:00
committed by Android (Google) Code Review
18 changed files with 714 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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="rectangle">
<solid android:color="@android:color/system_accent1_100"/>
<corners android:radius="12dp"/>
</shape>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<!-- DO NOT SUBMIT - find right color!! -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/system_accent1_10">
<item android:drawable="@drawable/letterbox_education_dismiss_background"/>
</ripple>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/system_neutral2_400"
android:pathData="M16.59,8.59L12.0,13.17 7.41,8.59 6.0,10.0l6.0,6.0 6.0,-6.0z"/>
</vector>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/system_neutral2_200">
<item android:drawable="@drawable/letterbox_education_ic_expand_more"/>
</ripple>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/letterbox_education_dialog_icon_size"
android:height="@dimen/letterbox_education_dialog_icon_size"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:fillType="evenOdd"
android:pathData="M2 8C0.895431 8 0 8.89543 0 10V38C0 39.1046 0.895431 40 2 40H46C47.1046 40 48 39.1046 48 38V10C48 8.89543 47.1046 8 46 8H2ZM44 12H4V36H44V12Z" />
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:pathData="M 14 22 H 30 V 26 H 14 V 22 Z" />
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:pathData="M26 16L34 24L26 32V16Z" />
</vector>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/letterbox_education_dialog_icon_size"
android:height="@dimen/letterbox_education_dialog_icon_size"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:fillType="evenOdd"
android:pathData="M22.56 2H26C37.02 2 46 10.98 46 22H42C42 14.44 36.74 8.1 29.7 6.42L31.74 10L28.26 12L22.56 2ZM22 46H25.44L19.74 36L16.26 38L18.3 41.58C11.26 39.9 6 33.56 6 26H2C2 37.02 10.98 46 22 46ZM20.46 12L36 27.52L27.54 36L12 20.48L20.46 12ZM17.64 9.18C18.42 8.4 19.44 8 20.46 8C21.5 8 22.52 8.4 23.3 9.16L38.84 24.7C40.4 26.26 40.4 28.78 38.84 30.34L30.36 38.82C29.58 39.6 28.56 40 27.54 40C26.52 40 25.5 39.6 24.72 38.82L9.18 23.28C7.62 21.72 7.62 19.2 9.18 17.64L17.64 9.18Z" />
</vector>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/letterbox_education_dialog_icon_size"
android:height="@dimen/letterbox_education_dialog_icon_size"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:fillType="evenOdd"
android:pathData="M2 8C0.895431 8 0 8.89543 0 10V38C0 39.1046 0.895431 40 2 40H46C47.1046 40 48 39.1046 48 38V10C48 8.89543 47.1046 8 46 8H2ZM44 12H4V36H44V12Z" />
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:pathData="M6 16C6 14.8954 6.89543 14 8 14H21C22.1046 14 23 14.8954 23 16V32C23 33.1046 22.1046 34 21 34H8C6.89543 34 6 33.1046 6 32V16Z" />
<path
android:fillColor="@color/letterbox_education_text_secondary"
android:pathData="M25 16C25 14.8954 25.8954 14 27 14H40C41.1046 14 42 14.8954 42 16V32C42 33.1046 41.1046 34 40 34H27C25.8954 34 25 33.1046 25 32V16Z" />
</vector>

View File

@@ -0,0 +1,40 @@
<!--
~ Copyright (C) 2022 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="@dimen/letterbox_education_dialog_action_width"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/letterbox_education_dialog_action_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="12dp"/>
<TextView
android:id="@+id/letterbox_education_dialog_action_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="4sp"
android:textAlignment="center"
android:textColor="@color/compat_controls_text"
android:textSize="14sp"/>
</LinearLayout>

View File

@@ -0,0 +1,98 @@
<!--
~ Copyright (C) 2022 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.wm.shell.compatui.LetterboxEduDialogLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/compat_controls_background"
android:gravity="center"
android:paddingTop="24dp"
android:paddingBottom="32dp"
android:paddingHorizontal="32dp">
<!-- Adding an extra layer to animate the alpha of the background and content separately. -->
<LinearLayout
android:id="@+id/letterbox_education_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/letterbox_education_icon"
android:layout_width="@dimen/letterbox_education_dialog_icon_size"
android:layout_height="@dimen/letterbox_education_dialog_icon_size"
android:layout_marginBottom="20dp" />
<TextView
android:id="@+id/letterbox_education_dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="@dimen/letterbox_education_dialog_title_max_width"
android:lineSpacingExtra="4sp"
android:textAlignment="center"
android:textColor="@color/compat_controls_text"
android:textSize="24sp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top"
android:orientation="horizontal"
android:paddingTop="43dp">
<com.android.wm.shell.compatui.letterboxedu.LetterboxEduDialogActionLayout
android:id="@+id/letterbox_education_dialog_screen_rotation_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="@drawable/letterbox_education_ic_screen_rotation"/>
<com.android.wm.shell.compatui.letterboxedu.LetterboxEduDialogActionLayout
android:id="@+id/letterbox_education_dialog_split_screen_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/letterbox_education_dialog_space_between_actions"
app:icon="@drawable/letterbox_education_ic_split_screen"
app:text="@string/letterbox_education_split_screen_text"/>
<com.android.wm.shell.compatui.letterboxedu.LetterboxEduDialogActionLayout
android:id="@+id/letterbox_education_dialog_reposition_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginStart="@dimen/letterbox_education_dialog_space_between_actions"
app:icon="@drawable/letterbox_education_ic_reposition"
app:text="@string/letterbox_education_reposition_text"/>
</LinearLayout>
<Button
android:id="@+id/letterbox_education_dialog_dismiss"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginTop="43dp"
android:layout_marginHorizontal="24dp"
android:background="@drawable/letterbox_education_dismiss_background_ripple"
android:gravity="center"
android:text="@string/letterbox_education_got_it"
android:textColor="@android:color/system_neutral1_900"
android:textAlignment="center"
android:contentDescription="@string/letterbox_education_got_it"/>
</LinearLayout>
</com.android.wm.shell.compatui.LetterboxEduDialogLayout>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
android:background="@android:color/system_neutral1_900"
android:clickable="true">
</FrameLayout>

View File

@@ -0,0 +1,61 @@
<!--
~ Copyright (C) 2022 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.wm.shell.compatui.LetterboxEduToastLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/compat_controls_background"
android:gravity="center"
android:paddingVertical="14dp"
android:paddingHorizontal="16dp">
<!-- Adding an extra layer to animate the alpha of the background and content separately. -->
<LinearLayout
android:id="@+id/letterbox_education_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/letterbox_education_icon"
android:layout_width="@dimen/letterbox_education_toast_icon_size"
android:layout_height="@dimen/letterbox_education_toast_icon_size"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="@dimen/letterbox_education_toast_text_max_width"
android:paddingHorizontal="16dp"
android:lineSpacingExtra="5sp"
android:text="@string/letterbox_education_toast_title"
android:textAlignment="viewStart"
android:textColor="@color/compat_controls_text"
android:textSize="16sp"
android:maxLines="1"
android:ellipsize="end"/>
<ImageButton
android:id="@+id/letterbox_education_toast_expand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/letterbox_education_ic_expand_more_ripple"
android:background="@android:color/transparent"
android:contentDescription="@string/letterbox_education_expand_button_description"/>
</LinearLayout>
</com.android.wm.shell.compatui.LetterboxEduToastLayout>

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2022 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.
-->
<resources>
<declare-styleable name="LetterboxEduDialogActionLayout">
<attr name="icon" format="reference" />
<attr name="text" format="string" />
</declare-styleable>
</resources>

View File

@@ -34,6 +34,9 @@
<color name="compat_controls_background">@android:color/system_neutral1_800</color>
<color name="compat_controls_text">@android:color/system_neutral1_50</color>
<!-- Letterbox Education -->
<color name="letterbox_education_text_secondary">@android:color/system_neutral2_200</color>
<!-- GM2 colors -->
<color name="GM2_grey_200">#E8EAED</color>
<color name="GM2_grey_700">#5F6368</color>

View File

@@ -219,6 +219,37 @@
<!-- The width of the camera compat hint. -->
<dimen name="camera_compat_hint_width">143dp</dimen>
<!-- The corner radius of the letterbox education toast. -->
<dimen name="letterbox_education_toast_corner_radius">100dp</dimen>
<!-- The corner radius of the letterbox education dialog. -->
<dimen name="letterbox_education_dialog_corner_radius">28dp</dimen>
<!-- The margin between the letterbox education toast/dialog and the bottom of the task. -->
<dimen name="letterbox_education_margin_bottom">16dp</dimen>
<!-- The size of the icon in the letterbox education toast. -->
<dimen name="letterbox_education_toast_icon_size">24dp</dimen>
<!-- The size of an icon in the letterbox education dialog. -->
<dimen name="letterbox_education_dialog_icon_size">48dp</dimen>
<!-- The width of each action container in the letterbox education dialog -->
<dimen name="letterbox_education_dialog_action_width">136dp</dimen>
<!-- The space between two actions in the letterbox education dialog -->
<dimen name="letterbox_education_dialog_space_between_actions">18dp</dimen>
<!-- The maximum width of the title and subtitle in the letterbox education dialog. -->
<dimen name="letterbox_education_dialog_title_max_width">444dp</dimen>
<!-- The maximum width of the text in the letterbox education toast. -->
<dimen name="letterbox_education_toast_text_max_width">398dp</dimen>
<!-- The distance that the letterbox education dialog will move up during appear/dismiss
animation. -->
<dimen name="letterbox_education_dialog_animation_elevation">20dp</dimen>
<!-- The width of the brand image on staring surface. -->
<dimen name="starting_surface_brand_image_width">200dp</dimen>

View File

@@ -171,4 +171,28 @@
compatibility control. [CHAR LIMIT=NONE] -->
<string name="camera_compat_dismiss_button_description">No camera issues? Tap to dismiss.</string>
<!-- The title of the letterbox education dialog. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_dialog_title">Get the most out of <xliff:g id="app_name" example="YouTube">%s</xliff:g></string>
<!-- The title of the letterbox education toast. [CHAR LIMIT=60] -->
<string name="letterbox_education_toast_title">Rotate your device for a full-screen view</string>
<!-- Description of the rotate screen into portrait action. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_screen_rotation_portrait_text">Rotate your screen to portrait</string>
<!-- Description of the rotate screen into landscape action. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_screen_rotation_landscape_text">Rotate your screen to landscape</string>
<!-- Description of the put app in split-screen action. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_split_screen_text">Drag in another app to use split screen</string>
<!-- Description of the reposition app action. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_reposition_text">Double tap to reposition</string>
<!-- Button text for dismissing the letterbox education dialog. [CHAR LIMIT=20] -->
<string name="letterbox_education_got_it">Got it</string>
<!-- Accessibility description of the letterbox education toast expand to dialog button. [CHAR LIMIT=NONE] -->
<string name="letterbox_education_expand_button_description">Expand for more information.</string>
</resources>

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2022 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.wm.shell.compatui.letterboxedu;
import android.annotation.StringRes;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.wm.shell.R;
/**
* Custom layout for Letterbox Education dialog action.
*/
// TODO(b/215316431): Add tests
class LetterboxEduDialogActionLayout extends FrameLayout {
private final ImageView mIcon;
private final TextView mText;
LetterboxEduDialogActionLayout(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray styledAttributes =
context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.LetterboxEduDialogActionLayout,
/* defStyleAttr= */ 0,
/* defStyleRes= */ 0);
int iconId = styledAttributes.getResourceId(
R.styleable.LetterboxEduDialogActionLayout_icon, 0);
String optionalText = styledAttributes.getString(
R.styleable.LetterboxEduDialogActionLayout_text);
styledAttributes.recycle();
View rootView = inflate(getContext(), R.layout.letterbox_education_dialog_action_layout,
this);
mIcon = rootView.findViewById(R.id.letterbox_education_dialog_action_icon);
mIcon.setImageResource(iconId);
mText = rootView.findViewById(R.id.letterbox_education_dialog_action_text);
if (optionalText != null) {
mText.setText(optionalText);
}
}
void setText(@StringRes int id) {
mText.setText(getResources().getString(id));
}
void setIconRotation(float rotation) {
mIcon.setRotation(rotation);
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2022 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.wm.shell.compatui.letterboxedu;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Configuration.Orientation;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.wm.shell.R;
/**
* Container for Letterbox Education Dialog.
*/
// TODO(b/215316431): Add tests
public class LetterboxEduDialogLayout extends FrameLayout {
public LetterboxEduDialogLayout(Context context) {
this(context, null);
}
public LetterboxEduDialogLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public LetterboxEduDialogLayout(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public LetterboxEduDialogLayout(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
/**
* Register a callback for the dismiss button.
* @param callback The callback to register
*/
void setDismissOnClickListener(Runnable callback) {
findViewById(R.id.letterbox_education_dialog_dismiss).setOnClickListener(
view -> callback.run());
}
/**
* Updates the layout with the given app info.
* @param appIcon The name of the app
* @param appIcon The icon of the app
*/
void updateAppInfo(String appName, Drawable appIcon) {
((ImageView) findViewById(R.id.letterbox_education_icon)).setImageDrawable(appIcon);
((TextView) findViewById(R.id.letterbox_education_dialog_title)).setText(
getResources().getString(R.string.letterbox_education_dialog_title, appName));
}
/**
* Updates the layout according to the given orientation.
* @param orientation The orientation of the display
*/
void updateDisplayOrientation(@Orientation int orientation) {
boolean isOrientationPortrait = orientation == Configuration.ORIENTATION_PORTRAIT;
((LetterboxEduDialogActionLayout) findViewById(
R.id.letterbox_education_dialog_screen_rotation_action)).setText(
isOrientationPortrait
? R.string.letterbox_education_screen_rotation_landscape_text
: R.string.letterbox_education_screen_rotation_portrait_text);
if (isOrientationPortrait) {
((LetterboxEduDialogActionLayout) findViewById(
R.id.letterbox_education_dialog_split_screen_action)).setIconRotation(90f);
}
findViewById(R.id.letterbox_education_dialog_reposition_action).setVisibility(
isOrientationPortrait ? View.GONE : View.VISIBLE);
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2022 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.wm.shell.compatui.letterboxedu;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.android.wm.shell.R;
/**
* Container for the Letterbox Education Toast.
*/
// TODO(b/215316431): Add tests
public class LetterboxEduToastLayout extends FrameLayout {
public LetterboxEduToastLayout(Context context) {
this(context, null);
}
public LetterboxEduToastLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public LetterboxEduToastLayout(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public LetterboxEduToastLayout(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
/**
* Register a callback for the dismiss button.
* @param callback The callback to register
*/
void setExpandOnClickListener(Runnable callback) {
findViewById(R.id.letterbox_education_toast_expand).setOnClickListener(
view -> callback.run());
}
/**
* Updates the layout with the given app info.
* @param appName The name of the app
* @param appIcon The icon of the app
*/
void updateAppInfo(String appName, Drawable appIcon) {
ImageView icon = findViewById(R.id.letterbox_education_icon);
icon.setContentDescription(appName);
icon.setImageDrawable(appIcon);
}
}