Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-25619
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokesh Choudhary committed Feb 26, 2018
2 parents 6387f98 + 84b1bdf commit f59ef8f
Show file tree
Hide file tree
Showing 35 changed files with 890 additions and 88 deletions.
20 changes: 9 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = function (grunt) {
'android/runtime/*/src/**/*.java',
'android/titanium/src/**/*.java'
];
const allSrc = iosSrc.concat(androidSrc);

// Project configuration.
grunt.initConfig({
Expand All @@ -30,13 +29,12 @@ module.exports = function (grunt) {
]
},
clangFormat: {
src: allSrc
android: { src: androidSrc },
ios: { src: iosSrc }
},
ios_format: {
src: iosSrc
},
android_format: {
src: androidSrc
checkFormat: {
android: { src: androidSrc },
ios: { src: iosSrc }
}
});

Expand Down Expand Up @@ -117,8 +115,8 @@ module.exports = function (grunt) {
});
}

grunt.registerMultiTask('ios_format', 'Validates the iOS source code formatting.', validateFormatting);
grunt.registerMultiTask('android_format', 'Validates the Android source code formatting.', validateFormatting);
grunt.registerMultiTask('checkFormat', 'Validates the source code formatting.', validateFormatting);
// grunt.registerMultiTask('android_format', 'Validates the Android source code formatting.', validateFormatting);

// Load grunt plugins for modules
grunt.loadNpmTasks('grunt-mocha-test');
Expand All @@ -127,10 +125,10 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');

// register tasks
grunt.registerTask('lint', [ 'appcJs', 'ios_format', 'android_format', 'validate_docs' ]);
grunt.registerTask('lint', [ 'appcJs', 'checkFormat:ios', 'checkFormat:android', 'validate_docs' ]);

// register tasks
grunt.registerTask('format', [ 'clangFormat' ]);
grunt.registerTask('format', [ 'clangFormat:android', 'clangFormat:ios' ]);

// register tasks
grunt.registerTask('default', [ 'lint' ]);
Expand Down
2 changes: 1 addition & 1 deletion android/cli/lib/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports.render = function (logger, config, rpad, styleHeading, styleValue, style
);

