Merge "Update home controls activity to exit to dream" into tm-qpr-dev
This commit is contained in:
@@ -21,6 +21,8 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.RemoteException
|
||||||
|
import android.service.dreams.IDreamManager
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
@@ -40,11 +42,13 @@ import javax.inject.Inject
|
|||||||
*/
|
*/
|
||||||
class ControlsActivity @Inject constructor(
|
class ControlsActivity @Inject constructor(
|
||||||
private val uiController: ControlsUiController,
|
private val uiController: ControlsUiController,
|
||||||
private val broadcastDispatcher: BroadcastDispatcher
|
private val broadcastDispatcher: BroadcastDispatcher,
|
||||||
|
private val dreamManager: IDreamManager,
|
||||||
) : ComponentActivity() {
|
) : ComponentActivity() {
|
||||||
|
|
||||||
private lateinit var parent: ViewGroup
|
private lateinit var parent: ViewGroup
|
||||||
private lateinit var broadcastReceiver: BroadcastReceiver
|
private lateinit var broadcastReceiver: BroadcastReceiver
|
||||||
|
private var mExitToDream: Boolean = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -81,17 +85,36 @@ class ControlsActivity @Inject constructor(
|
|||||||
|
|
||||||
parent = requireViewById<ViewGroup>(R.id.global_actions_controls)
|
parent = requireViewById<ViewGroup>(R.id.global_actions_controls)
|
||||||
parent.alpha = 0f
|
parent.alpha = 0f
|
||||||
uiController.show(parent, { finish() }, this)
|
uiController.show(parent, { finishOrReturnToDream() }, this)
|
||||||
|
|
||||||
ControlsAnimations.enterAnimation(parent).start()
|
ControlsAnimations.enterAnimation(parent).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
mExitToDream = intent.getBooleanExtra(ControlsUiController.EXIT_TO_DREAM, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun finishOrReturnToDream() {
|
||||||
|
if (mExitToDream) {
|
||||||
|
try {
|
||||||
|
mExitToDream = false
|
||||||
|
dreamManager.dream()
|
||||||
|
return
|
||||||
|
} catch (e: RemoteException) {
|
||||||
|
// Fall through
|
||||||
|
}
|
||||||
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
finishOrReturnToDream()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onStop()
|
super.onStop()
|
||||||
|
mExitToDream = false
|
||||||
|
|
||||||
uiController.hide()
|
uiController.hide()
|
||||||
}
|
}
|
||||||
@@ -106,7 +129,8 @@ class ControlsActivity @Inject constructor(
|
|||||||
broadcastReceiver = object : BroadcastReceiver() {
|
broadcastReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
val action = intent.getAction()
|
val action = intent.getAction()
|
||||||
if (Intent.ACTION_SCREEN_OFF.equals(action)) {
|
if (action == Intent.ACTION_SCREEN_OFF ||
|
||||||
|
action == Intent.ACTION_DREAMING_STARTED) {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,6 +138,7 @@ class ControlsActivity @Inject constructor(
|
|||||||
|
|
||||||
val filter = IntentFilter()
|
val filter = IntentFilter()
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF)
|
filter.addAction(Intent.ACTION_SCREEN_OFF)
|
||||||
|
filter.addAction(Intent.ACTION_DREAMING_STARTED)
|
||||||
broadcastDispatcher.registerReceiver(broadcastReceiver, filter)
|
broadcastDispatcher.registerReceiver(broadcastReceiver, filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ interface ControlsUiController {
|
|||||||
companion object {
|
companion object {
|
||||||
public const val TAG = "ControlsUiController"
|
public const val TAG = "ControlsUiController"
|
||||||
public const val EXTRA_ANIMATE = "extra_animate"
|
public const val EXTRA_ANIMATE = "extra_animate"
|
||||||
|
public const val EXIT_TO_DREAM = "extra_exit_to_dream"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun show(parent: ViewGroup, onDismiss: Runnable, activityContext: Context)
|
fun show(parent: ViewGroup, onDismiss: Runnable, activityContext: Context)
|
||||||
|
|||||||
@@ -210,7 +210,8 @@ public class DreamHomeControlsComplication implements Complication {
|
|||||||
|
|
||||||
final Intent intent = new Intent(mContext, ControlsActivity.class)
|
final Intent intent = new Intent(mContext, ControlsActivity.class)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
.putExtra(ControlsUiController.EXTRA_ANIMATE, true);
|
.putExtra(ControlsUiController.EXTRA_ANIMATE, true)
|
||||||
|
.putExtra(ControlsUiController.EXIT_TO_DREAM, true);
|
||||||
|
|
||||||
final ActivityLaunchAnimator.Controller controller =
|
final ActivityLaunchAnimator.Controller controller =
|
||||||
v != null ? ActivityLaunchAnimator.Controller.fromView(v, null /* cujType */)
|
v != null ? ActivityLaunchAnimator.Controller.fromView(v, null /* cujType */)
|
||||||
|
|||||||
Reference in New Issue
Block a user