Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timob 13561: Android: Move Ti.Android.Calendar to Ti.Calendar and deprecate Ti.Android.Calendar #4173

Merged
merged 4 commits into from
Apr 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/dependency.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"analytics":[],
"android":[],
"app":[],
"calendar":["android"],
"calendar":[],
"contacts":[],
"database":[],
"filesystem":[],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

package ti.modules.titanium.android.calendar;

import android.app.Notification;
Expand All @@ -7,10 +14,11 @@
import android.content.Context;
import android.content.Intent;

public class AlarmReceiver extends BroadcastReceiver
@Deprecated
public class AlarmReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
public void onReceive(Context context, Intent intent)
{
NotificationManager manger = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
Expand All @@ -24,6 +32,6 @@ public void onReceive(Context context, Intent intent)
//TEST
notification.setLatestEventInfo(context,"Payment Reminder","Send me to jhaynie@appcelerator.com",contentIntent);
manger.notify(1, notification);
}
}
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

package ti.modules.titanium.android.calendar;

import java.util.ArrayList;
Expand All @@ -18,13 +25,14 @@
import android.database.Cursor;
import android.net.Uri;

@Deprecated
@Kroll.proxy(parentModule=CalendarModule.class)
public class AlertProxy extends KrollProxy {

public static final int STATE_SCHEDULED = 0;
public static final int STATE_FIRED = 1;
public static final int STATE_DISMISSED = 2;

protected String id, eventId;
protected Date begin, end;
protected Date alarmTime;
Expand All @@ -39,7 +47,7 @@ public AlertProxy(TiContext context)
{
this();
}

public static String getAlertsUri() {
return CalendarProxy.getBaseCalendarUri() + "/calendar_alerts";
}
Expand All @@ -48,16 +56,15 @@ public static String getAlertsInstanceUri() {
return CalendarProxy.getBaseCalendarUri() + "/calendar_alerts/by_instance";
}

public static ArrayList<AlertProxy> queryAlerts(String query, String queryArgs[], String orderBy) {
public static ArrayList<AlertProxy> queryAlerts(String query, String queryArgs[], String orderBy)
{
ArrayList<AlertProxy> alerts = new ArrayList<AlertProxy>();
ContentResolver contentResolver = TiApplication.getInstance().getContentResolver();

Cursor cursor = contentResolver.query(Uri.parse(getAlertsUri()),
new String[] { "_id", "event_id", "begin", "end", "alarmTime", "state", "minutes"},
query, queryArgs, orderBy);

if (cursor!=null)
{

Cursor cursor = contentResolver.query(Uri.parse(getAlertsUri()), new String[] { "_id", "event_id", "begin", "end",
"alarmTime", "state", "minutes" }, query, queryArgs, orderBy);

if (cursor != null) {
while (cursor.moveToNext()) {
AlertProxy alert = new AlertProxy();
alert.id = cursor.getString(0);
Expand All @@ -72,7 +79,7 @@ public static ArrayList<AlertProxy> queryAlerts(String query, String queryArgs[]

cursor.close();
}

return alerts;
}

Expand All @@ -89,14 +96,15 @@ public static ArrayList<AlertProxy> getAlertsForEvent(TiContext context, EventPr
return AlertProxy.getAlertsForEvent(event);
}

public static AlertProxy createAlert(EventProxy event, int minutes) {
public static AlertProxy createAlert(EventProxy event, int minutes)
{
ContentResolver contentResolver = TiApplication.getInstance().getContentResolver();
ContentValues values = new ContentValues();

Calendar alarmTime = Calendar.getInstance();
alarmTime.setTime(event.getBegin());
alarmTime.add(Calendar.MINUTE, -minutes);

values.put("event_id", event.getId());
values.put("begin", event.getBegin().getTime());
values.put("end", event.getEnd().getTime());
Expand All @@ -106,10 +114,10 @@ public static AlertProxy createAlert(EventProxy event, int minutes) {
values.put("creationTime", System.currentTimeMillis());
values.put("receivedTime", 0);
values.put("notifyTime", 0);

Uri alertUri = contentResolver.insert(Uri.parse(getAlertsUri()), values);
String alertId = alertUri.getLastPathSegment();

AlertProxy alert = new AlertProxy();
alert.id = alertId;
alert.begin = event.getBegin();
Expand Down Expand Up @@ -150,12 +158,12 @@ protected void registerAlertIntent(TiContext context) {
public String getId() {
return id;
}

@Kroll.getProperty @Kroll.method
public String getEventId() {
return eventId;
}

@Kroll.getProperty @Kroll.method
public Date getBegin() {
return begin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

package ti.modules.titanium.android.calendar;

import java.util.ArrayList;

import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.kroll.common.Log;

import android.os.Build;

import ti.modules.titanium.android.AndroidModule;

@Deprecated
@Kroll.module(parentModule=AndroidModule.class)
public class CalendarModule extends KrollModule
{
private static final String TAG = "CalendarModule";

@Kroll.constant public static final int STATUS_TENTATIVE = EventProxy.STATUS_TENTATIVE;
@Kroll.constant public static final int STATUS_CONFIRMED = EventProxy.STATUS_CONFIRMED;
@Kroll.constant public static final int STATUS_CANCELED = EventProxy.STATUS_CANCELED;

@Kroll.constant public static final int VISIBILITY_DEFAULT = EventProxy.VISIBILITY_DEFAULT;
@Kroll.constant public static final int VISIBILITY_CONFIDENTIAL = EventProxy.VISIBILITY_CONFIDENTIAL;
@Kroll.constant public static final int VISIBILITY_PRIVATE = EventProxy.VISIBILITY_PRIVATE;
@Kroll.constant public static final int VISIBILITY_PUBLIC = EventProxy.VISIBILITY_PUBLIC;

@Kroll.constant public static final int METHOD_ALERT = ReminderProxy.METHOD_ALERT;
@Kroll.constant public static final int METHOD_DEFAULT = ReminderProxy.METHOD_DEFAULT;
@Kroll.constant public static final int METHOD_EMAIL = ReminderProxy.METHOD_EMAIL;
@Kroll.constant public static final int METHOD_SMS = ReminderProxy.METHOD_SMS;

@Kroll.constant public static final int STATE_DISMISSED = AlertProxy.STATE_DISMISSED;
@Kroll.constant public static final int STATE_FIRED = AlertProxy.STATE_FIRED;
@Kroll.constant public static final int STATE_SCHEDULED = AlertProxy.STATE_SCHEDULED;
Expand All @@ -36,19 +47,20 @@ public class CalendarModule extends KrollModule
public CalendarModule()
{
super();
Log.w(TAG, "The Titanium.Android.Calendar module is deprecated. Use Titanium.Calendar instead.");
}

public CalendarModule(TiContext context)
{
this();
}

@Kroll.getProperty @Kroll.method
public CalendarProxy[] getAllCalendars() {
ArrayList<CalendarProxy> calendars = CalendarProxy.queryCalendars(null, null);
return calendars.toArray(new CalendarProxy[calendars.size()]);
}

@Kroll.getProperty @Kroll.method
public CalendarProxy[] getSelectableCalendars() {
ArrayList<CalendarProxy> calendars;
Expand All @@ -69,19 +81,19 @@ else if (Build.VERSION.SDK_INT >= 11) { // HONEYCOMB, 3.0
}
return calendars.toArray(new CalendarProxy[calendars.size()]);
}

@Kroll.method
public CalendarProxy getCalendarById(int id) {
ArrayList<CalendarProxy> calendars = CalendarProxy.queryCalendars(
"Calendars._id = ?", new String[] { ""+id });

if (calendars.size() > 0) {
return calendars.get(0);
} else {
return null;
}
}

@Kroll.getProperty @Kroll.method
public AlertProxy[] getAllAlerts() {
ArrayList<AlertProxy> alerts = AlertProxy.queryAlerts(null, null, null);
Expand Down