summaryrefslogtreecommitdiffstats
path: root/src/com/android/calendar/AllInOneActivity.java
diff options
context:
space:
mode:
authoryingying <yingying@codeaurora.org>2013-12-30 03:53:21 -0500
committerSteve Kondik <steve@cyngn.com>2015-10-18 13:52:39 -0700
commite0978b2e507b21692d70886dd6437ad8762d0221 (patch)
tree58a44d7f7b892f3781927ef9718c3dde96fd732d /src/com/android/calendar/AllInOneActivity.java
parent52463f36899c9051c42ac784077e514864e52373 (diff)
downloadandroid_packages_apps_Calendar-e0978b2e507b21692d70886dd6437ad8762d0221.tar.gz
android_packages_apps_Calendar-e0978b2e507b21692d70886dd6437ad8762d0221.tar.bz2
android_packages_apps_Calendar-e0978b2e507b21692d70886dd6437ad8762d0221.zip
Calendar: Support display the lunar info.
- It will show the lunar info on the Month, Week and Day view. - If the current displayed language is not Chinese, it will not show the lunar info for on these views. Change-Id: I1aeb4bc27dbdd127e69ceb0bf50abc1509cf4bb2
Diffstat (limited to 'src/com/android/calendar/AllInOneActivity.java')
-rw-r--r--src/com/android/calendar/AllInOneActivity.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java
index 0e1feb49..9b623e4f 100644
--- a/src/com/android/calendar/AllInOneActivity.java
+++ b/src/com/android/calendar/AllInOneActivity.java
@@ -31,9 +31,12 @@ import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentUris;
+import android.content.Context;
import android.content.Intent;
+import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Configuration;
@@ -44,6 +47,7 @@ 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;
@@ -71,6 +75,8 @@ 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.List;
@@ -167,6 +173,23 @@ 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
@@ -307,6 +330,12 @@ 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);
}
@@ -610,6 +639,11 @@ 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);