Controls Task View - Limit screen width
For larger displays in landscape mode, the task view should appear on the right side of the display and take up just under half the width, with a dark scrim covering the rest of display. Also adjust the insets for this new layout. Fixes: 216105163 Test: manual - Tablets and phones in both portrait and landscape Change-Id: Ib0b123b2002cbe3947a9c3782e479700d1689d1a
This commit is contained in:
@@ -15,47 +15,52 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/control_detail_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/black">
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="4dp">
|
||||
<ImageView
|
||||
android:id="@+id/control_detail_close"
|
||||
android:contentDescription="@string/accessibility_desc_close"
|
||||
android:src="@drawable/ic_arrow_back"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:tint="@color/control_primary_text"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp" />
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="1dp" />
|
||||
<ImageView
|
||||
android:id="@+id/control_detail_open_in_app"
|
||||
android:contentDescription="@string/controls_open_app"
|
||||
android:src="@drawable/ic_open_in_new"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:tint="@color/control_primary_text"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/controls_activity_view"
|
||||
android:id="@+id/control_task_view_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" />
|
||||
</LinearLayout>
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right|top"
|
||||
android:layout_marginRight="@dimen/controls_task_view_right_margin"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="4dp">
|
||||
<ImageView
|
||||
android:id="@+id/control_detail_close"
|
||||
android:contentDescription="@string/accessibility_desc_close"
|
||||
android:src="@drawable/ic_close"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:tint="@color/control_primary_text"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp" />
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="1dp" />
|
||||
<ImageView
|
||||
android:id="@+id/control_detail_open_in_app"
|
||||
android:contentDescription="@string/controls_open_app"
|
||||
android:src="@drawable/ic_open_in_new"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:tint="@color/control_primary_text"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/controls_activity_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
@@ -25,4 +25,8 @@
|
||||
<!-- margin from keyguard status bar to clock. For split shade it should be
|
||||
keyguard_split_shade_top_margin - status_bar_header_height_keyguard = 8dp -->
|
||||
<dimen name="keyguard_clock_top_margin">8dp</dimen>
|
||||
|
||||
<!-- Limit the TaskView to this percentage of the overall screen width (0.0 - 1.0) -->
|
||||
<item name="controls_task_view_width_percentage" translatable="false" format="float" type="dimen">0.45</item>
|
||||
<dimen name="controls_task_view_right_margin">8dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -195,6 +195,7 @@
|
||||
<color name="control_enabled_cool_foreground">@color/GM2_blue_300</color>
|
||||
<color name="control_thumbnail_tint">#33000000</color>
|
||||
<color name="control_thumbnail_shadow_color">@*android:color/black</color>
|
||||
<color name="controls_task_view_bg">#CC191C1D</color>
|
||||
|
||||
<!-- Docked misalignment message -->
|
||||
<color name="misalignment_text_color">#F28B82</color>
|
||||
|
||||
@@ -1043,6 +1043,9 @@
|
||||
<dimen name="controls_setup_subtitle">14sp</dimen>
|
||||
<dimen name="controls_setup_vertical_padding">52dp</dimen>
|
||||
<dimen name="controls_detail_dialog_header_height">52dp</dimen>
|
||||
<!-- Limit the TaskView to this percentage of the overall screen width (0.0 - 1.0) -->
|
||||
<item name="controls_task_view_width_percentage" translatable="false" format="float" type="dimen">1.0</item>
|
||||
<dimen name="controls_task_view_right_margin">0dp</dimen>
|
||||
|
||||
<!-- Home Controls activity view detail panel-->
|
||||
<dimen name="controls_activity_view_corner_radius">@*android:dimen/config_bottomDialogCornerRadius</dimen>
|
||||
|
||||
@@ -746,7 +746,7 @@
|
||||
<style name="Theme.SystemUI.Dialog.Control.DetailPanel" parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar">
|
||||
<item name="android:windowFullscreen">false</item>
|
||||
<item name="android:windowIsFloating">false</item>
|
||||
<item name="android:windowBackground">@android:color/black</item>
|
||||
<item name="android:windowBackground">@color/controls_task_view_bg</item>
|
||||
<item name="android:backgroundDimEnabled">false</item>
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||
</style>
|
||||
|
||||
@@ -41,12 +41,12 @@ import com.android.wm.shell.TaskView
|
||||
* The activity being launched is specified by {@link android.service.controls.Control#getAppIntent}.
|
||||
*/
|
||||
class DetailDialog(
|
||||
val activityContext: Context?,
|
||||
val activityContext: Context,
|
||||
val taskView: TaskView,
|
||||
val pendingIntent: PendingIntent,
|
||||
val cvh: ControlViewHolder
|
||||
) : Dialog(
|
||||
activityContext ?: cvh.context,
|
||||
activityContext,
|
||||
R.style.Theme_SystemUI_Dialog_Control_DetailPanel
|
||||
) {
|
||||
companion object {
|
||||
@@ -58,6 +58,10 @@ class DetailDialog(
|
||||
}
|
||||
|
||||
var detailTaskId = INVALID_TASK_ID
|
||||
private lateinit var taskViewContainer: View
|
||||
private val taskWidthPercentWidth = activityContext.resources.getFloat(
|
||||
R.dimen.controls_task_view_width_percentage
|
||||
)
|
||||
|
||||
private val fillInIntent = Intent().apply {
|
||||
putExtra(EXTRA_USE_PANEL, true)
|
||||
@@ -75,13 +79,18 @@ class DetailDialog(
|
||||
|
||||
val stateCallback = object : TaskView.Listener {
|
||||
override fun onInitialized() {
|
||||
val options = activityContext?.let {
|
||||
ActivityOptions.makeCustomAnimation(
|
||||
it,
|
||||
0 /* enterResId */,
|
||||
0 /* exitResId */
|
||||
)
|
||||
} ?: ActivityOptions.makeBasic()
|
||||
taskViewContainer.apply {
|
||||
// For some devices, limit the overall width of the taskView
|
||||
val lp = getLayoutParams()
|
||||
lp.width = (getWidth() * taskWidthPercentWidth).toInt()
|
||||
setLayoutParams(lp)
|
||||
}
|
||||
|
||||
val options = ActivityOptions.makeCustomAnimation(
|
||||
activityContext,
|
||||
0 /* enterResId */,
|
||||
0 /* exitResId */
|
||||
)
|
||||
taskView.startActivity(
|
||||
pendingIntent,
|
||||
fillInIntent,
|
||||
@@ -112,16 +121,14 @@ class DetailDialog(
|
||||
}
|
||||
|
||||
init {
|
||||
if (activityContext == null) {
|
||||
window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY)
|
||||
}
|
||||
|
||||
// To pass touches to the task inside TaskView.
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)
|
||||
window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
|
||||
|
||||
setContentView(R.layout.controls_detail_dialog)
|
||||
|
||||
taskViewContainer = requireViewById<ViewGroup>(R.id.control_task_view_container)
|
||||
|
||||
requireViewById<ViewGroup>(R.id.controls_activity_view).apply {
|
||||
addView(taskView)
|
||||
setAlpha(0f)
|
||||
@@ -130,6 +137,9 @@ class DetailDialog(
|
||||
requireViewById<ImageView>(R.id.control_detail_close).apply {
|
||||
setOnClickListener { _: View -> dismiss() }
|
||||
}
|
||||
requireViewById<View>(R.id.control_detail_root).apply {
|
||||
setOnClickListener { _: View -> dismiss() }
|
||||
}
|
||||
|
||||
requireViewById<ImageView>(R.id.control_detail_open_in_app).apply {
|
||||
setOnClickListener { v: View ->
|
||||
@@ -145,17 +155,10 @@ class DetailDialog(
|
||||
// consume all insets to achieve slide under effect
|
||||
window.getDecorView().setOnApplyWindowInsetsListener {
|
||||
v: View, insets: WindowInsets ->
|
||||
taskView.apply {
|
||||
val l = getPaddingLeft()
|
||||
val t = getPaddingTop()
|
||||
val r = getPaddingRight()
|
||||
setPadding(l, t, r, insets.getInsets(Type.systemBars()).bottom)
|
||||
}
|
||||
|
||||
val l = v.getPaddingLeft()
|
||||
val b = v.getPaddingBottom()
|
||||
val r = v.getPaddingRight()
|
||||
v.setPadding(l, insets.getInsets(Type.systemBars()).top, r, b)
|
||||
val insets = insets.getInsets(Type.systemBars())
|
||||
v.setPadding(l, insets.top, r, insets.bottom)
|
||||
|
||||
WindowInsets.CONSUMED
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user