diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/calendar/AllInOneActivity.java | 33 | ||||
-rw-r--r-- | src/com/android/calendar/CalendarViewAdapter.java | 96 | ||||
-rw-r--r-- | src/com/android/calendar/DayView.java | 61 | ||||
-rw-r--r-- | src/com/android/calendar/month/MonthWeekEventsView.java | 57 | ||||
-rw-r--r-- | src/com/android/lunar/ILunarService.aidl | 50 | ||||
-rw-r--r-- | src/com/android/lunar/LunarUtils.java | 80 |
6 files changed, 4 insertions, 373 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java index bb32ac2e..17aaff1b 100644 --- a/src/com/android/calendar/AllInOneActivity.java +++ b/src/com/android/calendar/AllInOneActivity.java @@ -35,7 +35,6 @@ import android.app.FragmentTransaction; import android.app.LoaderManager; import android.content.AsyncQueryHandler; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; @@ -43,7 +42,6 @@ import android.content.CursorLoader; import android.content.DialogInterface; import android.content.Loader; import android.content.Intent; -import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; @@ -54,7 +52,6 @@ import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.os.IBinder; import android.provider.CalendarContract; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Calendars; @@ -83,8 +80,6 @@ import com.android.calendar.CalendarController.ViewType; import com.android.calendar.agenda.AgendaFragment; import com.android.calendar.month.MonthByWeekFragment; import com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment; -import com.android.lunar.ILunarService; -import com.android.lunar.LunarUtils; import java.io.IOException; import java.util.Calendar; @@ -183,23 +178,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH private AllInOneMenuExtensionsInterface mExtensions = ExtensionsFactory .getAllInOneMenuExtensions(); - // To connect the lunar service - private ILunarService mLunarService = null; - private ServiceConnection mLunarConnection = new ServiceConnection() { - - @Override - public void onServiceDisconnected(ComponentName name) { - mLunarService = null; - LunarUtils.setService(null); - } - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - mLunarService = ILunarService.Stub.asInterface(service); - LunarUtils.setService(mLunarService); - } - }; - private final AnimatorListener mSlideAnimationDoneListener = new AnimatorListener() { @Override @@ -340,12 +318,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH } super.onCreate(icicle); - // Bind the lunar service - if (LunarUtils.showLunar() && mLunarService == null) { - bindService(new Intent(ILunarService.class.getName()), mLunarConnection, - Context.BIND_AUTO_CREATE); - } - if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) { mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS); } @@ -655,11 +627,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH protected void onDestroy() { super.onDestroy(); - // Unbind the lunar service - if (mLunarService != null && mLunarConnection != null) { - unbindService(mLunarConnection); - } - SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this); prefs.unregisterOnSharedPreferenceChangeListener(this); diff --git a/src/com/android/calendar/CalendarViewAdapter.java b/src/com/android/calendar/CalendarViewAdapter.java index 1e75d1fd..3928e44a 100644 --- a/src/com/android/calendar/CalendarViewAdapter.java +++ b/src/com/android/calendar/CalendarViewAdapter.java @@ -17,17 +17,11 @@ package com.android.calendar; import com.android.calendar.CalendarController.ViewType; -import com.android.lunar.ILunarService; -import com.android.lunar.LunarUtils; -import com.android.lunar.LunarUtils.LunarServiceConnListener; import android.content.Context; import android.os.Handler; -import android.os.RemoteException; -import android.text.TextUtils; import android.text.format.DateUtils; import android.text.format.Time; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -35,7 +29,6 @@ import android.widget.BaseAdapter; import android.widget.TextView; import java.util.Formatter; -import java.util.HashMap; import java.util.Locale; @@ -82,24 +75,6 @@ public class CalendarViewAdapter extends BaseAdapter { 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) - // Create the connect listener for lunar service. - private HashMap<String, String> mLunarInfoMap = new HashMap<String, String>(); - private LunarServiceConnListener mLunarServiceConnListener = new LunarServiceConnListener() { - - @Override - public void onLunarServiceDisconnected() { - notifyDataSetChanged(); - } - - @Override - public void onLunarServiceConnected(ILunarService service) { - if (service != null && LunarUtils.getService() != null && LunarUtils.showLunar()) { - buildLunarInfo(); - notifyDataSetChanged(); - } - } - }; - // Updates time specific variables (time-zone, today's Julian day). private final Runnable mTimeUpdater = new Runnable() { @Override @@ -122,8 +97,6 @@ public class CalendarViewAdapter extends BaseAdapter { mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); - LunarUtils.setListener(mLunarServiceConnListener); - // Sets time specific variables and starts a thread for midnight updates if (showDate) { refresh(context); @@ -204,30 +177,15 @@ public class CalendarViewAdapter extends BaseAdapter { v = convertView; } TextView weekDay = (TextView) v.findViewById(R.id.top_button_weekday); - TextView lunarInfo = (TextView) v.findViewById(R.id.top_button_lunar); TextView date = (TextView) v.findViewById(R.id.top_button_date); switch (mCurrentMainView) { case ViewType.DAY: weekDay.setVisibility(View.VISIBLE); weekDay.setText(buildDayOfWeek()); - if (LunarUtils.getService() != null && LunarUtils.showLunar()) { - lunarInfo.setVisibility(View.VISIBLE); - String dateStr = Utils.formatDateRange(mContext, mMilliTime, mMilliTime, - DateUtils.FORMAT_SHOW_DATE); - if (mLunarInfoMap.containsKey(dateStr)) { - lunarInfo.setText(mLunarInfoMap.get(dateStr)); - } else { - buildLunarInfo(); - notifyDataSetChanged(); - } - } else { - lunarInfo.setVisibility(View.GONE); - } date.setText(buildFullDate()); break; case ViewType.WEEK: - lunarInfo.setVisibility(View.GONE); if (Utils.getShowWeekNumber(mContext)) { weekDay.setVisibility(View.VISIBLE); weekDay.setText(buildWeekNum()); @@ -238,12 +196,10 @@ public class CalendarViewAdapter extends BaseAdapter { break; case ViewType.MONTH: weekDay.setVisibility(View.GONE); - lunarInfo.setVisibility(View.GONE); date.setText(buildMonthYearDate()); break; case ViewType.AGENDA: weekDay.setVisibility(View.VISIBLE); - lunarInfo.setVisibility(View.GONE); weekDay.setText(buildDayOfWeek()); date.setText(buildFullDate()); break; @@ -348,14 +304,6 @@ public class CalendarViewAdapter extends BaseAdapter { // Used when the user selects a new day/week/month to watch public void setTime(long time) { mMilliTime = time; - if (LunarUtils.getService() != null && LunarUtils.showLunar()) { - new Thread (new Runnable() { - @Override - public void run() { - buildLunarInfo(); - } - }).start(); - } notifyDataSetChanged(); } @@ -473,49 +421,5 @@ public class CalendarViewAdapter extends BaseAdapter { return mContext.getResources().getQuantityString(R.plurals.weekN, week, week); } - private void buildLunarInfo() { - if (TextUtils.isEmpty(mTimeZone)) return; - - Time time = new Time(mTimeZone); - try { - ILunarService service = LunarUtils.getService(); - if (service != null && time != null) { - // put the current time lunar string into map - time.set(mMilliTime); - String date = Utils.formatDateRange(mContext, mMilliTime, mMilliTime, - DateUtils.FORMAT_SHOW_DATE); - if (!mLunarInfoMap.containsKey(date)) { - String lunarInfo = service.getLunarStringForDayView( - time.year, time.month, time.monthDay); - mLunarInfoMap.put(date, lunarInfo); - } - - // put the pre time lunar string into map - long preMilliTime = mMilliTime - 24 * 3600 * 1000; - time.set(preMilliTime); - date = Utils.formatDateRange(mContext, preMilliTime, preMilliTime, - DateUtils.FORMAT_SHOW_DATE); - if (!mLunarInfoMap.containsKey(date)) { - String lunarInfo = service.getLunarStringForDayView( - time.year, time.month, time.monthDay); - mLunarInfoMap.put(date, lunarInfo); - } - - // put the next time lunar string into map - long nextMilliTime = mMilliTime + 24 * 3600 * 1000; - time.set(nextMilliTime); - date = Utils.formatDateRange(mContext, nextMilliTime, nextMilliTime, - DateUtils.FORMAT_SHOW_DATE); - if (!mLunarInfoMap.containsKey(date)) { - String lunarInfo = service.getLunarStringForDayView( - time.year, time.month, time.monthDay); - mLunarInfoMap.put(date, lunarInfo); - } - } - } catch (RemoteException e) { - Log.e(TAG, "build lunar info, catch the RemoteException:"); - e.printStackTrace(); - } - } } diff --git a/src/com/android/calendar/DayView.java b/src/com/android/calendar/DayView.java index 7f6cbce6..68ae6a46 100644 --- a/src/com/android/calendar/DayView.java +++ b/src/com/android/calendar/DayView.java @@ -38,7 +38,6 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Handler; -import android.os.RemoteException; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Calendars; import android.provider.CalendarContract.Events; @@ -80,9 +79,6 @@ import android.widget.ViewSwitcher; import com.android.calendar.CalendarController.EventType; import com.android.calendar.CalendarController.ViewType; -import com.android.lunar.ILunarService; -import com.android.lunar.LunarUtils; -import com.android.lunar.LunarUtils.LunarServiceConnListener; import java.util.ArrayList; import java.util.Arrays; @@ -200,24 +196,6 @@ public class DayView extends View implements View.OnCreateContextMenuListener, // TODO recreate formatter when locale changes protected static Formatter mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); - private LunarServiceConnListener mLunarServiceConnListener = new LunarServiceConnListener() { - - @Override - public void onLunarServiceDisconnected() { - DAY_HEADER_HEIGHT = mNumDays == 1 ? ONE_DAY_HEADER_HEIGHT : MULTI_DAY_HEADER_HEIGHT; - } - - @Override - public void onLunarServiceConnected(ILunarService service) { - if (service != null) { - DAY_HEADER_HEIGHT = mNumDays == 1 ? ONE_DAY_HEADER_HEIGHT : MULTI_DAY_HEADER_HEIGHT; - if (LunarUtils.showLunar() && mNumDays != 1) { - DAY_HEADER_HEIGHT = (int) (DAY_HEADER_HEIGHT + DAY_HEADER_FONT_SIZE + 2); - } - } - } - }; - private final Runnable mTZUpdater = new Runnable() { @Override public void run() { @@ -795,8 +773,6 @@ public class DayView extends View implements View.OnCreateContextMenuListener, mOnDownDelay = ViewConfiguration.getTapTimeout(); OVERFLING_DISTANCE = vc.getScaledOverflingDistance(); - LunarUtils.setListener(mLunarServiceConnListener); - init(context); } @@ -2584,12 +2560,8 @@ public class DayView extends View implements View.OnCreateContextMenuListener, // Draw day of the month String dateNumStr = String.valueOf(dateNum); if (mNumDays > 1) { - float y = -1; - if (LunarUtils.showLunar() && LunarUtils.getService() != null) { - y = DAY_HEADER_HEIGHT - DAY_HEADER_BOTTOM_MARGIN - DATE_HEADER_FONT_SIZE - 2; - } else { - y = DAY_HEADER_HEIGHT - DAY_HEADER_BOTTOM_MARGIN; - } + float y = DAY_HEADER_HEIGHT - DAY_HEADER_BOTTOM_MARGIN; + // Draw day of the month x = computeDayLeftPosition(day + 1) - DAY_HEADER_RIGHT_MARGIN; p.setTextAlign(Align.RIGHT); @@ -2599,35 +2571,10 @@ public class DayView extends View implements View.OnCreateContextMenuListener, canvas.drawText(dateNumStr, x, y, p); // Draw day of the week - int dateX = (int) (x - p.measureText(" " + dateNumStr)); + x -= p.measureText(" " + dateNumStr); p.setTextSize(DAY_HEADER_FONT_SIZE); p.setTypeface(Typeface.DEFAULT); - canvas.drawText(dayStr, dateX, y, p); - - // To show the lunar info. - ILunarService service = LunarUtils.getService(); - if (LunarUtils.showLunar() && service != null) { - // adjust the year and month - int month = mBaseDate.month; - int year = mBaseDate.year; - if (dateNum > mMonthLength || dateNum < mFirstVisibleDate) { - month = month + 1; - if (month > 11) { - month = 0; - year = year + 1; - } - } - - try { - String display = service.getLunarDay(year, month, dateNum); - if (!TextUtils.isEmpty(display)) { - canvas.drawText(display, x, y + DAY_HEADER_FONT_SIZE + 2, p); - } - } catch (RemoteException e) { - Log.e(TAG, "RemoteException e:" + e.toString()); - e.printStackTrace(); - } - } + canvas.drawText(dayStr, x, y, p); } else { float y = ONE_DAY_HEADER_HEIGHT - DAY_HEADER_ONE_DAY_BOTTOM_MARGIN; p.setTextAlign(Align.LEFT); diff --git a/src/com/android/calendar/month/MonthWeekEventsView.java b/src/com/android/calendar/month/MonthWeekEventsView.java index a5dd5dae..e1c78c67 100644 --- a/src/com/android/calendar/month/MonthWeekEventsView.java +++ b/src/com/android/calendar/month/MonthWeekEventsView.java @@ -19,8 +19,6 @@ package com.android.calendar.month; import com.android.calendar.Event; import com.android.calendar.R; import com.android.calendar.Utils; -import com.android.lunar.ILunarService; -import com.android.lunar.LunarUtils; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -36,7 +34,6 @@ import android.graphics.Paint.Align; import android.graphics.Paint.Style; import android.graphics.Typeface; import android.graphics.drawable.Drawable; -import android.os.RemoteException; import android.provider.CalendarContract.Attendees; import android.text.TextPaint; import android.text.TextUtils; @@ -67,7 +64,6 @@ public class MonthWeekEventsView extends SimpleWeekView { /* NOTE: these are not constants, and may be multiplied by a scale factor */ private static int TEXT_SIZE_MONTH_NUMBER = 32; - private static int TEXT_SIZE_LUNAR = 18; private static int TEXT_SIZE_EVENT = 12; private static int TEXT_SIZE_EVENT_TITLE = 14; private static int TEXT_SIZE_MORE_EVENTS = 12; @@ -700,12 +696,6 @@ public class MonthWeekEventsView extends SimpleWeekView { boolean isFocusMonth = mFocusDay[i]; boolean isBold = false; mMonthNumPaint.setColor(isFocusMonth ? mMonthNumColor : mMonthNumOtherColor); - - // Get the julian monday used to show the lunar info. - int julianMonday = Utils.getJulianMondayFromWeeksSinceEpoch(mWeek); - Time time = new Time(mTimeZone); - time.setJulianDay(julianMonday); - for (; i < numCount; i++) { if (mHasToday && todayIndex == i) { mMonthNumPaint.setColor(mMonthNumTodayColor); @@ -724,53 +714,6 @@ public class MonthWeekEventsView extends SimpleWeekView { if (isBold) { mMonthNumPaint.setFakeBoldText(isBold = false); } - - ILunarService service = LunarUtils.getService(); - if (LunarUtils.showLunar() && service != null) { - // adjust the year and month - int year = time.year; - int month = time.month; - int julianMondayDay = time.monthDay; - int monthDay = Integer.parseInt(mDayNumbers[i]); - if (monthDay != julianMondayDay) { - int offsetDay = monthDay - julianMondayDay; - if (offsetDay > 0 && offsetDay > 6) { - month = month - 1; - if (month < 0) { - month = 11; - year = year - 1; - } - } else if (offsetDay < 0 && offsetDay < -6) { - month = month + 1; - if (month > 11) { - month = 0; - year = year + 1; - } - } - } - - try { - String display = service.getLunarDay(year, month, monthDay); - if (!TextUtils.isEmpty(display)) { - float originalTextSize = mMonthNumPaint.getTextSize(); - mMonthNumPaint.setTextSize(TEXT_SIZE_LUNAR); - Resources res = getResources(); - int mOrientation = res.getConfiguration().orientation; - if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) { - canvas.drawText(display, x - mMonthNumHeight - TOP_PADDING_MONTH_NUMBER, - y , mMonthNumPaint); - } else { - canvas.drawText(display, x, y + mMonthNumHeight - + TOP_PADDING_MONTH_NUMBER, mMonthNumPaint); - } - // restore the text size. - mMonthNumPaint.setTextSize(originalTextSize); - } - } catch (RemoteException e) { - Log.e(TAG, "RemoteException e:" + e.toString()); - e.printStackTrace(); - } - } } } diff --git a/src/com/android/lunar/ILunarService.aidl b/src/com/android/lunar/ILunarService.aidl deleted file mode 100644 index f5a24f32..00000000 --- a/src/com/android/lunar/ILunarService.aidl +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.lunar; - -interface ILunarService { - String getTraditionalFestivalSimple(); - String getTraditionalFestival(int lunarYear, int lunarMonth, int lunarDay); - String getFestivalSimple(); - String getFestival(int year, int month, int day); - String getLunarSolarTerms(int year); - String getAnimalsYearSimple(); - String getAnimalsYear(int lunarYear); - String getChinaMonthStringSimple(); - String getChinaMonthString(int lunarMonth, boolean isLeapMonth); - String getChinaDayStringSimple(boolean isDisplayLunarMonthForFirstDay); - String getChinaDayString(int lunarMonth, int lunarDay, boolean isLeapMonth, - boolean isDisplayLunarMonthForFirstDay); - String getChinaYearStringSimple(); - String getChinaYearString(int lunarYear); - String getLunarCalendarInfo(); - String getLunarStringForDayView(int year, int month, int monthDay); - String getLunarDay(int year, int month, int monthDay); -} diff --git a/src/com/android/lunar/LunarUtils.java b/src/com/android/lunar/LunarUtils.java deleted file mode 100644 index b9721ed9..00000000 --- a/src/com/android/lunar/LunarUtils.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.lunar; - -import java.util.Locale; - -public class LunarUtils { - - private static ILunarService sService = null; - private static LunarServiceConnListener sListener = null; - - public static void setService(ILunarService service) { - sService = service; - if (sListener != null) { - if (sService != null) { - sListener.onLunarServiceConnected(sService); - } else { - sListener.onLunarServiceDisconnected(); - } - } - } - - public static ILunarService getService() { - return sService; - } - - public static void setListener(LunarServiceConnListener l) { - sListener = l; - if (l != null && sService != null) { - l.onLunarServiceConnected(sService); - } - } - - public static LunarServiceConnListener getListener() { - return sListener; - } - - public static boolean showLunar() { - Locale locale = Locale.getDefault(); - String language = locale.getLanguage(); - String country = locale.getCountry().toLowerCase(); - if ("zh".equals(language) && "cn".equals(country)) { - return true; - } else { - return false; - } - } - - public interface LunarServiceConnListener { - public void onLunarServiceConnected(ILunarService service); - public void onLunarServiceDisconnected(); - } -} |