Even more Inline Reply goodness
- Removed action icon processing - Correct color for action label - Change default notification color to Gray 600 - Handle different states in RemoteInputView - Handle updates to Notifications with active remote input Bug: 22452379 Change-Id: I30a0cd917dbf814f156ab5a106e018a245d99b67
This commit is contained in:
@@ -3330,7 +3330,6 @@ public class Notification implements Parcelable
|
||||
if (mN.color != COLOR_DEFAULT) {
|
||||
button.setTextColor(R.id.action0, mN.color);
|
||||
}
|
||||
processLegacyAction(action, button);
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -3342,14 +3341,6 @@ public class Notification implements Parcelable
|
||||
return getColorUtil() != null;
|
||||
}
|
||||
|
||||
private void processLegacyAction(Action action, RemoteViews button) {
|
||||
if (!isLegacy() || getColorUtil().isGrayscaleIcon(mContext, action.getIcon())) {
|
||||
button.setTextViewCompoundDrawablesRelativeColorFilter(R.id.action0, 0,
|
||||
mContext.getColor(R.color.notification_action_color_filter),
|
||||
PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
}
|
||||
|
||||
private CharSequence processLegacyText(CharSequence charSequence) {
|
||||
if (isLegacy()) {
|
||||
return getColorUtil().invertCharSequenceColors(charSequence);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="4dp"
|
||||
android:textColor="@color/secondary_text_material_light"
|
||||
android:textColor="@color/notification_default_color"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:background="@drawable/notification_material_action_background"
|
||||
|
||||
@@ -130,8 +130,8 @@
|
||||
<drawable name="notification_template_divider">#29000000</drawable>
|
||||
<drawable name="notification_template_divider_media">#29ffffff</drawable>
|
||||
|
||||
<color name="notification_icon_default_color">#ff616161</color>
|
||||
<color name="notification_action_color_filter">@color/secondary_text_material_light</color>
|
||||
<color name="notification_default_color">#757575</color> <!-- Gray 600 -->
|
||||
<color name="notification_icon_default_color">@color/notification_default_color</color>
|
||||
|
||||
<color name="notification_progress_background_color">@color/secondary_text_material_light</color>
|
||||
|
||||
|
||||
@@ -1874,7 +1874,6 @@
|
||||
<java-symbol type="layout" name="notification_template_material_big_text" />
|
||||
<java-symbol type="layout" name="notification_template_header" />
|
||||
<java-symbol type="layout" name="notification_material_media_action" />
|
||||
<java-symbol type="color" name="notification_action_color_filter" />
|
||||
<java-symbol type="color" name="notification_icon_default_color" />
|
||||
<java-symbol type="color" name="notification_progress_background_color" />
|
||||
<java-symbol type="id" name="media_actions" />
|
||||
|
||||
21
packages/SystemUI/res/color/remote_input_send.xml
Normal file
21
packages/SystemUI/res/color/remote_input_send.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 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
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="true" android:color="@android:color/white" />
|
||||
<item android:color="#4dffffff" /> <!-- 30% white -->
|
||||
</selector>
|
||||
21
packages/SystemUI/res/color/remote_input_text.xml
Normal file
21
packages/SystemUI/res/color/remote_input_text.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 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
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="true" android:color="@android:color/white" />
|
||||
<item android:color="#99ffffff" /> <!-- 60% white -->
|
||||
</selector>
|
||||
@@ -36,7 +36,8 @@
|
||||
android:paddingEnd="12dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearance"
|
||||
android:textColor="#deffffff"
|
||||
android:textColor="@color/remote_input_text"
|
||||
android:textColorHint="@color/remote_input_hint"
|
||||
android:textSize="16sp"
|
||||
android:background="@null"
|
||||
android:singleLine="true"
|
||||
@@ -58,8 +59,8 @@
|
||||
android:paddingBottom="12dp"
|
||||
android:id="@+id/remote_input_send"
|
||||
android:src="@drawable/ic_send"
|
||||
android:tint="@android:color/white"
|
||||
android:tintMode="src_atop"
|
||||
android:tint="@color/remote_input_send"
|
||||
android:tintMode="src_in"
|
||||
android:background="@drawable/ripple_drawable" />
|
||||
|
||||
<ProgressBar
|
||||
|
||||
@@ -144,4 +144,7 @@
|
||||
|
||||
<color name="docked_divider_background">#ff000000</color>
|
||||
<color name="docked_divider_handle">#ffffff</color>
|
||||
|
||||
<color name="default_remote_input_background">@*android:color/notification_default_color</color>
|
||||
<color name="remote_input_hint">#4dffffff</color>
|
||||
</resources>
|
||||
|
||||
@@ -1602,7 +1602,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
private void applyRemoteInput(final Entry entry) {
|
||||
if (!ENABLE_REMOTE_INPUT) return;
|
||||
|
||||
RemoteInput remoteInput = null;
|
||||
boolean hasRemoteInput = false;
|
||||
|
||||
Notification.Action[] actions = entry.notification.getNotification().actions;
|
||||
if (actions != null) {
|
||||
@@ -1610,7 +1610,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
if (a.getRemoteInputs() != null) {
|
||||
for (RemoteInput ri : a.getRemoteInputs()) {
|
||||
if (ri.getAllowFreeFormInput()) {
|
||||
remoteInput = ri;
|
||||
hasRemoteInput = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1618,34 +1618,50 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
}
|
||||
|
||||
// See if we have somewhere to put that remote input
|
||||
if (remoteInput != null) {
|
||||
View bigContentView = entry.getExpandedContentView();
|
||||
if (bigContentView != null) {
|
||||
inflateRemoteInput(bigContentView, entry);
|
||||
}
|
||||
View headsUpContentView = entry.getHeadsUpContentView();
|
||||
if (headsUpContentView != null) {
|
||||
inflateRemoteInput(headsUpContentView, entry);
|
||||
}
|
||||
View bigContentView = entry.getExpandedContentView();
|
||||
if (bigContentView != null) {
|
||||
applyRemoteInput(bigContentView, entry, hasRemoteInput);
|
||||
}
|
||||
View headsUpContentView = entry.getHeadsUpContentView();
|
||||
if (headsUpContentView != null) {
|
||||
applyRemoteInput(headsUpContentView, entry, hasRemoteInput);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RemoteInputView inflateRemoteInput(View view, Entry entry) {
|
||||
private RemoteInputView applyRemoteInput(View view, Entry entry, boolean hasRemoteInput) {
|
||||
View actionContainerCandidate = view.findViewById(
|
||||
com.android.internal.R.id.actions_container);
|
||||
if (actionContainerCandidate instanceof FrameLayout) {
|
||||
ViewGroup actionContainer = (FrameLayout) actionContainerCandidate;
|
||||
RemoteInputView riv = inflateRemoteInputView(actionContainer, entry);
|
||||
if (riv != null) {
|
||||
riv.setVisibility(View.INVISIBLE);
|
||||
actionContainer.addView(riv, new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
);
|
||||
riv.setBackgroundColor(entry.notification.getNotification().color);
|
||||
return riv;
|
||||
RemoteInputView existing = (RemoteInputView)
|
||||
view.findViewWithTag(RemoteInputView.VIEW_TAG);
|
||||
|
||||
if (hasRemoteInput) {
|
||||
if (existing != null) {
|
||||
existing.onNotificationUpdate();
|
||||
return existing;
|
||||
}
|
||||
|
||||
ViewGroup actionContainer = (FrameLayout) actionContainerCandidate;
|
||||
RemoteInputView riv = inflateRemoteInputView(actionContainer, entry);
|
||||
if (riv != null) {
|
||||
riv.setVisibility(View.INVISIBLE);
|
||||
actionContainer.addView(riv, new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
);
|
||||
int color = entry.notification.getNotification().color;
|
||||
if (color == Notification.COLOR_DEFAULT) {
|
||||
color = mContext.getColor(R.color.default_remote_input_background);
|
||||
}
|
||||
riv.setBackgroundColor(color);
|
||||
return riv;
|
||||
}
|
||||
} else {
|
||||
if (existing != null) {
|
||||
existing.onNotificationUpdate();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -28,6 +28,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -49,7 +51,7 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Host for the remote input.
|
||||
*/
|
||||
public class RemoteInputView extends LinearLayout implements View.OnClickListener {
|
||||
public class RemoteInputView extends LinearLayout implements View.OnClickListener, TextWatcher {
|
||||
|
||||
private static final String TAG = "RemoteInput";
|
||||
|
||||
@@ -101,6 +103,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
}
|
||||
});
|
||||
mEditText.setOnClickListener(this);
|
||||
mEditText.addTextChangedListener(this);
|
||||
mEditText.setInnerFocusable(false);
|
||||
mEditText.mDefocusListener = this;
|
||||
}
|
||||
@@ -115,6 +118,8 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
mEditText.setEnabled(false);
|
||||
mSendButton.setVisibility(INVISIBLE);
|
||||
mProgressBar.setVisibility(VISIBLE);
|
||||
mController.removeRemoteInput(mEntry);
|
||||
mEditText.mShowImeOnInputConnection = false;
|
||||
|
||||
try {
|
||||
mPendingIntent.send(mContext, 0, fillInIntent);
|
||||
@@ -175,6 +180,40 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
mEditText.setText(mEntry.remoteInputText);
|
||||
mEditText.setSelection(mEditText.getText().length());
|
||||
mEditText.requestFocus();
|
||||
updateSendButton();
|
||||
}
|
||||
|
||||
public void onNotificationUpdate() {
|
||||
boolean sending = mProgressBar.getVisibility() == VISIBLE;
|
||||
|
||||
if (sending) {
|
||||
// Update came in after we sent the reply, time to reset.
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
mEditText.getText().clear();
|
||||
mEditText.setEnabled(true);
|
||||
mSendButton.setVisibility(VISIBLE);
|
||||
mProgressBar.setVisibility(INVISIBLE);
|
||||
updateSendButton();
|
||||
onDefocus();
|
||||
}
|
||||
|
||||
private void updateSendButton() {
|
||||
mSendButton.setEnabled(mEditText.getText().length() != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
updateSendButton();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user