logger.log(styleHeading(__('Android NDK')) + '\n'
+ +' ' + rpad(__('NDK Path')) + ' = ' + styleValue(data.ndk && data.ndk.path || __('not found')) + '\n'
+ ' ' + rpad(__('NDK Path')) + ' = ' + styleValue(data.ndk && data.ndk.path || __('not found')) + '\n'
+ ' ' + rpad(__('NDK Version')) + ' = ' + styleValue(data.ndk && data.ndk.version || __('not found')) + '\n'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ void ${className}::${method.apiName}(const FunctionCallbackInfo<Value>& args)
</#if>

jobject javaProxy = proxy->getJavaObject();
if (javaProxy == NULL) {
args.GetReturnValue().Set(v8::Undefined(isolate));
return;
}
<@Proxy.callJNIMethod method.args, method.hasInvocation, method.returnType,
"methodID", "javaProxy", "jArguments", (method.returnType != "void") ; hasResult, resultVar>

Expand Down Expand Up @@ -293,6 +297,10 @@ void ${className}::getter_${name}(Local<Name> property, const PropertyCallbackIn
jvalue* jArguments = 0;

jobject javaProxy = proxy->getJavaObject();
if (javaProxy == NULL) {
args.GetReturnValue().Set(v8::Undefined(isolate));
return;
}
<@Proxy.callJNIMethod property.getMethodArgs, property.getHasInvocation, property.getReturnType,
"methodID", "javaProxy", "jArguments", (property.getReturnType != "void") ; hasResult, resultVar>

Expand Down Expand Up @@ -327,6 +335,9 @@ void ${className}::setter_${name}(Local<Name> property, Local<Value> value, cons
<@Proxy.verifyAndConvertArgument expr="value" index=0 info=typeInfo logOnly=true isOptional=false/>

jobject javaProxy = proxy->getJavaObject();
if (javaProxy == NULL) {
return;
}
<@Proxy.callJNIMethod property.setMethodArgs, property.setHasInvocation, property.setReturnType, "methodID", "javaProxy", "jArguments", false ;
hasResult, resultVar>
</@Proxy.callJNIMethod>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.os.Build;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.support.v4.app.NotificationManagerCompat;

import java.util.HashMap;

Expand Down Expand Up @@ -126,6 +127,12 @@ public void notify(int id, NotificationProxy notificationProxy)
}
}

@Kroll.method
public boolean areNotificationsEnabled()
{
return NotificationManagerCompat.from(TiApplication.getInstance()).areNotificationsEnabled();
}

@Override
public String getApiName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public class CalendarModule extends KrollModule
@Kroll.constant
public static final int STATE_SCHEDULED = AlertProxy.STATE_SCHEDULED;

//region recurrence frequency
@Kroll.constant
public static final int RECURRENCEFREQUENCY_DAILY = 0;
@Kroll.constant
public static final int RECURRENCEFREQUENCY_WEEKLY = 1;
@Kroll.constant
public static final int RECURRENCEFREQUENCY_MONTHLY = 2;
@Kroll.constant
public static final int RECURRENCEFREQUENCY_YEARLY = 3;
//endregion

//region attendee relationships
@Kroll.constant
public static final int RELATIONSHIP_ATTENDEE = CalendarContract.Attendees.RELATIONSHIP_ATTENDEE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
import android.provider.CalendarContract.Instances;

// Columns and value constants taken from android.provider.Calendar in the android source base
@Kroll.proxy(parentModule = CalendarModule.class)
@Kroll.proxy(parentModule = CalendarModule.class, propertyAccessors = { TiC.PROPERTY_RECURRENCE_RULES })
public class EventProxy extends KrollProxy
{

public static final String TAG = "EventProxy";

public static final int STATUS_TENTATIVE = 0;
Expand All @@ -48,7 +49,7 @@ public class EventProxy extends KrollProxy
protected int status, visibility;
protected KrollDict extendedProperties = new KrollDict();

protected String recurrenceRule, recurrenceDate, recurrenceExceptionRule, recurrenceExceptionDate;
protected String recurrenceDate, recurrenceExceptionRule, recurrenceExceptionDate;
protected Date lastDate;

public EventProxy()
Expand Down Expand Up @@ -97,11 +98,11 @@ public static ArrayList<EventProxy> queryEventsBetweenDates(long date1, long dat
visibility = "visibility";
}

Cursor eventCursor =
contentResolver.query(builder.build(),
new String[] { "event_id", "title", "description", "eventLocation", "begin", "end",
"allDay", "hasAlarm", "eventStatus", visibility },
query, queryArgs, "startDay ASC, startMinute ASC");
Cursor eventCursor = contentResolver.query(builder.build(),
new String[] { "event_id", "title", "description", "eventLocation",
"begin", "end", "allDay", "hasAlarm", "eventStatus",
visibility, Events.RRULE, Events.CALENDAR_ID },
query, queryArgs, "startDay ASC, startMinute ASC");

if (eventCursor == null) {
Log.w(TAG, "Unable to get any results when pulling events by date range");
Expand All @@ -121,7 +122,16 @@ public static ArrayList<EventProxy> queryEventsBetweenDates(long date1, long dat
event.hasAlarm = !eventCursor.getString(7).equals("0");
event.status = eventCursor.getInt(8);
event.visibility = eventCursor.getInt(9);

// Guarding against Cursor implementations which would throw an exception
// instead of returning null if no recurrence rule is added to the event
String recurrenceRule = null;
try {
recurrenceRule = eventCursor.getString(10);
} catch (Exception e) {
Log.w(TAG, "Trying to get a recurrence rule for an event without one.");
e.printStackTrace();
}
event.setRecurrenceRules(recurrenceRule, eventCursor.getInt(11));
events.add(event);
}

Expand All @@ -130,6 +140,22 @@ public static ArrayList<EventProxy> queryEventsBetweenDates(long date1, long dat
return events;
}

@Kroll.method
public void save()
{
// Currently only saving added recurrenceRules.
String ruleToSave =
((RecurrenceRuleProxy) ((Object[]) getProperty(TiC.PROPERTY_RECURRENCE_RULES))[0]).generateRRULEString();
ContentValues contentValues = new ContentValues();
contentValues.put(Events.RRULE, ruleToSave);
ContentResolver contentResolver = TiApplication.getInstance().getContentResolver();
try {
contentResolver.update(Events.CONTENT_URI, contentValues, Events._ID + "=?", new String[] { id });
} catch (IllegalArgumentException e) {
Log.e(TAG, "Invalid event recurrence rule.");
}
}

public static ArrayList<EventProxy> queryEvents(Uri uri, String query, String[] queryArgs, String orderBy)
{
ArrayList<EventProxy> events = new ArrayList<EventProxy>();
Expand Down Expand Up @@ -336,9 +362,15 @@ public ReminderProxy createReminder(KrollDict data)
return ReminderProxy.createReminder(this, minutes, method);
}

@Kroll.method
RecurrenceRuleProxy createRecurrenceRule(KrollDict data)
{
return new RecurrenceRuleProxy(data);
}

// clang-format off
@Kroll.method
@Kroll.getProperty
@Kroll.getProperty
public AlertProxy[] getAlerts()
// clang-format on
{
Expand Down Expand Up @@ -461,13 +493,13 @@ public int getVisibility()
return visibility;
}

// clang-format off
@Kroll.method
@Kroll.getProperty
public String getRecurrenceRule()
// clang-format on
public void setRecurrenceRules(String rrule, int calendarID)
{
return recurrenceRule;
RecurrenceRuleProxy[] result = new RecurrenceRuleProxy[] {};
if (rrule != null) {
result = new RecurrenceRuleProxy[] { new RecurrenceRuleProxy(rrule, calendarID, begin) };
}
setProperty(TiC.PROPERTY_RECURRENCE_RULES, result);
}

// clang-format off
Expand Down

0 comments on commit f59ef8f

Please sign in to comment.