Merge "Accessibility for Notification Inline Controls" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-17 23:07:49 +00:00
committed by Android (Google) Code Review
5 changed files with 43 additions and 5 deletions

View File

@@ -114,6 +114,7 @@
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_weight="1"
android:contentDescription="@string/notification_channel_switch_accessibility"
android:background="@null" />
</LinearLayout>

View File

@@ -1466,6 +1466,15 @@
<item quantity="other"><xliff:g id="channel_name_1">%1$s</xliff:g>, <xliff:g id="channel_name_2">%2$s</xliff:g>, and <xliff:g id="number">%3$d</xliff:g> others</item>
</plurals>
<!-- Notification: Control panel: Accessibility description for expanded inline controls view, used
to control settings about notifications related to the current notification. -->
<string name="notification_channel_controls_opened_accessibility">Notification controls for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> opened</string>
<!-- Notification: Control panel: Accessibility description for announcing the closing of the
inline controls view. -->
<string name="notification_channel_controls_closed_accessibility">Notification controls for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> closed</string>
<!-- Notification: Control panel: Accessibility description for switch that is used to enable
or disable notifications from this channel -->
<string name="notification_channel_switch_accessibility">Allow notifications from this channel</string>
<!-- Notification: Control panel: Label for button that launches notification settings. Used
when this app has defined more than a single channel for notifications. -->
<string name="notification_all_categories">All Categories</string>

View File

@@ -39,6 +39,7 @@ import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -255,6 +256,7 @@ public class NotificationGuts extends FrameLayout {
}
public void setExposed(boolean exposed, boolean needsFalsingProtection) {
final boolean wasExposed = mExposed;
mExposed = exposed;
mNeedsFalsingProtection = needsFalsingProtection;
if (mExposed && mNeedsFalsingProtection) {
@@ -262,6 +264,13 @@ public class NotificationGuts extends FrameLayout {
} else {
mHandler.removeCallbacks(mFalsingCheck);
}
if (wasExposed != mExposed && mGutsContent != null) {
final View contentView = mGutsContent.getContentView();
contentView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
if (mExposed) {
contentView.requestAccessibilityFocus();
}
}
}
public boolean willBeRemoved() {

View File

@@ -35,6 +35,7 @@ import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
@@ -57,6 +58,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
private INotificationManager mINotificationManager;
private String mPkg;
private String mAppName;
private int mAppUid;
private List<NotificationChannel> mNotificationChannels;
private NotificationChannel mSingleNotificationChannel;
@@ -125,7 +127,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
}
}
String appName = mPkg;
mAppName = mPkg;
Drawable pkgicon = null;
CharSequence channelNameText = "";
ApplicationInfo info = null;
@@ -137,7 +139,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
| PackageManager.MATCH_DIRECT_BOOT_AWARE);
if (info != null) {
mAppUid = info.uid;
appName = String.valueOf(pm.getApplicationLabel(info));
mAppName = String.valueOf(pm.getApplicationLabel(info));
pkgicon = pm.getApplicationIcon(info);
}
} catch (PackageManager.NameNotFoundException e) {
@@ -189,7 +191,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
} else {
channelNameText = mSingleNotificationChannel.getName();
}
((TextView) findViewById(R.id.pkgname)).setText(appName);
((TextView) findViewById(R.id.pkgname)).setText(mAppName);
((TextView) findViewById(R.id.channel_name)).setText(channelNameText);
// Set group information if this channel has an associated group.
@@ -309,6 +311,21 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
});
}
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
if (mGutsContainer != null &&
event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
if (mGutsContainer.isExposed()) {
event.getText().add(mContext.getString(
R.string.notification_channel_controls_opened_accessibility, mAppName));
} else {
event.getText().add(mContext.getString(
R.string.notification_channel_controls_closed_accessibility, mAppName));
}
}
}
private void updateSecondaryText() {
final boolean disabled = mSingleNotificationChannel != null &&
getSelectedImportance() == IMPORTANCE_NONE;

View File

@@ -5909,8 +5909,10 @@ public class StatusBar extends SystemUI implements DemoMode,
}
});
a.start();
guts.setExposed(true /* exposed */,
mState == StatusBarState.KEYGUARD /* needsFalsingProtection */);
final boolean needsFalsingProtection =
(mState == StatusBarState.KEYGUARD &&
!mAccessibilityManager.isTouchExplorationEnabled());
guts.setExposed(true /* exposed */, needsFalsingProtection);
row.closeRemoteInput();
mStackScroller.onHeightChanged(row, true /* needsAnimation */);
mNotificationGutsExposed = guts;