Merge "Controls UI - Detail panel" into rvc-dev am: 87cf6848bd
Change-Id: Ia167e1c03859d5be843a49b3d490d6e34d0ae64d
This commit is contained in:
@@ -50,41 +50,15 @@
|
|||||||
android:padding="12dp" />
|
android:padding="12dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="@dimen/controls_activity_view_top_padding"
|
|
||||||
android:paddingLeft="@dimen/controls_activity_view_side_padding"
|
|
||||||
android:paddingRight="@dimen/controls_activity_view_side_padding"
|
|
||||||
android:background="@drawable/rounded_bg_top"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="@style/TextAppearance.ControlDialog"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end" />
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/subtitle"
|
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="@style/TextAppearance.ControlDialog"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end" />
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/controls_activity_view"
|
android:id="@+id/controls_activity_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_weight="1"
|
||||||
android:layout_weight="1" />
|
android:paddingTop="@dimen/controls_activity_view_top_padding"
|
||||||
|
android:paddingLeft="@dimen/controls_activity_view_side_padding"
|
||||||
</LinearLayout>
|
android:paddingRight="@dimen/controls_activity_view_side_padding"
|
||||||
|
android:background="@drawable/rounded_bg_top"
|
||||||
|
android:orientation="vertical" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -1260,7 +1260,7 @@
|
|||||||
<!-- Home Controls activity view detail panel-->
|
<!-- Home Controls activity view detail panel-->
|
||||||
<dimen name="controls_activity_view_top_padding">25dp</dimen>
|
<dimen name="controls_activity_view_top_padding">25dp</dimen>
|
||||||
<dimen name="controls_activity_view_side_padding">12dp</dimen>
|
<dimen name="controls_activity_view_side_padding">12dp</dimen>
|
||||||
<dimen name="controls_activity_view_top_offset">200dp</dimen>
|
<dimen name="controls_activity_view_top_offset">100dp</dimen>
|
||||||
<dimen name="controls_activity_view_text_size">17sp</dimen>
|
<dimen name="controls_activity_view_text_size">17sp</dimen>
|
||||||
|
|
||||||
<!-- Home Controls management screens -->
|
<!-- Home Controls management screens -->
|
||||||
|
|||||||
@@ -731,11 +731,6 @@
|
|||||||
<item name="android:textSize">@dimen/control_text_size</item>
|
<item name="android:textSize">@dimen/control_text_size</item>
|
||||||
<item name="android:textColor">@color/control_secondary_text</item>
|
<item name="android:textColor">@color/control_secondary_text</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="TextAppearance.ControlDialog">
|
|
||||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
|
|
||||||
<item name="android:textSize">@dimen/controls_activity_view_text_size</item>
|
|
||||||
<item name="android:textColor">@color/control_primary_text</item>
|
|
||||||
</style>
|
|
||||||
<style name="Control.ListPopupWindow" parent="@*android:style/Widget.DeviceDefault.ListPopupWindow">
|
<style name="Control.ListPopupWindow" parent="@*android:style/Widget.DeviceDefault.ListPopupWindow">
|
||||||
<item name="android:overlapAnchor">true</item>
|
<item name="android:overlapAnchor">true</item>
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,11 @@
|
|||||||
package com.android.systemui.controls.ui
|
package com.android.systemui.controls.ui
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.service.controls.Control
|
import android.service.controls.Control
|
||||||
import android.service.controls.actions.BooleanAction
|
import android.service.controls.actions.BooleanAction
|
||||||
import android.service.controls.actions.CommandAction
|
import android.service.controls.actions.CommandAction
|
||||||
import android.util.Log
|
|
||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
import com.android.systemui.R
|
|
||||||
import com.android.systemui.controls.controller.ControlsController
|
import com.android.systemui.controls.controller.ControlsController
|
||||||
|
|
||||||
object ControlActionCoordinator {
|
object ControlActionCoordinator {
|
||||||
@@ -51,23 +48,14 @@ object ControlActionCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow apps to specify whether they would like to appear in a detail panel or within
|
* All long presses will be shown in a 3/4 height bottomsheet panel, in order for the user to
|
||||||
* the full activity by setting the {@link Control#EXTRA_USE_PANEL} flag. In order for
|
* retain context with their favorited controls in the power menu.
|
||||||
* activities to determine how they are being launched, they should inspect the
|
|
||||||
* {@link Control#EXTRA_USE_PANEL} flag for a value of true.
|
|
||||||
*/
|
*/
|
||||||
fun longPress(cvh: ControlViewHolder) {
|
fun longPress(cvh: ControlViewHolder) {
|
||||||
// Long press snould only be called when there is valid control state, otherwise ignore
|
// Long press snould only be called when there is valid control state, otherwise ignore
|
||||||
cvh.cws.control?.let {
|
cvh.cws.control?.let {
|
||||||
try {
|
|
||||||
it.getAppIntent().send()
|
|
||||||
cvh.layout.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
cvh.layout.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||||
cvh.context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
|
showDialog(cvh, it.getAppIntent().getIntent())
|
||||||
} catch (e: PendingIntent.CanceledException) {
|
|
||||||
Log.e(ControlsUiController.TAG, "Error sending pending intent", e)
|
|
||||||
cvh.setTransientStatus(
|
|
||||||
cvh.context.resources.getString(R.string.controls_error_failed))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ class ControlViewHolder(
|
|||||||
val layout: ViewGroup,
|
val layout: ViewGroup,
|
||||||
val controlsController: ControlsController,
|
val controlsController: ControlsController,
|
||||||
val uiExecutor: DelayableExecutor,
|
val uiExecutor: DelayableExecutor,
|
||||||
val bgExecutor: DelayableExecutor,
|
val bgExecutor: DelayableExecutor
|
||||||
val usePanels: Boolean
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -159,8 +158,7 @@ class ControlViewHolder(
|
|||||||
controlsController.action(cws.componentName, cws.ci, action)
|
controlsController.action(cws.componentName, cws.ci, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun usePanel(): Boolean =
|
fun usePanel(): Boolean = deviceType in ControlViewHolder.FORCE_PANEL_DEVICES
|
||||||
usePanels && deviceType in ControlViewHolder.FORCE_PANEL_DEVICES
|
|
||||||
|
|
||||||
private fun findBehavior(
|
private fun findBehavior(
|
||||||
status: Int,
|
status: Int,
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import android.content.res.Configuration
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.provider.Settings
|
|
||||||
import android.service.controls.Control
|
import android.service.controls.Control
|
||||||
import android.service.controls.actions.ControlAction
|
import android.service.controls.actions.ControlAction
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -84,7 +83,6 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
private const val PREF_COMPONENT = "controls_component"
|
private const val PREF_COMPONENT = "controls_component"
|
||||||
private const val PREF_STRUCTURE = "controls_structure"
|
private const val PREF_STRUCTURE = "controls_structure"
|
||||||
|
|
||||||
private const val USE_PANELS = "systemui.controls_use_panel"
|
|
||||||
private const val FADE_IN_MILLIS = 200L
|
private const val FADE_IN_MILLIS = 200L
|
||||||
|
|
||||||
private val EMPTY_COMPONENT = ComponentName("", "")
|
private val EMPTY_COMPONENT = ComponentName("", "")
|
||||||
@@ -441,9 +439,6 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
|
|
||||||
val maxColumns = findMaxColumns()
|
val maxColumns = findMaxColumns()
|
||||||
|
|
||||||
// use flag only temporarily for testing
|
|
||||||
val usePanels = Settings.Secure.getInt(context.contentResolver, USE_PANELS, 0) == 1
|
|
||||||
|
|
||||||
val listView = parent.requireViewById(R.id.global_actions_controls_list) as ViewGroup
|
val listView = parent.requireViewById(R.id.global_actions_controls_list) as ViewGroup
|
||||||
var lastRow: ViewGroup = createRow(inflater, listView)
|
var lastRow: ViewGroup = createRow(inflater, listView)
|
||||||
selectedStructure.controls.forEach {
|
selectedStructure.controls.forEach {
|
||||||
@@ -457,8 +452,7 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
baseLayout,
|
baseLayout,
|
||||||
controlsController.get(),
|
controlsController.get(),
|
||||||
uiExecutor,
|
uiExecutor,
|
||||||
bgExecutor,
|
bgExecutor
|
||||||
usePanels
|
|
||||||
)
|
)
|
||||||
val key = ControlKey(selectedStructure.componentName, it.controlId)
|
val key = ControlKey(selectedStructure.componentName, it.controlId)
|
||||||
cvh.bindData(controlsById.getValue(key))
|
cvh.bindData(controlsById.getValue(key))
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import android.provider.Settings
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
|
import android.view.WindowInsets.Type
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
|
||||||
|
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ class DetailDialog(
|
|||||||
private const val PANEL_TOP_OFFSET = "systemui.controls_panel_top_offset"
|
private const val PANEL_TOP_OFFSET = "systemui.controls_panel_top_offset"
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var activityView: ActivityView
|
var activityView = ActivityView(context, null, 0, false)
|
||||||
|
|
||||||
val stateCallback: ActivityView.StateCallback = object : ActivityView.StateCallback() {
|
val stateCallback: ActivityView.StateCallback = object : ActivityView.StateCallback() {
|
||||||
override fun onActivityViewReady(view: ActivityView) {
|
override fun onActivityViewReady(view: ActivityView) {
|
||||||
@@ -67,10 +67,8 @@ class DetailDialog(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY)
|
window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY)
|
||||||
|
|
||||||
setContentView(R.layout.controls_detail_dialog)
|
setContentView(R.layout.controls_detail_dialog)
|
||||||
|
|
||||||
activityView = ActivityView(context, null, 0, false)
|
|
||||||
requireViewById<ViewGroup>(R.id.controls_activity_view).apply {
|
requireViewById<ViewGroup>(R.id.controls_activity_view).apply {
|
||||||
addView(activityView)
|
addView(activityView)
|
||||||
}
|
}
|
||||||
@@ -79,14 +77,6 @@ class DetailDialog(
|
|||||||
setOnClickListener { _: View -> dismiss() }
|
setOnClickListener { _: View -> dismiss() }
|
||||||
}
|
}
|
||||||
|
|
||||||
requireViewById<TextView>(R.id.title).apply {
|
|
||||||
setText(cvh.title.text)
|
|
||||||
}
|
|
||||||
|
|
||||||
requireViewById<TextView>(R.id.subtitle).apply {
|
|
||||||
setText(cvh.subtitle.text)
|
|
||||||
}
|
|
||||||
|
|
||||||
requireViewById<ImageView>(R.id.control_detail_open_in_app).apply {
|
requireViewById<ImageView>(R.id.control_detail_open_in_app).apply {
|
||||||
setOnClickListener { v: View ->
|
setOnClickListener { v: View ->
|
||||||
dismiss()
|
dismiss()
|
||||||
@@ -97,15 +87,15 @@ class DetailDialog(
|
|||||||
|
|
||||||
// consume all insets to achieve slide under effect
|
// consume all insets to achieve slide under effect
|
||||||
window.getDecorView().setOnApplyWindowInsetsListener {
|
window.getDecorView().setOnApplyWindowInsetsListener {
|
||||||
v: View, insets: WindowInsets ->
|
_: View, insets: WindowInsets ->
|
||||||
activityView.apply {
|
activityView.apply {
|
||||||
val l = getPaddingLeft()
|
val l = getPaddingLeft()
|
||||||
val t = getPaddingTop()
|
val t = getPaddingTop()
|
||||||
val r = getPaddingRight()
|
val r = getPaddingRight()
|
||||||
setPadding(l, t, r, insets.getSystemWindowInsets().bottom)
|
setPadding(l, t, r, insets.getInsets(Type.systemBars()).bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
insets.consumeSystemWindowInsets()
|
WindowInsets.CONSUMED
|
||||||
}
|
}
|
||||||
|
|
||||||
requireViewById<ViewGroup>(R.id.control_detail_root).apply {
|
requireViewById<ViewGroup>(R.id.control_detail_root).apply {
|
||||||
@@ -118,6 +108,9 @@ class DetailDialog(
|
|||||||
val lp = getLayoutParams() as ViewGroup.MarginLayoutParams
|
val lp = getLayoutParams() as ViewGroup.MarginLayoutParams
|
||||||
lp.topMargin = offsetInPx
|
lp.topMargin = offsetInPx
|
||||||
setLayoutParams(lp)
|
setLayoutParams(lp)
|
||||||
|
|
||||||
|
setOnClickListener { dismiss() }
|
||||||
|
(getParent() as View).setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user