Skip to content

Commit cdbb5cf

Browse files
author
anuragkondeya
committed
Release 1.8.3
1 parent 6899c97 commit cdbb5cf

File tree

4 files changed

+97
-4
lines changed

4 files changed

+97
-4
lines changed

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<plugin id="com.streethawk.core" version="1.8.2" xmlns="http://apache.org/cordova/ns/plugins/1.0"
2+
<plugin id="com.streethawk.core" version="1.8.3" xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android">
44
<name>StreetHawkCore</name>
55
<description>StreetHawk SDK plugin for analytics</description>

src/android/Streethawk.java

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,15 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
155155
if(action.equals("setInteractivePushBtnPair")){
156156
return setInteractivePushBtnPair();
157157
}
158-
158+
159+
//Added in 1.8.7
160+
if(action.equals("setLargeIconResID")){
161+
return setLargeIconResID(args);
162+
}
163+
if(action.equals("setSmallIconResID")){
164+
return setSmallIconResID(args);
165+
}
166+
159167
/*GROWTH plugin*/
160168
if(action.equals("getShareUrlForAppDownload")){
161169
return originateShareWithCampaign(args,callbackContext);
@@ -1088,6 +1096,88 @@ private boolean getIcon(JSONArray args,CallbackContext callbackContext){
10881096
}
10891097
return true;
10901098
}
1099+
1100+
/**
1101+
* Function sets bigIcon to be used in notification bar
1102+
*/
1103+
private boolean setLargeIconResID(JSONArray args){
1104+
final Context context = cordova.getActivity().getApplicationContext();
1105+
String iconName;
1106+
try{
1107+
iconName= args.getString(0);
1108+
}catch(JSONException e){
1109+
iconName=null;
1110+
}
1111+
if(null==iconName)
1112+
return false;
1113+
Class noParams[] = {};
1114+
Class[] paramContext = new Class[1];
1115+
paramContext[0] = Context.class;
1116+
1117+
Class[] name = new Class[1];
1118+
name[0] = String.class;
1119+
Class push = null;
1120+
try {
1121+
push = Class.forName("com.streethawk.library.push.Push");
1122+
Method pushMethod = push.getMethod("getInstance", paramContext);
1123+
Object obj = pushMethod.invoke(null,context);
1124+
if (null != obj) {
1125+
Method addPushModule = push.getDeclaredMethod("setLargeIconResID",name);
1126+
addPushModule.invoke(obj,iconName);
1127+
}
1128+
} catch (ClassNotFoundException e1) {
1129+
Log.w(TAG,SUBTAG+"No Push module found. Add streethawk push plugin");
1130+
} catch (IllegalAccessException e1) {
1131+
e1.printStackTrace();
1132+
} catch (NoSuchMethodException e1) {
1133+
e1.printStackTrace();
1134+
} catch (InvocationTargetException e1) {
1135+
e1.printStackTrace();
1136+
}
1137+
return true;
1138+
}
1139+
1140+
/**
1141+
* Function returns icon resid of given icon name
1142+
*/
1143+
private boolean setSmallIconResID(JSONArray args){
1144+
Log.e("Anurag","inside setSmallIconResID");
1145+
final Context context = cordova.getActivity().getApplicationContext();
1146+
String iconName;
1147+
try{
1148+
iconName= args.getString(0);
1149+
Log.e("Anurag","Small Iconname "+iconName);
1150+
}catch(JSONException e){
1151+
iconName=null;
1152+
}
1153+
if(null==iconName)
1154+
return false;
1155+
Class noParams[] = {};
1156+
Class[] paramContext = new Class[1];
1157+
paramContext[0] = Context.class;
1158+
Class[] name = new Class[1];
1159+
name[0] = String.class;
1160+
Class push = null;
1161+
try {
1162+
push = Class.forName("com.streethawk.library.push.Push");
1163+
Method pushMethod = push.getMethod("getInstance", paramContext);
1164+
Object obj = pushMethod.invoke(null,context);
1165+
if (null != obj) {
1166+
Method addPushModule = push.getDeclaredMethod("setSmallIconResID",name);
1167+
addPushModule.invoke(obj,iconName);
1168+
}
1169+
} catch (ClassNotFoundException e1) {
1170+
Log.w(TAG,SUBTAG+"No Push module found. Add streethawk push plugin");
1171+
} catch (IllegalAccessException e1) {
1172+
e1.printStackTrace();
1173+
} catch (NoSuchMethodException e1) {
1174+
e1.printStackTrace();
1175+
} catch (InvocationTargetException e1) {
1176+
e1.printStackTrace();
1177+
}
1178+
return true;
1179+
}
1180+
10911181

10921182
/*GROWTH API*/
10931183
private boolean originateShareWithCampaign(JSONArray args, CallbackContext callbackContext)throws JSONException{

src/android/streethawkcore.jar

-13 KB
Binary file not shown.

www/Streethawk.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ SHLibrary.prototype.addInteractivePushButtonPairWithIcons = function(string_b1,s
156156
SHLibrary.prototype.addInteractivePushButtonPair = function(string_b1,string_b2,string_pairname,appSuccess, appFail) {
157157
exec(appSuccess, appFail, 'Streethawk', 'addInteractivePushButtonPair', [string_b1,string_b2,string_pairname]);
158158
}
159-
SHLibrary.prototype.setInteractivePushBtnPair = function(appSuccess, appFail) {
160-
exec(appSuccess, appFail, 'Streethawk', 'setInteractivePushBtnPair',[]);
159+
SHLibrary.prototype.setLargeIconResID = function(string_name,appSuccess, appFail) {
160+
exec(appSuccess, appFail, 'Streethawk', 'setLargeIconResID',[string_name]);
161+
}
162+
SHLibrary.prototype.setSmallIconResID = function(string_name,appSuccess, appFail) {
163+
exec(appSuccess, appFail, 'Streethawk', 'setSmallIconResID',[string_name]);
161164
}
162165

163166
// Growth plugin

0 commit comments

Comments
 (0)