Skip to content

Commit

Permalink
Merge branch 'feature/cordova4-compat'
Browse files Browse the repository at this point in the history
Conflicts:
	plugin.xml
	src/android/com/telerik/feedback/AppFeedback.java
	src/ios/TLRKFeedback.m
  • Loading branch information
darind committed Nov 24, 2015
2 parents f33077a + 2c1da4a commit 7e39984
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 57 deletions.
21 changes: 11 additions & 10 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.telerik.feedback"
version="1.5.0">
version="2.0.0">

<name>Telerik AppFeedback</name>
<description>This plugin allows the app to include Telerik AppFeedback functionality on device shake.</description>
<license>Commercial</license>
<keywords>cordova,device</keywords>
<url>http://docs.telerik.com/platform/appfeedback</url>
<engines>
<engine name="cordova" version=">=3.0.0" />
<engine name="cordova-ios" version=">=3" />
<engine name="cordova-android" version=">=3.6.0" />
</engines>

<js-module src="www/feedback.js" name="feedback">
Expand Down Expand Up @@ -37,13 +39,13 @@
<framework src="Foundation.framework" weak="true" />

<config-file target="*-Info.plist" parent="apiKey">
<string>$API_KEY</string>
<string>$API_KEY</string>
</config-file>
<config-file target="*-Info.plist" parent="apiUrl">
<string>$API_URL</string>
<string>$API_URL</string>
</config-file>
<config-file target="*-Info.plist" parent="enableShake">
<string>$ENABLE_SHAKE</string>
<string>$ENABLE_SHAKE</string>
</config-file>
</platform>

Expand All @@ -67,18 +69,17 @@

<source-file src="src/android/res/values/feedback.xml" target-dir="res/values" />
<config-file target="res/values/strings.xml" parent="/*">
<string name="apiKey">$API_KEY</string>
<string name="apiUrl">$API_URL</string>
<string name="enableShake">$ENABLE_SHAKE</string>
<string name="apiKey">$API_KEY</string>
<string name="apiUrl">$API_URL</string>
<string name="enableShake">$ENABLE_SHAKE</string>
</config-file>

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
</config-file>

<source-file src="src/android/com/telerik/feedback/AppFeedback.java" target-dir="src/com/telerik/feedback" />

<framework src="src/android/FeedbackLib" custom="true" />
<framework src="extras/android/support/v7/appcompat" parent="src/android/FeedbackLib" />
</platform>
</plugin>
3 changes: 3 additions & 0 deletions src/android/FeedbackLib/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
}
Binary file modified src/android/FeedbackLib/libs/Feedback.jar
Binary file not shown.
28 changes: 13 additions & 15 deletions src/android/com/telerik/feedback/AppFeedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,24 @@ public class AppFeedback extends CordovaPlugin implements RadFeedback.OnSendFeed

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

if (action.equals("GetVariables")) {
JSONObject data = new JSONObject();
for (int i = 0; i < args.length(); i++) {
try {
String variableName = args.getString(i);
int appResId = cordova.getActivity().getResources().getIdentifier(variableName, "string", cordova.getActivity().getPackageName());
String variableValue = cordova.getActivity().getString(appResId);
data.put(variableName, variableValue);
} catch(Exception ex) {
JSONObject data = new JSONObject();
for (int i = 0; i < args.length(); i++) {
try {
String variableName = args.getString(i);
int appResId = cordova.getActivity().getResources().getIdentifier(variableName, "string", cordova.getActivity().getPackageName());
String variableValue = cordova.getActivity().getString(appResId);
data.put(variableName, variableValue);
} catch(Exception ex) {
}
}
}
callbackContext.success(data);
return true;
}
if (action.equalsIgnoreCase("initialize")) {
callbackContext.success(data);
return true;
} else if (action.equalsIgnoreCase("initialize")) {
this.initialize(args);
} else if (action.equalsIgnoreCase("showfeedback")) {
this.showFeedback();
} else {
} else {
callbackContext.error("Method not found");
return false;
}
Expand Down
31 changes: 16 additions & 15 deletions src/ios/TLRKFeedback.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ -(void)showFeedback: (CDVInvokedUrlCommand *)command

-(void)GetVariables:(CDVInvokedUrlCommand*)command
{
NSMutableDictionary *values = [NSMutableDictionary dictionary];
int i;
for (i = 0; i < [command.arguments count]; i++)
{
@try
NSMutableDictionary *values = [NSMutableDictionary dictionary];
int i;
for (i = 0; i < [command.arguments count]; i++)
{
NSString *variableName = [command argumentAtIndex:i];
NSString *variableValue = [[[NSBundle mainBundle] infoDictionary] objectForKey:variableName];
[values setObject:variableValue forKey:variableName];
@try
{
NSString *variableName = [command argumentAtIndex:i];
NSString *variableValue = [[[NSBundle mainBundle] infoDictionary] objectForKey:variableName];
[values setObject:variableValue forKey:variableName];
}
@catch (NSException *exception)
{
}
}
@catch (NSException *exception)
{
}
}

CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:values];
NSString *callbackId = [command callbackId];
[self success:result callbackId:callbackId];
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:values];
NSString *callbackId = [command callbackId];
[self success:result callbackId:callbackId];
}

@end
32 changes: 15 additions & 17 deletions www/feedback.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var cordova = require('cordova'),
API_BASE_URL = 'https://platform.telerik.com/feedback/api/v1',
API_BASE_URL = 'https://platform.telerik.com/feedback/api/v1',
Feedback = function () {
this.initialize = function (apiKey, options) {
var that = this;
Expand All @@ -11,7 +11,7 @@ var cordova = require('cordova'),
}

if (options) {
options.enableShake = options.enableShake === 'undefined' ? true : options.enableShake;
options.enableShake = typeof options.enableShake === 'undefined' ? true : options.enableShake;
} else {
options = {
enableShake: true
Expand Down Expand Up @@ -42,22 +42,20 @@ var cordova = require('cordova'),
};
},
feedback = new Feedback();

window.addEventListener('deviceready', function () {
cordova.exec(function(data) {
if(data.apiKey !== "YourKeyHere"){
var shouldEnableShake = data.enableShake === 'true'
var feedbackOptions = {
enableShake: shouldEnableShake,
apiUrl: data.apiUrl
};
feedback.initialize(data.apiKey, feedbackOptions);
}
}, function(err) {
window.data = err;
console.log('Unable to read required plugin variables: ' + err);
}, 'AppFeedback', 'GetVariables', [ 'apiKey', 'apiUrl', 'enableShake' ]);

window.addEventListener('deviceready', function () {
cordova.exec(function(data) {
if (data.apiKey !== 'YourKeyHere') {
var shouldEnableShake = (data.enableShake || '').toLowerCase() === 'true';
var feedbackOptions = {
enableShake: shouldEnableShake,
apiUrl: data.apiUrl
};
feedback.initialize(data.apiKey, feedbackOptions);
}
}, function(err) {
console.log('Unable to read required plugin variables: ' + err);
}, 'AppFeedback', 'GetVariables', [ 'apiKey', 'apiUrl', 'enableShake' ]);
}, true);

module.exports = feedback;

0 comments on commit 7e39984

Please sign in to comment.