diff options
author | Michael Chan <mchan@android.com> | 2011-09-09 13:06:43 -0700 |
---|---|---|
committer | Michael Chan <mchan@android.com> | 2011-09-12 09:37:03 -0700 |
commit | aeae98bf8f8c5c544f65f5b6b7f29cfd31366ad5 (patch) | |
tree | ae20a07e38a2001223d50f2d41de3796f7ef0746 | |
parent | f9fdf5788de7be95bae9d73115a4a68b043a90c7 (diff) | |
download | android_packages_apps_Etar-aeae98bf8f8c5c544f65f5b6b7f29cfd31366ad5.tar.gz android_packages_apps_Etar-aeae98bf8f8c5c544f65f5b6b7f29cfd31366ad5.tar.bz2 android_packages_apps_Etar-aeae98bf8f8c5c544f65f5b6b7f29cfd31366ad5.zip |
Fix up accessibility. Remove stripes for declined events
b/5288841 Remove stripes for declined events
b/5270879 Accessibility: Interrupt the first reading of the event
from day/week view when the user taps and open an event.
b/5288922 Accessibility: Read event times when viewing an event
Also other improved on the event and time readout for accessibility
Change-Id: Ic6b317fbe9ef3a00ffd854094d904945dbec3159
-rw-r--r-- | res/drawable-hdpi/event_bg_declined.png | bin | 92 -> 0 bytes | |||
-rw-r--r-- | res/drawable-mdpi/event_bg_declined.png | bin | 85 -> 0 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/event_bg_declined.png | bin | 104 -> 0 bytes | |||
-rw-r--r-- | res/drawable/widget_chip_declined_bg.xml | 25 | ||||
-rw-r--r-- | res/drawable/widget_declined_tile.png | bin | 169 -> 0 bytes | |||
-rw-r--r-- | src/com/android/calendar/ColorChipView.java | 25 | ||||
-rw-r--r-- | src/com/android/calendar/DayView.java | 149 | ||||
-rw-r--r-- | src/com/android/calendar/EventInfoFragment.java | 9 | ||||
-rw-r--r-- | src/com/android/calendar/agenda/AgendaAdapter.java | 2 | ||||
-rw-r--r-- | src/com/android/calendar/widget/CalendarAppWidgetService.java | 2 |
10 files changed, 93 insertions, 119 deletions
diff --git a/res/drawable-hdpi/event_bg_declined.png b/res/drawable-hdpi/event_bg_declined.png Binary files differdeleted file mode 100644 index da07254c..00000000 --- a/res/drawable-hdpi/event_bg_declined.png +++ /dev/null diff --git a/res/drawable-mdpi/event_bg_declined.png b/res/drawable-mdpi/event_bg_declined.png Binary files differdeleted file mode 100644 index 78ef0d44..00000000 --- a/res/drawable-mdpi/event_bg_declined.png +++ /dev/null diff --git a/res/drawable-xhdpi/event_bg_declined.png b/res/drawable-xhdpi/event_bg_declined.png Binary files differdeleted file mode 100644 index bcad7920..00000000 --- a/res/drawable-xhdpi/event_bg_declined.png +++ /dev/null diff --git a/res/drawable/widget_chip_declined_bg.xml b/res/drawable/widget_chip_declined_bg.xml deleted file mode 100644 index 1a43d281..00000000 --- a/res/drawable/widget_chip_declined_bg.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 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" - android:exitFadeDuration="@android:integer/config_mediumAnimTime"> - <item> - <bitmap - android:state_window_focused="false" - android:src="@drawable/widget_declined_tile" - android:tileMode="repeat" /> - </item> -</selector> diff --git a/res/drawable/widget_declined_tile.png b/res/drawable/widget_declined_tile.png Binary files differdeleted file mode 100644 index 4cac4839..00000000 --- a/res/drawable/widget_declined_tile.png +++ /dev/null diff --git a/src/com/android/calendar/ColorChipView.java b/src/com/android/calendar/ColorChipView.java index 50e9d1b0..53421bf1 100644 --- a/src/com/android/calendar/ColorChipView.java +++ b/src/com/android/calendar/ColorChipView.java @@ -45,9 +45,9 @@ public class ColorChipView extends View { public static final int DRAW_FULL = 0; public static final int DRAW_BORDER = 1; - public static final int DRAW_CROSS_HATCHED = 2; + public static final int DRAW_FADED = 2; - private static final float DECLINED_ALPHA = (float) 0.4; + private static final float DECLINED_ALPHA = (float) 0.625; private static final float DEFAULT_ALPHA = 1; int mDrawStyle = DRAW_FULL; @@ -57,26 +57,21 @@ public class ColorChipView extends View { int mBorderWidth = DEF_BORDER_WIDTH; int mColor; - BitmapDrawable mCrosshatchedPattern; public ColorChipView(Context context) { super(context); - init(context); } public ColorChipView(Context context, AttributeSet attrs) { super(context, attrs); - init(context); } public void setDrawStyle(int style) { - if (style != DRAW_FULL && style != DRAW_BORDER && style != DRAW_CROSS_HATCHED) { + if (style != DRAW_FULL && style != DRAW_BORDER && style != DRAW_FADED) { return; } mDrawStyle = style; - if (style == DRAW_CROSS_HATCHED) { - mCrosshatchedPattern.setColorFilter(mColor, PorterDuff.Mode.OVERLAY); - setBackgroundDrawable(mCrosshatchedPattern); + if (style == DRAW_FADED) { setAlpha(DECLINED_ALPHA); } else { setBackgroundDrawable(null); @@ -94,16 +89,9 @@ public class ColorChipView extends View { public void setColor(int color) { mColor = color; - mCrosshatchedPattern.setColorFilter(mColor, PorterDuff.Mode.OVERLAY); invalidate(); } - private void init(Context c) { - mCrosshatchedPattern = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), - R.drawable.event_bg_declined)); - mCrosshatchedPattern.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); - } - @Override public void onDraw(Canvas c) { @@ -114,6 +102,7 @@ public class ColorChipView extends View { p.setStyle(Style.FILL_AND_STROKE); switch (mDrawStyle) { + case DRAW_FADED: case DRAW_FULL: c.drawRect(0, 0, right, bottom, p); break; @@ -146,10 +135,6 @@ public class ColorChipView extends View { lines [ptr++] = bottom; c.drawLines(lines, p); break; - default: - // Don't need to do anything for DRAW_CROSS_HATCHED since the - // pattern is already set in the background drawable in "setStyle" - break; } } } diff --git a/src/com/android/calendar/DayView.java b/src/com/android/calendar/DayView.java index 96d712d7..a4b2c205 100644 --- a/src/com/android/calendar/DayView.java +++ b/src/com/android/calendar/DayView.java @@ -33,16 +33,12 @@ import android.content.DialogInterface; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.Cursor; -import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Align; -import android.graphics.PorterDuff; import android.graphics.Paint.Style; -import android.graphics.Shader.TileMode; import android.graphics.Rect; import android.graphics.Typeface; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Handler; @@ -470,7 +466,6 @@ public class DayView extends View implements View.OnCreateContextMenuListener, protected final Drawable mExpandAlldayDrawable; protected final Drawable mCollapseAlldayDrawable; protected Drawable mAcceptedOrTentativeEventBoxDrawable; - protected BitmapDrawable mDeclinedBgDrawable; private String mAmString; private String mPmString; private DeleteEventHelper mDeleteEventHelper; @@ -540,12 +535,17 @@ public class DayView extends View implements View.OnCreateContextMenuListener, private float mLastVelocity; private ScrollInterpolator mHScrollInterpolator; + private AccessibilityManager mAccessibilityMgr = null; + private boolean mIsAccessibilityEnabled = false; private boolean mTouchExplorationEnabled = false; private String mCreateNewEventString; public DayView(Context context, CalendarController controller, ViewSwitcher viewSwitcher, EventLoader eventLoader, int numDays) { super(context); + mContext = context; + initAccessibilityVariables(); + mResources = context.getResources(); mCreateNewEventString = mResources.getString(R.string.event_create); @@ -624,17 +624,11 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mAcceptedOrTentativeEventBoxDrawable = mResources .getDrawable(R.drawable.panel_month_event_holo_light); - mDeclinedBgDrawable = new BitmapDrawable(mResources, BitmapFactory.decodeResource( - mResources, R.drawable.event_bg_declined)); - mDeclinedBgDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); - mDeclinedBgDrawable.setAntiAlias(false); - mEventLoader = eventLoader; mEventGeometry = new EventGeometry(); mEventGeometry.setMinEventHeight(MIN_EVENT_HEIGHT); mEventGeometry.setHourGap(HOUR_GAP); mEventGeometry.setCellMargin(DAY_GAP); - mContext = context; mLongPressItems = new CharSequence[] { mResources.getString(R.string.new_event_dialog_option) }; @@ -801,7 +795,7 @@ public class DayView extends View implements View.OnCreateContextMenuListener, } public void handleOnResume() { - mTouchExplorationEnabled = isTouchExplorationEnabled(); + initAccessibilityVariables(); mIs24HourFormat = DateFormat.is24HourFormat(mContext); mHourStrs = mIs24HourFormat ? CalendarData.s24Hours : CalendarData.s12HoursNoAmPm; mFirstDayOfWeek = Utils.getFirstDayOfWeek(mContext); @@ -810,6 +804,13 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mLastSelectedEvent = null; } + private void initAccessibilityVariables() { + mAccessibilityMgr = (AccessibilityManager) mContext + .getSystemService(Service.ACCESSIBILITY_SERVICE); + mIsAccessibilityEnabled = mAccessibilityMgr != null && mAccessibilityMgr.isEnabled(); + mTouchExplorationEnabled = isTouchExplorationEnabled(); + } + /** * Returns the start of the selected time in milliseconds since the epoch. * @@ -933,7 +934,7 @@ public class DayView extends View implements View.OnCreateContextMenuListener, scrollAnim.addListener(mAnimatorListener); scrollAnim.start(); } - sendAccessibilityEventAsNeeded(); + sendAccessibilityEventAsNeeded(false); } public void setViewStartY(int viewStartY) { @@ -1262,6 +1263,9 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mController.sendEventRelatedEventWithExtra(this, EventType.CREATE_EVENT, -1, startMillis, endMillis, -1, -1, extraLong, -1); } else { + if (mIsAccessibilityEnabled) { + mAccessibilityMgr.interrupt(); + } // Switch to the EventInfo view mController.sendEventRelatedEvent(this, EventType.VIEW_EVENT, selectedEvent.id, selectedEvent.startMillis, selectedEvent.endMillis, 0, 0, @@ -1272,6 +1276,9 @@ public class DayView extends View implements View.OnCreateContextMenuListener, // unambiguous event, then view that event. Otherwise go to // Day/Agenda view. if (mSelectedEvents.size() == 1) { + if (mIsAccessibilityEnabled) { + mAccessibilityMgr.interrupt(); + } mController.sendEventRelatedEvent(this, EventType.VIEW_EVENT, selectedEvent.id, selectedEvent.startMillis, selectedEvent.endMillis, 0, 0, getSelectedTimeInMillis()); @@ -1292,6 +1299,9 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mController.sendEventRelatedEventWithExtra(this, EventType.CREATE_EVENT, -1, startMillis, endMillis, -1, -1, extraLong, -1); } else { + if (mIsAccessibilityEnabled) { + mAccessibilityMgr.interrupt(); + } mController.sendEventRelatedEvent(this, EventType.VIEW_EVENT, selectedEvent.id, selectedEvent.startMillis, selectedEvent.endMillis, 0, 0, getSelectedTimeInMillis()); @@ -1521,14 +1531,11 @@ public class DayView extends View implements View.OnCreateContextMenuListener, } private boolean isTouchExplorationEnabled() { - AccessibilityManager am = (AccessibilityManager) mContext - .getSystemService(Service.ACCESSIBILITY_SERVICE); - return am != null && am.isEnabled() && am.isTouchExplorationEnabled(); + return mIsAccessibilityEnabled && mAccessibilityMgr.isTouchExplorationEnabled(); } - private void sendAccessibilityEventAsNeeded() { - if (!((AccessibilityManager) mContext.getSystemService(Service.ACCESSIBILITY_SERVICE)) - .isEnabled()) { + private void sendAccessibilityEventAsNeeded(boolean speakEvents) { + if (!mIsAccessibilityEnabled) { return; } boolean dayChanged = mLastSelectionDay != mSelectionDay; @@ -1539,9 +1546,6 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mLastSelectedEvent = mSelectedEvent; StringBuilder b = new StringBuilder(); - if (mEventCountTemplate == null) { - mEventCountTemplate = mContext.getString(R.string.template_announce_item_index); - } // Announce only the changes i.e. day or hour or both if (dayChanged) { @@ -1550,43 +1554,53 @@ public class DayView extends View implements View.OnCreateContextMenuListener, if (hourChanged) { b.append(getSelectedTime().format(mIs24HourFormat ? "%k" : "%l%p")); } - b.append(PERIOD_SPACE); + if (dayChanged || hourChanged) { + b.append(PERIOD_SPACE); + } - // Read out the relevant event(s) - int numEvents = mSelectedEvents.size(); - if (numEvents > 0) { - if (mSelectedEvent == null) { - // Read out all the events - int i = 1; - for (Event calEvent : mSelectedEvents) { + if (speakEvents) { + if (mEventCountTemplate == null) { + mEventCountTemplate = mContext.getString(R.string.template_announce_item_index); + } + + // Read out the relevant event(s) + int numEvents = mSelectedEvents.size(); + if (numEvents > 0) { + if (mSelectedEvent == null) { + // Read out all the events + int i = 1; + for (Event calEvent : mSelectedEvents) { + if (numEvents > 1) { + // Read out x of numEvents if there are more than one event + mStringBuilder.setLength(0); + b.append(mFormatter.format(mEventCountTemplate, i++, numEvents)); + b.append(" "); + } + appendEventAccessibilityString(b, calEvent); + } + } else { if (numEvents > 1) { // Read out x of numEvents if there are more than one event mStringBuilder.setLength(0); - b.append(mFormatter.format(mEventCountTemplate, i++, numEvents)); + b.append(mFormatter.format(mEventCountTemplate, mSelectedEvents + .indexOf(mSelectedEvent) + 1, numEvents)); b.append(" "); } - appendEventAccessibilityString(b, calEvent); + appendEventAccessibilityString(b, mSelectedEvent); } } else { - if (numEvents > 1) { - // Read out x of numEvents if there are more than one event - mStringBuilder.setLength(0); - b.append(mFormatter.format(mEventCountTemplate, mSelectedEvents - .indexOf(mSelectedEvent) + 1, numEvents)); - b.append(" "); - } - appendEventAccessibilityString(b, mSelectedEvent); + b.append(mCreateNewEventString); } - } else { - b.append(mCreateNewEventString); } - AccessibilityEvent event = AccessibilityEvent - .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); - CharSequence msg = b.toString(); - event.getText().add(msg); - event.setAddedCount(msg.length()); - sendAccessibilityEventUnchecked(event); + if (dayChanged || hourChanged || speakEvents) { + AccessibilityEvent event = AccessibilityEvent + .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); + CharSequence msg = b.toString(); + event.getText().add(msg); + event.setAddedCount(msg.length()); + sendAccessibilityEventUnchecked(event); + } } } @@ -3188,14 +3202,13 @@ public class DayView extends View implements View.OnCreateContextMenuListener, r.left = (int) event.left + EVENT_RECT_LEFT_MARGIN; r.right = (int) event.right; + int color = event.color; switch (event.selfAttendeeStatus) { case Attendees.ATTENDEE_STATUS_INVITED: p.setStyle(Style.STROKE); break; case Attendees.ATTENDEE_STATUS_DECLINED: - mDeclinedBgDrawable.setColorFilter((event.color & 0x00FFFFFF) | DECLINED_ALPHA, - PorterDuff.Mode.OVERLAY); - break; + color = (event.color & 0x00FFFFFF) | DECLINED_ALPHA; case Attendees.ATTENDEE_STATUS_NONE: // Your own events case Attendees.ATTENDEE_STATUS_ACCEPTED: case Attendees.ATTENDEE_STATUS_TENTATIVE: @@ -3206,28 +3219,23 @@ public class DayView extends View implements View.OnCreateContextMenuListener, p.setAntiAlias(false); - if (event.selfAttendeeStatus == Attendees.ATTENDEE_STATUS_DECLINED) { - mDeclinedBgDrawable.setBounds(r); - mDeclinedBgDrawable.draw(canvas); - } else { - int floorHalfStroke = (int) Math.floor(EVENT_RECT_STROKE_WIDTH / 2.0f); - int ceilHalfStroke = (int) Math.ceil(EVENT_RECT_STROKE_WIDTH / 2.0f); - r.top = Math.max((int) event.top + EVENT_RECT_TOP_MARGIN + floorHalfStroke, visibleTop); - r.bottom = Math.min((int) event.bottom - EVENT_RECT_BOTTOM_MARGIN - ceilHalfStroke, - visibleBot); - r.left += floorHalfStroke; - r.right -= ceilHalfStroke; - p.setStrokeWidth(EVENT_RECT_STROKE_WIDTH); - p.setColor(event.color); - canvas.drawRect(r, p); - } + int floorHalfStroke = (int) Math.floor(EVENT_RECT_STROKE_WIDTH / 2.0f); + int ceilHalfStroke = (int) Math.ceil(EVENT_RECT_STROKE_WIDTH / 2.0f); + r.top = Math.max((int) event.top + EVENT_RECT_TOP_MARGIN + floorHalfStroke, visibleTop); + r.bottom = Math.min((int) event.bottom - EVENT_RECT_BOTTOM_MARGIN - ceilHalfStroke, + visibleBot); + r.left += floorHalfStroke; + r.right -= ceilHalfStroke; + p.setStrokeWidth(EVENT_RECT_STROKE_WIDTH); + p.setColor(color); + canvas.drawRect(r, p); p.setStyle(Style.FILL); // If this event is selected, then use the selection color if (mSelectedEvent == event) { boolean paintIt = false; - int color = 0; + color = 0; if (mSelectionMode == SELECTION_PRESSED) { // Also, remember the last selected event that we drew mPrevSelectedEvent = event; @@ -3599,6 +3607,9 @@ public class DayView extends View implements View.OnCreateContextMenuListener, invalidate(); if (mSelectedEvent != null) { + if (mIsAccessibilityEnabled) { + mAccessibilityMgr.interrupt(); + } // If the tap is on an event, launch the "View event" view mController.sendEventRelatedEvent(this, EventType.VIEW_EVENT, mSelectedEvent.id, mSelectedEvent.startMillis, mSelectedEvent.endMillis, (int) ev.getRawX(), @@ -4200,7 +4211,7 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mSelectionDay = day; if (y < DAY_HEADER_HEIGHT) { - sendAccessibilityEventAsNeeded(); + sendAccessibilityEventAsNeeded(false); return false; } @@ -4237,7 +4248,7 @@ public class DayView extends View implements View.OnCreateContextMenuListener, // Log.i("Cal", " " + timeRange + " " + ev.title); // } // } - sendAccessibilityEventAsNeeded(); + sendAccessibilityEventAsNeeded(true); return true; } diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java index 0f63a10d..5ef58291 100644 --- a/src/com/android/calendar/EventInfoFragment.java +++ b/src/com/android/calendar/EventInfoFragment.java @@ -256,7 +256,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange private String mCalendarAllowedReminders; private TextView mTitle; - private TextView mWhen; + private TextView mWhenDate; + private TextView mWhenTime; private TextView mWhere; private TextView mDesc; private AttendeesView mLongAttendees; @@ -551,7 +552,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange mView = inflater.inflate(R.layout.event_info, container, false); mScrollView = (ScrollView) mView.findViewById(R.id.event_info_scroll_view); mTitle = (TextView) mView.findViewById(R.id.title); - mWhen = (TextView) mView.findViewById(R.id.when); + mWhenDate = (TextView) mView.findViewById(R.id.when_date); + mWhenTime = (TextView) mView.findViewById(R.id.when_time); mWhere = (TextView) mView.findViewById(R.id.where); mDesc = (TextView) mView.findViewById(R.id.description); mHeadlines = mView.findViewById(R.id.event_info_headline); @@ -1295,7 +1297,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange List<CharSequence> text = event.getText(); addFieldToAccessibilityEvent(text, mTitle); - addFieldToAccessibilityEvent(text, mWhen); + addFieldToAccessibilityEvent(text, mWhenDate); + addFieldToAccessibilityEvent(text, mWhenTime); addFieldToAccessibilityEvent(text, mWhere); addFieldToAccessibilityEvent(text, mDesc); diff --git a/src/com/android/calendar/agenda/AgendaAdapter.java b/src/com/android/calendar/agenda/AgendaAdapter.java index 7d4e5190..cb8bb161 100644 --- a/src/com/android/calendar/agenda/AgendaAdapter.java +++ b/src/com/android/calendar/agenda/AgendaAdapter.java @@ -131,7 +131,7 @@ public class AgendaAdapter extends ResourceCursorAdapter { holder.title.setTextColor(mDeclinedColor); holder.when.setTextColor(mWhereDeclinedColor); holder.where.setTextColor(mWhereDeclinedColor); - holder.colorChip.setDrawStyle(ColorChipView.DRAW_CROSS_HATCHED); + holder.colorChip.setDrawStyle(ColorChipView.DRAW_FADED); } else { holder.title.setTextColor(mStandardColor); holder.when.setTextColor(mWhereColor); diff --git a/src/com/android/calendar/widget/CalendarAppWidgetService.java b/src/com/android/calendar/widget/CalendarAppWidgetService.java index 81ba40e8..f0851c18 100644 --- a/src/com/android/calendar/widget/CalendarAppWidgetService.java +++ b/src/com/android/calendar/widget/CalendarAppWidgetService.java @@ -257,7 +257,7 @@ public class CalendarAppWidgetService extends RemoteViewsService { // views.setInt(R.id.agenda_item_color, "setDrawStyle", // ColorChipView.DRAW_CROSS_HATCHED); views.setInt(R.id.agenda_item_color, "setImageResource", - R.drawable.widget_chip_declined_bg); + R.drawable.widget_chip_responded_bg); // 40% opacity views.setInt(R.id.agenda_item_color, "setColorFilter", (displayColor & 0x00FFFFFF) | DECLINED_EVENT_ALPHA); |