[RemoteInputView] RemoteInputQuickSettingsDisabler to Controller
Bug: 193539698 Test: mp sysuig, focus a remote input, try to swipe down quick settings Change-Id: Ia2128ee62cb2f593bc8a2ef03ed021d098b28812
This commit is contained in:
@@ -421,6 +421,9 @@ public class NotificationContentView extends FrameLayout {
|
||||
mExpandedChild.animate().cancel();
|
||||
removeView(mExpandedChild);
|
||||
mExpandedRemoteInput = null;
|
||||
if (mExpandedRemoteInputController != null) {
|
||||
mExpandedRemoteInputController.unbind();
|
||||
}
|
||||
mExpandedRemoteInputController = null;
|
||||
}
|
||||
if (child == null) {
|
||||
@@ -465,6 +468,9 @@ public class NotificationContentView extends FrameLayout {
|
||||
mHeadsUpChild.animate().cancel();
|
||||
removeView(mHeadsUpChild);
|
||||
mHeadsUpRemoteInput = null;
|
||||
if (mHeadsUpRemoteInputController != null) {
|
||||
mHeadsUpRemoteInputController.unbind();
|
||||
}
|
||||
mHeadsUpRemoteInputController = null;
|
||||
}
|
||||
if (child == null) {
|
||||
@@ -1211,8 +1217,14 @@ public class NotificationContentView extends FrameLayout {
|
||||
mExpandedWrapper);
|
||||
mExpandedRemoteInput = expandedData.mView;
|
||||
mExpandedRemoteInputController = expandedData.mController;
|
||||
if (mExpandedRemoteInputController != null) {
|
||||
mExpandedRemoteInputController.bind();
|
||||
}
|
||||
} else {
|
||||
mExpandedRemoteInput = null;
|
||||
if (mExpandedRemoteInputController != null) {
|
||||
mExpandedRemoteInputController.unbind();
|
||||
}
|
||||
mExpandedRemoteInputController = null;
|
||||
}
|
||||
if (mCachedExpandedRemoteInput != null
|
||||
@@ -1230,8 +1242,14 @@ public class NotificationContentView extends FrameLayout {
|
||||
mHeadsUpWrapper);
|
||||
mHeadsUpRemoteInput = headsUpData.mView;
|
||||
mHeadsUpRemoteInputController = headsUpData.mController;
|
||||
if (mHeadsUpRemoteInputController != null) {
|
||||
mHeadsUpRemoteInputController.bind();
|
||||
}
|
||||
} else {
|
||||
mHeadsUpRemoteInput = null;
|
||||
if (mHeadsUpRemoteInputController != null) {
|
||||
mHeadsUpRemoteInputController.unbind();
|
||||
}
|
||||
mHeadsUpRemoteInputController = null;
|
||||
}
|
||||
if (mCachedHeadsUpRemoteInput != null
|
||||
@@ -1272,7 +1290,7 @@ public class NotificationContentView extends FrameLayout {
|
||||
// Create a new controller for the view. The lifetime of the controller is 1:1
|
||||
// with that of the view.
|
||||
RemoteInputViewSubcomponent subcomponent =
|
||||
mRemoteInputSubcomponentFactory.create();
|
||||
mRemoteInputSubcomponentFactory.create(result.mView);
|
||||
result.mController = subcomponent.getController();
|
||||
result.mView.setController(result.mController);
|
||||
} else {
|
||||
|
||||
@@ -128,7 +128,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
|
||||
// TODO(b/193539698): move these to a Controller
|
||||
private RemoteInputController mController;
|
||||
private final RemoteInputQuickSettingsDisabler mRemoteInputQuickSettingsDisabler;
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
private NotificationEntry mEntry;
|
||||
private PendingIntent mPendingIntent;
|
||||
@@ -170,7 +169,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
super(context, attrs);
|
||||
mTextWatcher = new SendButtonTextWatcher();
|
||||
mEditorActionHandler = new EditorActionHandler();
|
||||
mRemoteInputQuickSettingsDisabler = Dependency.get(RemoteInputQuickSettingsDisabler.class);
|
||||
mUiEventLogger = Dependency.get(UiEventLogger.class);
|
||||
TypedArray ta = getContext().getTheme().obtainStyledAttributes(new int[]{
|
||||
com.android.internal.R.attr.colorAccent,
|
||||
@@ -522,8 +520,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
mRemoteInputQuickSettingsDisabler.setRemoteInputActive(false);
|
||||
|
||||
if (logClose) {
|
||||
mUiEventLogger.logWithInstanceId(
|
||||
NotificationRemoteInputEvent.NOTIFICATION_REMOTE_INPUT_CLOSE,
|
||||
@@ -623,8 +619,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
mController.addRemoteInput(mEntry, mToken);
|
||||
setAttachment(mEntry.remoteInputAttachment);
|
||||
|
||||
mRemoteInputQuickSettingsDisabler.setRemoteInputActive(true);
|
||||
|
||||
updateSendButton();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,38 @@
|
||||
|
||||
package com.android.systemui.statusbar.policy
|
||||
|
||||
import android.view.View
|
||||
import com.android.systemui.statusbar.policy.dagger.RemoteInputViewScope
|
||||
import javax.inject.Inject
|
||||
|
||||
interface RemoteInputViewController
|
||||
interface RemoteInputViewController {
|
||||
fun bind()
|
||||
fun unbind()
|
||||
}
|
||||
|
||||
@RemoteInputViewScope
|
||||
class RemoteInputViewControllerImpl @Inject constructor() : RemoteInputViewController
|
||||
class RemoteInputViewControllerImpl @Inject constructor(
|
||||
private val view: RemoteInputView,
|
||||
private val remoteInputQuickSettingsDisabler: RemoteInputQuickSettingsDisabler
|
||||
) : RemoteInputViewController {
|
||||
|
||||
private var isBound = false
|
||||
|
||||
override fun bind() {
|
||||
if (isBound) return
|
||||
isBound = true
|
||||
|
||||
view.addOnEditTextFocusChangedListener(onFocusChangeListener)
|
||||
}
|
||||
|
||||
override fun unbind() {
|
||||
if (!isBound) return
|
||||
isBound = false
|
||||
|
||||
view.removeOnEditTextFocusChangedListener(onFocusChangeListener)
|
||||
}
|
||||
|
||||
private val onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
|
||||
remoteInputQuickSettingsDisabler.setRemoteInputActive(hasFocus)
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.android.systemui.statusbar.policy.dagger
|
||||
|
||||
import com.android.systemui.statusbar.policy.RemoteInputView
|
||||
import com.android.systemui.statusbar.policy.RemoteInputViewController
|
||||
import com.android.systemui.statusbar.policy.RemoteInputViewControllerImpl
|
||||
import dagger.Binds
|
||||
import dagger.BindsInstance
|
||||
import dagger.Module
|
||||
import dagger.Subcomponent
|
||||
import javax.inject.Qualifier
|
||||
@@ -30,7 +32,7 @@ interface RemoteInputViewSubcomponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
fun create(): RemoteInputViewSubcomponent
|
||||
fun create(@BindsInstance view: RemoteInputView): RemoteInputViewSubcomponent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user