diff options
author | Isaac Katzenelson <isaack@android.com> | 2011-10-25 18:00:50 -0700 |
---|---|---|
committer | Isaac Katzenelson <isaack@android.com> | 2011-10-31 17:38:38 -0700 |
commit | 7ef2981ab9ad32a6818b36cefbd39f070ba708ed (patch) | |
tree | 74cc06a05b237d6775ba25690cd8c8ed9533cd56 /src | |
parent | 4f04f9f3bee90bad4f0fa0505a5c3644834c1b50 (diff) | |
download | android_packages_apps_Calendar-7ef2981ab9ad32a6818b36cefbd39f070ba708ed.tar.gz android_packages_apps_Calendar-7ef2981ab9ad32a6818b36cefbd39f070ba708ed.tar.bz2 android_packages_apps_Calendar-7ef2981ab9ad32a6818b36cefbd39f070ba708ed.zip |
Support for 7 inch devices
Changed layout directory names
Added values directories
Added config values to support event info behavior
Change-Id: I78d14e952250008cc453ed7b2ff3ec638eea6eac
Diffstat (limited to 'src')
11 files changed, 73 insertions, 44 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java index 17b22b58..b88cd25d 100644 --- a/src/com/android/calendar/AllInOneActivity.java +++ b/src/com/android/calendar/AllInOneActivity.java @@ -125,7 +125,8 @@ public class AllInOneActivity extends Activity implements EventHandler, private View mSecondaryPane; private String mTimeZone; private boolean mShowCalendarControls; - private boolean mShowEventInfoFullScreen; + private boolean mShowEventInfoFullScreenAgenda; + private boolean mShowEventInfoFullScreenDay; private int mWeekNum; private long mViewEventId = -1; @@ -331,14 +332,16 @@ public class AllInOneActivity extends Activity implements EventHandler, mShowString = res.getString(R.string.show_controls); mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - mIsMultipane = Utils.isMultiPaneConfiguration(this); + mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config); mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month); mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); - mShowEventInfoFullScreen = - Utils.getConfigBool(this, R.bool.show_event_info_full_screen); + mShowEventInfoFullScreenAgenda = + Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen); + mShowEventInfoFullScreenDay = + Utils.getConfigBool(this, R.bool.day_show_event_info_full_screen); Utils.setAllowWeekForDetailView(mIsMultipane); @@ -1082,7 +1085,9 @@ public class AllInOneActivity extends Activity implements EventHandler, mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, -1, ViewType.CURRENT); } - if (mShowEventInfoFullScreen) { + if ((mCurrentView == ViewType.AGENDA && mShowEventInfoFullScreenAgenda) || + ((mCurrentView == ViewType.DAY || (mCurrentView == ViewType.WEEK)) + && mShowEventInfoFullScreenDay)){ // start event info as activity Intent intent = new Intent(Intent.ACTION_VIEW); Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id); @@ -1098,7 +1103,8 @@ public class AllInOneActivity extends Activity implements EventHandler, // start event info as a dialog EventInfoFragment fragment = new EventInfoFragment(this, event.id, event.startTime.toMillis(false), - event.endTime.toMillis(false), (int) event.extraLong, true); + event.endTime.toMillis(false), (int) event.extraLong, true, + EventInfoFragment.DIALOG_WINDOW_STYLE); fragment.setDialogParams(event.x, event.y, mActionBar.getHeight()); FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); diff --git a/src/com/android/calendar/EventInfoActivity.java b/src/com/android/calendar/EventInfoActivity.java index 798f9502..aac0a8ec 100644 --- a/src/com/android/calendar/EventInfoActivity.java +++ b/src/com/android/calendar/EventInfoActivity.java @@ -88,7 +88,9 @@ public class EventInfoActivity extends Activity { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, - attendeeResponse, isDialog); + attendeeResponse, isDialog, isDialog ? + EventInfoFragment.DIALOG_WINDOW_STYLE : + EventInfoFragment.FULL_WINDOW_STYLE); ft.replace(R.id.main_frame, mInfoFragment); ft.commit(); } diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java index 4130f458..17168cbb 100644 --- a/src/com/android/calendar/EventInfoFragment.java +++ b/src/com/android/calendar/EventInfoFragment.java @@ -123,6 +123,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange protected static final String BUNDLE_KEY_END_MILLIS = "key_end_millis"; protected static final String BUNDLE_KEY_IS_DIALOG = "key_fragment_is_dialog"; protected static final String BUNDLE_KEY_DELETE_DIALOG_VISIBLE = "key_delete_dialog_visible"; + protected static final String BUNDLE_KEY_WINDOW_STYLE = "key_window_style"; protected static final String BUNDLE_KEY_ATTENDEE_RESPONSE = "key_attendee_response"; private static final String PERIOD_SPACE = ". "; @@ -134,6 +135,12 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange static final int UPDATE_SINGLE = 0; static final int UPDATE_ALL = 1; + // Style of view + public static final int FULL_WINDOW_STYLE = 0; + public static final int DIALOG_WINDOW_STYLE = 1; + + private int mWindowStyle = DIALOG_WINDOW_STYLE; + // Query tokens for QueryHandler private static final int TOKEN_QUERY_EVENT = 1 << 0; private static final int TOKEN_QUERY_CALENDARS = 1 << 1; @@ -316,8 +323,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange private OnItemSelectedListener mReminderChangeListener; - private static int DIALOG_WIDTH = 500; - private static int DIALOG_HEIGHT = 600; + private static int mDialogWidth = 500; + private static int mDialogHeight = 600; private static int DIALOG_TOP_MARGIN = 8; private boolean mIsDialog = false; private boolean mIsPaused = true; @@ -440,13 +447,21 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } public EventInfoFragment(Context context, Uri uri, long startMillis, long endMillis, - int attendeeResponse, boolean isDialog) { - if (mScale == 0) { - mScale = context.getResources().getDisplayMetrics().density; - if (mScale != 1) { - DIALOG_WIDTH *= mScale; - DIALOG_HEIGHT *= mScale; - DIALOG_TOP_MARGIN *= mScale; + int attendeeResponse, boolean isDialog, int windowStyle) { + + if (isDialog) { + Resources r = context.getResources(); + + mDialogWidth = r.getInteger(R.integer.event_info_dialog_width); + mDialogHeight = r.getInteger(R.integer.event_info_dialog_height); + + if (mScale == 0) { + mScale = context.getResources().getDisplayMetrics().density; + if (mScale != 1) { + mDialogWidth *= mScale; + mDialogHeight *= mScale; + DIALOG_TOP_MARGIN *= mScale; + } } } mIsDialog = isDialog; @@ -456,6 +471,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange mStartMillis = startMillis; mEndMillis = endMillis; mAttendeeResponseFromIntent = attendeeResponse; + mWindowStyle = windowStyle; } // This is currently required by the fragment manager. @@ -465,9 +481,9 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange public EventInfoFragment(Context context, long eventId, long startMillis, long endMillis, - int attendeeResponse, boolean isDialog) { + int attendeeResponse, boolean isDialog, int windowStyle) { this(context, ContentUris.withAppendedId(Events.CONTENT_URI, eventId), startMillis, - endMillis, attendeeResponse, isDialog); + endMillis, attendeeResponse, isDialog, windowStyle); mEventId = eventId; } @@ -494,6 +510,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange if (savedInstanceState != null) { mIsDialog = savedInstanceState.getBoolean(BUNDLE_KEY_IS_DIALOG, false); + mWindowStyle = savedInstanceState.getInt(BUNDLE_KEY_WINDOW_STYLE, + DIALOG_WINDOW_STYLE); } if (mIsDialog) { @@ -512,16 +530,16 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange WindowManager.LayoutParams a = window.getAttributes(); a.dimAmount = .4f; - a.width = DIALOG_WIDTH; - a.height = DIALOG_HEIGHT; + a.width = mDialogWidth; + a.height = mDialogHeight; // On tablets , do smart positioning of dialog // On phones , use the whole screen if (mX != -1 || mY != -1) { - a.x = mX - DIALOG_WIDTH / 2; - a.y = mY - DIALOG_HEIGHT / 2; + a.x = mX - mDialogWidth / 2; + a.y = mY - mDialogHeight / 2; if (a.y < mMinTop) { a.y = mMinTop + DIALOG_TOP_MARGIN; } @@ -581,7 +599,11 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - mView = inflater.inflate(R.layout.event_info, container, false); + if (mWindowStyle == DIALOG_WINDOW_STYLE) { + mView = inflater.inflate(R.layout.dialog_event_info, container, false); + } else { + 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); mWhenDate = (TextView) mView.findViewById(R.id.when_date); @@ -632,10 +654,13 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange // Hide Edit/Delete buttons if in full screen mode on a phone if (savedInstanceState != null) { mIsDialog = savedInstanceState.getBoolean(BUNDLE_KEY_IS_DIALOG, false); + mWindowStyle = savedInstanceState.getInt(BUNDLE_KEY_WINDOW_STYLE, + DIALOG_WINDOW_STYLE); mDeleteDialogVisible = savedInstanceState.getBoolean(BUNDLE_KEY_DELETE_DIALOG_VISIBLE,false); + } - if (!mIsDialog && !mIsTabletConfig) { + if (!mIsDialog && !mIsTabletConfig || mWindowStyle == EventInfoFragment.FULL_WINDOW_STYLE) { mView.findViewById(R.id.event_info_buttons_container).setVisibility(View.GONE); } @@ -812,6 +837,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange outState.putLong(BUNDLE_KEY_START_MILLIS, mStartMillis); outState.putLong(BUNDLE_KEY_END_MILLIS, mEndMillis); outState.putBoolean(BUNDLE_KEY_IS_DIALOG, mIsDialog); + outState.putInt(BUNDLE_KEY_WINDOW_STYLE, mWindowStyle); outState.putBoolean(BUNDLE_KEY_DELETE_DIALOG_VISIBLE, mDeleteDialogVisible); outState.putInt(BUNDLE_KEY_ATTENDEE_RESPONSE, mAttendeeResponseFromIntent); } @@ -820,8 +846,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - // Show edit/delete buttons only in non-dialog configuration on a phone - if (!mIsDialog && !mIsTabletConfig) { + // Show edit/delete buttons only in non-dialog configuration + if (!mIsDialog && !mIsTabletConfig || mWindowStyle == EventInfoFragment.FULL_WINDOW_STYLE) { inflater.inflate(R.menu.event_info_title_bar, menu); mMenu = menu; updateMenu(); @@ -831,9 +857,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange @Override public boolean onOptionsItemSelected(MenuItem item) { - // If we're a dialog or part of a tablet display we don't want to handle - // menu buttons - if (mIsDialog || mIsTabletConfig) { + // If we're a dialog we don't want to handle menu buttons + if (mIsDialog) { return false; } // Handles option menu selections: @@ -1442,7 +1467,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange button.setVisibility(View.GONE); } } - if (!mIsTabletConfig && mMenu != null) { + if ((!mIsDialog && !mIsTabletConfig || + mWindowStyle == EventInfoFragment.FULL_WINDOW_STYLE) && mMenu != null) { mActivity.invalidateOptionsMenu(); } } else { diff --git a/src/com/android/calendar/SearchActivity.java b/src/com/android/calendar/SearchActivity.java index 121c2890..9ccd32ab 100644 --- a/src/com/android/calendar/SearchActivity.java +++ b/src/com/android/calendar/SearchActivity.java @@ -95,7 +95,7 @@ public class SearchActivity extends Activity implements CalendarController.Event // This needs to be created before setContentView mController = CalendarController.getInstance(this); - mIsMultipane = Utils.isMultiPaneConfiguration (this); + mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); @@ -174,7 +174,7 @@ public class SearchActivity extends Activity implements CalendarController.Event mEventInfoFragment = new EventInfoFragment(this, event.id, event.startTime.toMillis(false), event.endTime.toMillis(false), - (int) event.extraLong, false); + (int) event.extraLong, false, EventInfoFragment.FULL_WINDOW_STYLE); ft.replace(R.id.agenda_event_info, mEventInfoFragment); ft.commit(); mController.registerEventHandler(R.id.agenda_event_info, mEventInfoFragment); diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java index be6c1888..5f8c42ee 100644 --- a/src/com/android/calendar/Utils.java +++ b/src/com/android/calendar/Utils.java @@ -566,11 +566,6 @@ public class Utils { return mAllowWeekForDetailView; } - public static boolean isMultiPaneConfiguration (Context c) { - return (c.getResources().getConfiguration().screenLayout & - Configuration.SCREENLAYOUT_SIZE_XLARGE) != 0; - } - public static boolean getConfigBool(Context c, int key) { return c.getResources().getBoolean(key); } diff --git a/src/com/android/calendar/agenda/AgendaFragment.java b/src/com/android/calendar/agenda/AgendaFragment.java index 5dbb8083..f8db0ff0 100644 --- a/src/com/android/calendar/agenda/AgendaFragment.java +++ b/src/com/android/calendar/agenda/AgendaFragment.java @@ -342,7 +342,7 @@ public class AgendaFragment extends Fragment implements CalendarController.Event mEventFragment = new EventInfoFragment(mActivity, event.id, event.startTime.toMillis(true), event.endTime.toMillis(true), - response, false); + response, false, EventInfoFragment.DIALOG_WINDOW_STYLE); ft.replace(R.id.agenda_event_info, mEventFragment); mController.registerEventHandler(R.id.agenda_event_info, mEventFragment); diff --git a/src/com/android/calendar/agenda/AgendaListView.java b/src/com/android/calendar/agenda/AgendaListView.java index a8558cd5..1f6ff4d8 100644 --- a/src/com/android/calendar/agenda/AgendaListView.java +++ b/src/com/android/calendar/agenda/AgendaListView.java @@ -258,7 +258,7 @@ public class AgendaListView extends ListView implements OnItemClickListener { } } - @Override +/* @Override public int getFirstVisiblePosition() { // TODO File bug! // getFirstVisiblePosition doesn't always return the first visible @@ -275,7 +275,7 @@ public class AgendaListView extends ListView implements OnItemClickListener { } return -1; } - +*/ public View getFirstVisibleView() { Rect r = new Rect(); int childCount = getChildCount(); diff --git a/src/com/android/calendar/agenda/AgendaWindowAdapter.java b/src/com/android/calendar/agenda/AgendaWindowAdapter.java index 69011a8b..3481067b 100644 --- a/src/com/android/calendar/agenda/AgendaWindowAdapter.java +++ b/src/com/android/calendar/agenda/AgendaWindowAdapter.java @@ -452,7 +452,7 @@ public class AgendaWindowAdapter extends BaseAdapter selected = mSelectedInstanceId == vh.instanceId; vh.selectedMarker.setVisibility((selected && mShowEventOnStart) ? View.VISIBLE : View.GONE); - if (selected) { + if (selected && mShowEventOnStart) { mSelectedVH = vh; v.setBackgroundColor(mSelectedItemBackgroundColor); vh.title.setTextColor(mSelectedItemTextColor); diff --git a/src/com/android/calendar/event/EditEventActivity.java b/src/com/android/calendar/event/EditEventActivity.java index 56c488e2..1fdbbc5d 100644 --- a/src/com/android/calendar/event/EditEventActivity.java +++ b/src/com/android/calendar/event/EditEventActivity.java @@ -57,7 +57,7 @@ public class EditEventActivity extends AbstractCalendarActivity { mEditFragment = (EditEventFragment) getFragmentManager().findFragmentById(R.id.main_frame); - mIsMultipane = Utils.isMultiPaneConfiguration (this); + mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); if (mIsMultipane) { getActionBar().setDisplayOptions( diff --git a/src/com/android/calendar/event/EditEventFragment.java b/src/com/android/calendar/event/EditEventFragment.java index 06efedb9..c8b71227 100644 --- a/src/com/android/calendar/event/EditEventFragment.java +++ b/src/com/android/calendar/event/EditEventFragment.java @@ -423,7 +423,7 @@ public class EditEventFragment extends Fragment implements EventHandler { mInputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); - mUseCustomActionBar = !Utils.isMultiPaneConfiguration(mContext); + mUseCustomActionBar = !Utils.getConfigBool(mContext, R.bool.multiple_pane_config); } @Override diff --git a/src/com/android/calendar/selectcalendars/SelectVisibleCalendarsFragment.java b/src/com/android/calendar/selectcalendars/SelectVisibleCalendarsFragment.java index 5f6c6b5e..699f7b7a 100644 --- a/src/com/android/calendar/selectcalendars/SelectVisibleCalendarsFragment.java +++ b/src/com/android/calendar/selectcalendars/SelectVisibleCalendarsFragment.java @@ -111,7 +111,7 @@ public class SelectVisibleCalendarsFragment extends Fragment // Hide the Calendars to Sync button on tablets for now. // Long terms stick it in the list of calendars - if (Utils.isMultiPaneConfiguration(getActivity())) { + if (Utils.getConfigBool(getActivity(), R.bool.multiple_pane_config)) { // Don't show dividers on tablets mList.setDivider(null); View v = mView.findViewById(R.id.manage_sync_set); |