Removing setting of window.data and fixed some indentations
This commit is contained in:
Родитель
be73502c5d
Коммит
5f9dbbc951
14
plugin.xml
14
plugin.xml
|
@ -10,7 +10,7 @@
|
||||||
<keywords>cordova,device</keywords>
|
<keywords>cordova,device</keywords>
|
||||||
<url>http://docs.telerik.com/platform/appfeedback</url>
|
<url>http://docs.telerik.com/platform/appfeedback</url>
|
||||||
<engines>
|
<engines>
|
||||||
<engine name="cordova-ios" version=" >=3" />
|
<engine name="cordova-ios" version=">=3" />
|
||||||
<engine name="cordova-android" version=">=4" />
|
<engine name="cordova-android" version=">=4" />
|
||||||
</engines>
|
</engines>
|
||||||
|
|
||||||
|
@ -39,13 +39,13 @@
|
||||||
<framework src="Foundation.framework" weak="true" />
|
<framework src="Foundation.framework" weak="true" />
|
||||||
|
|
||||||
<config-file target="*-Info.plist" parent="apiKey">
|
<config-file target="*-Info.plist" parent="apiKey">
|
||||||
<string>$API_KEY</string>
|
<string>$API_KEY</string>
|
||||||
</config-file>
|
</config-file>
|
||||||
<config-file target="*-Info.plist" parent="apiUrl">
|
<config-file target="*-Info.plist" parent="apiUrl">
|
||||||
<string>$API_URL</string>
|
<string>$API_URL</string>
|
||||||
</config-file>
|
</config-file>
|
||||||
<config-file target="*-Info.plist" parent="enableShake">
|
<config-file target="*-Info.plist" parent="enableShake">
|
||||||
<string>$ENABLE_SHAKE</string>
|
<string>$ENABLE_SHAKE</string>
|
||||||
</config-file>
|
</config-file>
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
|
@ -69,9 +69,9 @@
|
||||||
|
|
||||||
<source-file src="src/android/res/values/feedback.xml" target-dir="res/values" />
|
<source-file src="src/android/res/values/feedback.xml" target-dir="res/values" />
|
||||||
<config-file target="res/values/strings.xml" parent="/*">
|
<config-file target="res/values/strings.xml" parent="/*">
|
||||||
<string name="apiKey">$API_KEY</string>
|
<string name="apiKey">$API_KEY</string>
|
||||||
<string name="apiUrl">$API_URL</string>
|
<string name="apiUrl">$API_URL</string>
|
||||||
<string name="enableShake">$ENABLE_SHAKE</string>
|
<string name="enableShake">$ENABLE_SHAKE</string>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<config-file target="AndroidManifest.xml" parent="/*">
|
<config-file target="AndroidManifest.xml" parent="/*">
|
||||||
|
|
|
@ -21,26 +21,25 @@ public class AppFeedback extends CordovaPlugin implements RadFeedback.OnSendFeed
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||||
|
|
||||||
if (action.equals("GetVariables")) {
|
if (action.equals("GetVariables")) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
for (int i = 0; i < args.length(); i++) {
|
for (int i = 0; i < args.length(); i++) {
|
||||||
try {
|
try {
|
||||||
String variableName = args.getString(i);
|
String variableName = args.getString(i);
|
||||||
int appResId = cordova.getActivity().getResources().getIdentifier(variableName, "string", cordova.getActivity().getPackageName());
|
int appResId = cordova.getActivity().getResources().getIdentifier(variableName, "string", cordova.getActivity().getPackageName());
|
||||||
String variableValue = cordova.getActivity().getString(appResId);
|
String variableValue = cordova.getActivity().getString(appResId);
|
||||||
data.put(variableName, variableValue);
|
data.put(variableName, variableValue);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
callbackContext.success(data);
|
||||||
callbackContext.success(data);
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (action.equalsIgnoreCase("initialize")) {
|
if (action.equalsIgnoreCase("initialize")) {
|
||||||
this.initialize(args);
|
this.initialize(args);
|
||||||
} else if (action.equalsIgnoreCase("showfeedback")) {
|
} else if (action.equalsIgnoreCase("showfeedback")) {
|
||||||
this.showFeedback();
|
this.showFeedback();
|
||||||
} else {
|
} else {
|
||||||
callbackContext.error("Method not found");
|
callbackContext.error("Method not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,23 +33,24 @@
|
||||||
|
|
||||||
-(void)GetVariables:(CDVInvokedUrlCommand*)command
|
-(void)GetVariables:(CDVInvokedUrlCommand*)command
|
||||||
{
|
{
|
||||||
NSMutableDictionary *values = [NSMutableDictionary dictionary];
|
NSMutableDictionary *values = [NSMutableDictionary dictionary];
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < [command.arguments count]; i++)
|
for (i = 0; i < [command.arguments count]; i++)
|
||||||
{
|
|
||||||
@try
|
|
||||||
{
|
{
|
||||||
NSString *variableName = [command argumentAtIndex:i];
|
@try
|
||||||
NSString *variableValue = [[[NSBundle mainBundle] infoDictionary] objectForKey:variableName];
|
{
|
||||||
[values setObject:variableValue forKey:variableName];
|
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];
|
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:values];
|
||||||
NSString *callbackId = [command callbackId];
|
NSString *callbackId = [command callbackId];
|
||||||
[self success:result callbackId:callbackId];
|
[self success:result callbackId:callbackId];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var cordova = require('cordova'),
|
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 () {
|
Feedback = function () {
|
||||||
this.initialize = function (apiKey, options) {
|
this.initialize = function (apiKey, options) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
@ -42,22 +42,20 @@ var cordova = require('cordova'),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
feedback = new Feedback();
|
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);
|
}, true);
|
||||||
|
|
||||||
module.exports = feedback;
|
module.exports = feedback;
|
Загрузка…
Ссылка в новой задаче