Loading res/layout/actionbar_pulldown_menu_top_button_no_date.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 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. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="48dip" android:minWidth="192dip" android:singleLine="true" android:textSize="18sp" android:textColor="@color/calendar_view_switch_menu_text_color" android:gravity="left|center_vertical" android:paddingLeft="12dip"/> src/com/android/calendar/AllInOneActivity.java +8 −9 Original line number Diff line number Diff line Loading @@ -460,11 +460,7 @@ public class AllInOneActivity extends Activity implements EventHandler, } private void configureActionBar(int viewType) { if (mIsTabletConfig) { createTabs(); } else { createButtonsSpinner(viewType); } createButtonsSpinner(viewType, mIsTabletConfig); if (mIsMultipane) { mActionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); Loading Loading @@ -498,8 +494,9 @@ public class AllInOneActivity extends Activity implements EventHandler, } } private void createButtonsSpinner(int viewType) { mActionBarMenuSpinnerAdapter = new CalendarViewAdapter (this, viewType); private void createButtonsSpinner(int viewType, boolean tabletConfig) { // If tablet configuration , show spinner with no dates mActionBarMenuSpinnerAdapter = new CalendarViewAdapter (this, viewType, !tabletConfig); mActionBar = getActionBar(); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mActionBar.setListNavigationCallbacks(mActionBarMenuSpinnerAdapter, this); Loading Loading @@ -940,9 +937,11 @@ public class AllInOneActivity extends Activity implements EventHandler, // Update the current view so that the menu can update its look according to the // current view. if (!mIsTabletConfig && mActionBarMenuSpinnerAdapter != null) { mActionBarMenuSpinnerAdapter.setTime(timeMillis); if (mActionBarMenuSpinnerAdapter != null) { mActionBarMenuSpinnerAdapter.setMainView(viewType); if (!mIsTabletConfig) { mActionBarMenuSpinnerAdapter.setTime(timeMillis); } } Loading src/com/android/calendar/CalendarViewAdapter.java +96 −52 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ public class CalendarViewAdapter extends BaseAdapter { private static final String TAG = "MenuSpinnerAdapter"; private String mButtonNames []; // Text on buttons private final String mButtonNames []; // Text on buttons // Used to define the look of the menu button according to the current view: // Day view: show day of the week + full date underneath Loading @@ -65,29 +65,31 @@ public class CalendarViewAdapter extends BaseAdapter { // The current selected event's time, used to calculate the date and day of the week // for the buttons. long mMilliTime; String mTimeZone; long mTodayJulianDay; private long mMilliTime; private String mTimeZone; private long mTodayJulianDay; Context mContext; private Formatter mFormatter; private StringBuilder mStringBuilder; private final Context mContext; private final Formatter mFormatter; private final StringBuilder mStringBuilder; private Handler mMidnightHandler = null; // Used to run a time update every midnight private final boolean mShowDate; // Spinner mode indicator (view name or view name with date) // Updates time specific variables (time-zone, today's Julian day). private Runnable mTimeUpdater = new Runnable() { private final Runnable mTimeUpdater = new Runnable() { @Override public void run() { refresh(mContext); } }; public CalendarViewAdapter(Context context, int viewType) { public CalendarViewAdapter(Context context, int viewType, boolean showDate) { super(); mMidnightHandler = new Handler(); mCurrentMainView = viewType; mContext = context; mShowDate = showDate; // Initialize mButtonNames = context.getResources().getStringArray(R.array.buttons_list); Loading @@ -96,8 +98,10 @@ public class CalendarViewAdapter extends BaseAdapter { mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); // Sets time specific variables and starts a thread for midnight updates if (showDate) { refresh(context); } } // Sets the time zone and today's Julian day to be used by the adapter. Loading Loading @@ -160,12 +164,14 @@ public class CalendarViewAdapter extends BaseAdapter { public View getView(int position, View convertView, ViewGroup parent) { View v; if (mShowDate) { // Check if can recycle the view if (convertView == null || ((Integer)convertView.getTag()).intValue() != R.layout.actionbar_pulldown_menu_top_button) { if (convertView == null || ((Integer) convertView.getTag()).intValue() != R.layout.actionbar_pulldown_menu_top_button) { v = mInflater.inflate(R.layout.actionbar_pulldown_menu_top_button, parent, false); // Set the tag to make sure you can recycle it when you get it as a convert view // Set the tag to make sure you can recycle it when you get it // as a convert view v.setTag(new Integer(R.layout.actionbar_pulldown_menu_top_button)); } else { v = convertView; Loading Loading @@ -201,6 +207,36 @@ public class CalendarViewAdapter extends BaseAdapter { v = null; break; } } else { if (convertView == null || ((Integer) convertView.getTag()).intValue() != R.layout.actionbar_pulldown_menu_top_button_no_date) { v = mInflater.inflate( R.layout.actionbar_pulldown_menu_top_button_no_date, parent, false); // Set the tag to make sure you can recycle it when you get it // as a convert view v.setTag(new Integer(R.layout.actionbar_pulldown_menu_top_button_no_date)); } else { v = convertView; } TextView title = (TextView) v; switch (mCurrentMainView) { case ViewType.DAY: title.setText(mButtonNames [DAY_BUTTON_INDEX]); break; case ViewType.WEEK: title.setText(mButtonNames [WEEK_BUTTON_INDEX]); break; case ViewType.MONTH: title.setText(mButtonNames [MONTH_BUTTON_INDEX]); break; case ViewType.AGENDA: title.setText(mButtonNames [AGENDA_BUTTON_INDEX]); break; default: v = null; break; } } return v; } Loading Loading @@ -228,19 +264,27 @@ public class CalendarViewAdapter extends BaseAdapter { switch (position) { case DAY_BUTTON_INDEX: viewType.setText(mButtonNames [DAY_BUTTON_INDEX]); if (mShowDate) { date.setText(buildMonthDayDate()); } break; case WEEK_BUTTON_INDEX: viewType.setText(mButtonNames [WEEK_BUTTON_INDEX]); if (mShowDate) { date.setText(buildWeekDate()); } break; case MONTH_BUTTON_INDEX: viewType.setText(mButtonNames [MONTH_BUTTON_INDEX]); if (mShowDate) { date.setText(buildMonthDate()); } break; case AGENDA_BUTTON_INDEX: viewType.setText(mButtonNames [AGENDA_BUTTON_INDEX]); if (mShowDate) { date.setText(buildMonthDayDate()); } break; default: v = convertView; Loading Loading
res/layout/actionbar_pulldown_menu_top_button_no_date.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 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. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="48dip" android:minWidth="192dip" android:singleLine="true" android:textSize="18sp" android:textColor="@color/calendar_view_switch_menu_text_color" android:gravity="left|center_vertical" android:paddingLeft="12dip"/>
src/com/android/calendar/AllInOneActivity.java +8 −9 Original line number Diff line number Diff line Loading @@ -460,11 +460,7 @@ public class AllInOneActivity extends Activity implements EventHandler, } private void configureActionBar(int viewType) { if (mIsTabletConfig) { createTabs(); } else { createButtonsSpinner(viewType); } createButtonsSpinner(viewType, mIsTabletConfig); if (mIsMultipane) { mActionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); Loading Loading @@ -498,8 +494,9 @@ public class AllInOneActivity extends Activity implements EventHandler, } } private void createButtonsSpinner(int viewType) { mActionBarMenuSpinnerAdapter = new CalendarViewAdapter (this, viewType); private void createButtonsSpinner(int viewType, boolean tabletConfig) { // If tablet configuration , show spinner with no dates mActionBarMenuSpinnerAdapter = new CalendarViewAdapter (this, viewType, !tabletConfig); mActionBar = getActionBar(); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mActionBar.setListNavigationCallbacks(mActionBarMenuSpinnerAdapter, this); Loading Loading @@ -940,9 +937,11 @@ public class AllInOneActivity extends Activity implements EventHandler, // Update the current view so that the menu can update its look according to the // current view. if (!mIsTabletConfig && mActionBarMenuSpinnerAdapter != null) { mActionBarMenuSpinnerAdapter.setTime(timeMillis); if (mActionBarMenuSpinnerAdapter != null) { mActionBarMenuSpinnerAdapter.setMainView(viewType); if (!mIsTabletConfig) { mActionBarMenuSpinnerAdapter.setTime(timeMillis); } } Loading
src/com/android/calendar/CalendarViewAdapter.java +96 −52 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ public class CalendarViewAdapter extends BaseAdapter { private static final String TAG = "MenuSpinnerAdapter"; private String mButtonNames []; // Text on buttons private final String mButtonNames []; // Text on buttons // Used to define the look of the menu button according to the current view: // Day view: show day of the week + full date underneath Loading @@ -65,29 +65,31 @@ public class CalendarViewAdapter extends BaseAdapter { // The current selected event's time, used to calculate the date and day of the week // for the buttons. long mMilliTime; String mTimeZone; long mTodayJulianDay; private long mMilliTime; private String mTimeZone; private long mTodayJulianDay; Context mContext; private Formatter mFormatter; private StringBuilder mStringBuilder; private final Context mContext; private final Formatter mFormatter; private final StringBuilder mStringBuilder; private Handler mMidnightHandler = null; // Used to run a time update every midnight private final boolean mShowDate; // Spinner mode indicator (view name or view name with date) // Updates time specific variables (time-zone, today's Julian day). private Runnable mTimeUpdater = new Runnable() { private final Runnable mTimeUpdater = new Runnable() { @Override public void run() { refresh(mContext); } }; public CalendarViewAdapter(Context context, int viewType) { public CalendarViewAdapter(Context context, int viewType, boolean showDate) { super(); mMidnightHandler = new Handler(); mCurrentMainView = viewType; mContext = context; mShowDate = showDate; // Initialize mButtonNames = context.getResources().getStringArray(R.array.buttons_list); Loading @@ -96,8 +98,10 @@ public class CalendarViewAdapter extends BaseAdapter { mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); // Sets time specific variables and starts a thread for midnight updates if (showDate) { refresh(context); } } // Sets the time zone and today's Julian day to be used by the adapter. Loading Loading @@ -160,12 +164,14 @@ public class CalendarViewAdapter extends BaseAdapter { public View getView(int position, View convertView, ViewGroup parent) { View v; if (mShowDate) { // Check if can recycle the view if (convertView == null || ((Integer)convertView.getTag()).intValue() != R.layout.actionbar_pulldown_menu_top_button) { if (convertView == null || ((Integer) convertView.getTag()).intValue() != R.layout.actionbar_pulldown_menu_top_button) { v = mInflater.inflate(R.layout.actionbar_pulldown_menu_top_button, parent, false); // Set the tag to make sure you can recycle it when you get it as a convert view // Set the tag to make sure you can recycle it when you get it // as a convert view v.setTag(new Integer(R.layout.actionbar_pulldown_menu_top_button)); } else { v = convertView; Loading Loading @@ -201,6 +207,36 @@ public class CalendarViewAdapter extends BaseAdapter { v = null; break; } } else { if (convertView == null || ((Integer) convertView.getTag()).intValue() != R.layout.actionbar_pulldown_menu_top_button_no_date) { v = mInflater.inflate( R.layout.actionbar_pulldown_menu_top_button_no_date, parent, false); // Set the tag to make sure you can recycle it when you get it // as a convert view v.setTag(new Integer(R.layout.actionbar_pulldown_menu_top_button_no_date)); } else { v = convertView; } TextView title = (TextView) v; switch (mCurrentMainView) { case ViewType.DAY: title.setText(mButtonNames [DAY_BUTTON_INDEX]); break; case ViewType.WEEK: title.setText(mButtonNames [WEEK_BUTTON_INDEX]); break; case ViewType.MONTH: title.setText(mButtonNames [MONTH_BUTTON_INDEX]); break; case ViewType.AGENDA: title.setText(mButtonNames [AGENDA_BUTTON_INDEX]); break; default: v = null; break; } } return v; } Loading Loading @@ -228,19 +264,27 @@ public class CalendarViewAdapter extends BaseAdapter { switch (position) { case DAY_BUTTON_INDEX: viewType.setText(mButtonNames [DAY_BUTTON_INDEX]); if (mShowDate) { date.setText(buildMonthDayDate()); } break; case WEEK_BUTTON_INDEX: viewType.setText(mButtonNames [WEEK_BUTTON_INDEX]); if (mShowDate) { date.setText(buildWeekDate()); } break; case MONTH_BUTTON_INDEX: viewType.setText(mButtonNames [MONTH_BUTTON_INDEX]); if (mShowDate) { date.setText(buildMonthDate()); } break; case AGENDA_BUTTON_INDEX: viewType.setText(mButtonNames [AGENDA_BUTTON_INDEX]); if (mShowDate) { date.setText(buildMonthDayDate()); } break; default: v = convertView; Loading