reactnative-plugin-appice 1.6.2 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/example/App.js CHANGED
@@ -83,6 +83,38 @@ addAppICEAPIListeners();
83
83
  color="#841584"
84
84
 
85
85
  />
86
+ <Button
87
+ onPress={getUserId}
88
+ title="getUserId"
89
+ color="#841584"
90
+
91
+ />
92
+ <Button
93
+ onPress={getInboxMessage}
94
+ title="getInboxMessage"
95
+ color="#841584"
96
+
97
+ />
98
+ <Button
99
+ onPress={getMessageCount}
100
+ title="getMessageCount"
101
+ color="#841584"
102
+ />
103
+ <Button
104
+ onPress={getInboxMessageForId}
105
+ title="getInboxMessageForId"
106
+ color="#841584"
107
+ />
108
+ <Button
109
+ onPress={updateInboxMessage}
110
+ title="updateInboxMessage"
111
+ color="#841584"
112
+ />
113
+ <Button
114
+ onPress={synchronizeInbox}
115
+ title="synchronizeInbox"
116
+ color="#841584"
117
+ />
86
118
  </View>
87
119
  )
88
120
 
@@ -143,6 +175,62 @@ const setLanguage = () => {
143
175
  };
144
176
  const sendView = () => {
145
177
  AppICE.tagEvent("HomeScreen", {});
178
+ };
179
+
180
+ const getUserId = () => {
181
+ AppICE.getUserId((userIds: any[]) => {
182
+ console.log('User IDs:', userIds);
183
+ });
184
+ };
185
+
186
+ const type = 1;
187
+ const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
188
+
189
+ const getInboxMessage = () => {
190
+ AppICE.getInboxMessages(type, userIds, (inboxMessages: any[]) => {
191
+ console.log('Received Inbox Messages:', inboxMessages);
192
+ });
146
193
  }
147
194
 
195
+ const getMessageCount = () => {
196
+ AppICE.getMessageCount(type, userIds, (count: number) => {
197
+ console.log('Messages count :', count);
198
+ });
199
+ }
200
+
201
+
202
+ const getInboxMessageForId = () => {
203
+ const messageId = "df73e314-2a61-4615-9fa5-348419e3fc82";
204
+ const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
205
+
206
+ AppICE.getInboxMessageForId(messageId, userIds, (inboxMessage: any) => {
207
+ console.log('getInboxMessageForId in JS:', inboxMessage);
208
+ });
209
+ }
210
+
211
+
212
+
213
+ const updateInboxMessage = () => {
214
+ const messageId = "df73e314-2a61-4615-9fa5-348419e3fc82";
215
+ const userId = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
216
+ AppICE.updateInboxMessage(messageId, 1, userId, (isSuccess: boolean) => {
217
+ console.log('Update Inbox Message Success:', isSuccess);
218
+ });
219
+ }
220
+
221
+
222
+
223
+ const synchronizeInbox = () => {
224
+ AppICE.synchronizeInbox(10, (success: boolean) => {
225
+ console.log('Inbox synchronization success:', success);
226
+ const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
227
+ AppICE.getInboxMessages( 1, userIds, (inboxMessages: any[]) => {
228
+ console.log('Inbox Messages:', inboxMessages);
229
+ // everytime will return next set of data from payload
230
+ // var inbox = getInboxFilteredData (inbox, key= "Transaction", limit=10, offset=1 );
231
+ });
232
+
233
+ });
234
+ }
235
+
148
236
  export default HelloWorldApp;
@@ -16,7 +16,7 @@
16
16
  "install": "^0.13.0",
17
17
  "react": "18.0.0",
18
18
  "react-native": "0.69.4",
19
- "reactnative-plugin-appice": "^1.6.2"
19
+ "reactnative-plugin-appice": "^1.6.4"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@babel/core": "^7.12.9",
package/index.js CHANGED
@@ -3,7 +3,6 @@ import { Platform, Component } from 'react-native';
3
3
 
4
4
  const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
5
5
  var eventEmitter;
6
-
7
6
  if(Platform.OS === 'ios')
8
7
  {
9
8
  eventEmitter = NativeModules.AppICEReactEvent ? new NativeEventEmitter(NativeModules.AppICEReactEvent) : DeviceEventEmitter;
@@ -13,8 +12,13 @@ else
13
12
  eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
14
13
  }
15
14
  var AppICEReact = {
15
+ // Push Notification
16
16
  AppICEPushNotificationClicked: AppIceReactPlugin.AppICEPushNotificationClicked,
17
+
18
+ // InApp Notification
17
19
  AppICEInAppClicked: AppIceReactPlugin.AppICEInAppClicked,
20
+
21
+ // User Profile
18
22
  name: AppIceReactPlugin.n,
19
23
  email: AppIceReactPlugin.em,
20
24
  phone: AppIceReactPlugin.ph,
@@ -26,6 +30,17 @@ var AppICEReact = {
26
30
  isEmployed: AppIceReactPlugin.is_emp,
27
31
  validateIntegration: AppIceReactPlugin.validateIntegration,
28
32
 
33
+ // App Inbox
34
+ INBOX_MESSAGE: AppIceReactPlugin.INBOX_MESSAGE,
35
+ INBOX_TITLE : AppIceReactPlugin.INBOX_TITLE,
36
+ INBOX_MESSAGE_STATUS: AppIceReactPlugin.INBOX_MESSAGE_STATUS,
37
+ INBOX_CAMPAIGN_TYPE :AppIceReactPlugin.INBOX_CAMPAIGN_TYPE,
38
+ INBOX_MESSAGE_LANGUAGE: AppIceReactPlugin.INBOX_MESSAGE_LANGUAGE,
39
+ INBOX_MESSAGE_ID : AppIceReactPlugin.INBOX_MESSAGE_ID,
40
+ INBOX_CAMPAIGN_ID : AppIceReactPlugin.INBOX_CAMPAIGN_ID,
41
+ INBOX_MESSAGE_ICON : AppIceReactPlugin.INBOX_MESSAGE_ICON,
42
+ INBOX_CUSTOM_DATA: AppIceReactPlugin.INBOX_CUSTOM_DATA,
43
+
29
44
 
30
45
  /**
31
46
  * add all of the registered listeners for given eventName.
@@ -50,7 +65,19 @@ var AppICEReact = {
50
65
  }
51
66
  },
52
67
 
53
- /**
68
+ /**
69
+ * call this function before clearing old data from db/keychain
70
+ */
71
+ preInitialise: function(){
72
+ this.getDeviceId(( res ) =>
73
+ {
74
+ if(res){
75
+ this.setInternalId(res);
76
+ }
77
+ });
78
+ },
79
+
80
+ /**
54
81
  * Meta data of the apps that is needed for sdk setting
55
82
  * @param {string} appID - meta key
56
83
  * @param {string} appKey - meta key
@@ -66,10 +93,8 @@ var AppICEReact = {
66
93
  this.getDeviceId(( res ) =>
67
94
  {
68
95
  if(res){
69
- console.log('Res variable'+res);
70
96
  AppIceReactPlugin.startContext(appID, appKey, apiKey, res, region, baseUrl, certs)
71
97
  }else{
72
- console.log('deviceID variable'+deviceID);
73
98
  AppIceReactPlugin.startContext(appID, appKey, apiKey, deviceID, region, baseUrl, certs)
74
99
  }
75
100
  });
@@ -85,7 +110,7 @@ var AppICEReact = {
85
110
  AppIceReactPlugin.tagEvent(eventName, props);
86
111
  },
87
112
 
88
- /**
113
+ /**
89
114
  * Record an click event
90
115
  * @param {string} eventName - the name of the event
91
116
  */
@@ -108,10 +133,13 @@ var AppICEReact = {
108
133
  * @param {object} profile - key-value profile properties. keys are strings and values can be string, number or boolean.
109
134
  */
110
135
  setUser: function (profile) {
111
- console.log(profile);
112
136
  AppIceReactPlugin.setUser(profile);
113
137
  },
114
138
 
139
+ //===============================================
140
+ // User id setting
141
+ //===============================================
142
+
115
143
  /**
116
144
  * Set unique user id
117
145
  * @param {object} values - array of userids
@@ -120,6 +148,14 @@ var AppICEReact = {
120
148
  AppIceReactPlugin.setUserId(values);
121
149
  },
122
150
 
151
+ /**
152
+ * Getuser id
153
+ * @param {object} values - array of userids
154
+ */
155
+ getUserId: function(callback){
156
+ callWithCallback ('getUserId', null, callback);
157
+ },
158
+
123
159
  getCustomDataFromPayload: function (object) {
124
160
  let userObj = JSON.parse(object, (key, value) => {
125
161
  return value;
@@ -137,9 +173,7 @@ var AppICEReact = {
137
173
 
138
174
  this.getDeviceId(( res ) =>
139
175
  {
140
-
141
176
  if(res){
142
- console.log('setInternalId');
143
177
  this.setInternalId(res);
144
178
  }
145
179
  });
@@ -157,11 +191,77 @@ var AppICEReact = {
157
191
  setInternalId: function (deviceId){
158
192
  AppIceReactPlugin.setInternalId(deviceId);
159
193
  },
160
-
194
+
195
+ //===============================================
196
+ // AppInbox
197
+ //===============================================
198
+
199
+ /**
200
+ * Get inbox messages list.
201
+ *
202
+ * @param type the message type
203
+ * 1 = ALL
204
+ * 2 = UNREAD
205
+ * 3 = READ
206
+ * 4 = VIEWED
207
+ * 5 = DELETED
208
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
209
+ * @callback will have the string json array
210
+ */
211
+ getInboxMessages: function(type, userIds, callback){
212
+ callWithCallback('getInboxMessages', [type, userIds], callback);
213
+ },
214
+
215
+
216
+ /**
217
+ * Get inbox messages count.
218
+ *
219
+ * @param type the message type is integer
220
+ * 1 = ALL
221
+ * 2 = UNREAD
222
+ * 3 = READ
223
+ * 4 = VIEWED
224
+ * 5 = DELETED
225
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
226
+ * @callback will have the integer
227
+ */
228
+ getMessageCount: function(type, userIds, callback){
229
+ callWithCallback('getMessageCount', [type, userIds], callback);
230
+ },
231
+
232
+ /**
233
+ * Get messages payload based on message id.
234
+ *
235
+ * @param messageId - message id of the notification
236
+ * @param userId - single userid in string ie. "useridA"
237
+ * @callback will have the json object
238
+ */
239
+ getInboxMessageForId: function(messageId, userId, callback){
240
+ callWithCallback('getMessageCount', [messageId, userId], callback);
241
+ },
242
+
243
+ /**
244
+ * update message status ex. UNREAD to READ.
245
+ *
246
+ * @param messageId - message id of the notification
247
+ * @param type - integer value for status
248
+ * @param userId - single userid in string
249
+ * @callback will have the boolean
250
+ */
251
+ updateInboxMessage: function(messageId, type, userId, callback){
252
+ callWithCallback('updateInboxMessage', [messageId, type, userId], callback);
253
+ },
254
+
255
+ synchronizeInbox: function( timeout, callback){
256
+ callWithCallback('synchronizeInbox', [timeout], callback)
257
+ }
258
+
259
+ //========================================
260
+
161
261
  };
162
262
 
163
263
  // internal function for callback
164
- function callWithCallback(method, args, callback) {
264
+ function callWithCallback(method, args, callback) {
165
265
  if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
166
266
  callback = (err, res) => {
167
267
  defaultCallback(method, err, res);
@@ -14,6 +14,17 @@ static NSString *const km = @"m";
14
14
  static NSString *const kis_emp = @"is_emp";
15
15
  static NSString *const kappICEToken = @"appICEToken";
16
16
 
17
+ static NSString *const INBOX_MESSAGE = @"INBOX_MESSAGE";
18
+ static NSString *const INBOX_TITLE = @"INBOX_TITLE";
19
+ static NSString *const INBOX_MESSAGE_STATUS = @"INBOX_MESSAGE_STATUS";
20
+ static NSString *const INBOX_CAMPAIGN_TYPE = @"INBOX_CAMPAIGN_TYPE";
21
+ static NSString *const INBOX_MESSAGE_LANGUAGE = @"INBOX_MESSAGE_LANGUAGE";
22
+ static NSString *const INBOX_MESSAGE_ID = @"INBOX_MESSAGE_ID";
23
+ static NSString *const INBOX_CAMPAIGN_ID = @"INBOX_CAMPAIGN_ID";
24
+ static NSString *const INBOX_MESSAGE_CATEGORY = @"INBOX_MESSAGE_CATEGORY";
25
+ static NSString *const INBOX_MESSAGE_ICON = @"INBOX_MESSAGE_ICON";
26
+ static NSString *const INBOX_CUSTOM_DATA = @"INBOX_CUSTOM_DATA";
27
+
17
28
  @interface AppIceReactPlugin : NSObject <RCTBridgeModule,UNUserNotificationCenterDelegate>
18
29
  +(void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken;
19
30
  + (void)pushNotificationClicked:(NSDictionary *)userInfo;
@@ -23,7 +23,17 @@ RCT_EXPORT_MODULE()
23
23
  ked : @"edt",
24
24
  ket : @"emt",
25
25
  km : km,
26
- kis_emp : @"em"
26
+ kis_emp : @"em",
27
+ INBOX_MESSAGE : @"message",
28
+ INBOX_TITLE : @"title",
29
+ INBOX_MESSAGE_STATUS : @"messageStatus",
30
+ INBOX_CAMPAIGN_TYPE : @"campType",
31
+ INBOX_MESSAGE_LANGUAGE : @"messageLanguage",
32
+ INBOX_MESSAGE_ID : @"id",
33
+ INBOX_CAMPAIGN_ID : @"campId",
34
+ INBOX_MESSAGE_CATEGORY : @"category",
35
+ INBOX_MESSAGE_ICON : @"icon",
36
+ INBOX_CUSTOM_DATA : @"cdata"
27
37
  };
28
38
  }
29
39
  - (dispatch_queue_t)methodQueue {
@@ -102,6 +112,29 @@ RCT_EXPORT_METHOD(setUserId:(NSArray*)userIdArray)
102
112
  [[appICE sharedInstance] setUserId:userIdArray];
103
113
  }
104
114
 
115
+ /**
116
+ * Call the native method to getUserId
117
+ * Check if the getUserIdArray is not nil and the callback function is provided
118
+ * else Handle the case when getUserIdArray is nil
119
+ * Invoke the callback with an array containing NSNull to represent nil
120
+ */
121
+
122
+ RCT_EXPORT_METHOD(getUserId:(RCTResponseSenderBlock)callback)
123
+ {
124
+
125
+ NSMutableArray *getUserIdArray = [[appICE sharedInstance] getUserId];
126
+ RCTLog(@"getUserIdArray %@", getUserIdArray);
127
+
128
+ if (getUserIdArray && getUserIdArray.count > 0 && callback) {
129
+ callback(@[getUserIdArray]);
130
+ } else {
131
+ if (callback) {
132
+ callback(@[[NSNull null]]);
133
+ }
134
+ }
135
+
136
+ }
137
+
105
138
  RCT_EXPORT_METHOD(pushNotificationClicked:(NSDictionary*)userInfo)
106
139
  {
107
140
  [[appICE sharedInstance] pushNotificationClickedEvent:userInfo];
@@ -210,5 +243,141 @@ RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback)
210
243
  }
211
244
  }
212
245
 
246
+ /**
247
+ * Get inbox messages list.
248
+ * @param type the message type
249
+ * 1 = ALL
250
+ * 2 = UNREAD
251
+ * 3 = READ
252
+ * 4 = VIEWED
253
+ * 5 = DELETED
254
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
255
+ * @callback will have the string json array
256
+ */
257
+
258
+ RCT_EXPORT_METHOD(getInboxMessages:(int)type userId:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
259
+ {
260
+ NSMutableArray *inboxMessagesArray = [[appICE sharedInstance] getInboxMessages:type userId:userIds];
261
+ // Convert AppICEInboxMessage objects to dictionaries
262
+
263
+ NSMutableArray *formattedinboxMessages = [NSMutableArray array];
264
+ for (AppICEInboxMessage *inboxMessage in inboxMessagesArray) {
265
+ NSDictionary *formattedMessage = [self formatInboxMessage:inboxMessage];
266
+ [formattedinboxMessages addObject:formattedMessage];
267
+ }
268
+ RCTLog(@"Formatted Inbox Messages: %@", formattedinboxMessages);
269
+ [self returnResult:formattedinboxMessages withCallback:callback andError:nil];
270
+
271
+ }
272
+
273
+ /**
274
+ ---------------
275
+ APPINBOX
276
+ ---------------
277
+ * Get inbox messages count.
278
+ * @param type the message type
279
+ * 1 = ALL
280
+ * 2 = UNREAD
281
+ * 3 = READ
282
+ * 4 = VIEWED
283
+ * 5 = DELETED
284
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
285
+ * @callback will have the integer
286
+ */
287
+
288
+ RCT_EXPORT_METHOD(getMessageCount:(int)type userId:(NSArray*)userId callback:(RCTResponseSenderBlock)callback)
289
+ {
290
+ int inboxMessageCount = [[appICE sharedInstance] getMessageCount:type userId:userId];
291
+ RCTLog(@"Inbox Messages Count: %d", inboxMessageCount);
292
+
293
+ [self returnResult:@(inboxMessageCount) withCallback:callback andError:nil];
294
+ }
295
+
296
+ /**
297
+ * Get messages payload based on message id.
298
+ * @param messageId - message id of the notification
299
+ * @param userId - single userid in string ie. "useridA"
300
+ * @callback will have the json object
301
+ */
302
+ RCT_EXPORT_METHOD(getInboxMessageForId:(NSString*)messageId userId:(NSArray*)userId callback:(RCTResponseSenderBlock)callback)
303
+ {
304
+
305
+ AppICEInboxMessage *inboxMessageId = [[appICE sharedInstance] getInboxMessageForId:messageId userId:userId];
306
+ RCTLog(@"Inbox Messages id: %@", inboxMessageId);
307
+ NSDictionary *formattedMessageforId = [self formatInboxMessage:inboxMessageId];
308
+ RCTLog(@"Formatted Inbox Message id: %@", formattedMessageforId);
309
+
310
+ [self returnResult:formattedMessageforId withCallback:callback andError:nil];
311
+ }
312
+
313
+ /**
314
+ * update message status ex. UNREAD to READ.
315
+ * @param messageId - message id of the notification
316
+ * @param type - integer value for status
317
+ * @param userId - single userid in string
318
+ * @callback will have the boolean
319
+ */
320
+
321
+ RCT_EXPORT_METHOD(updateInboxMessage:(NSString *)messageId type:(int)type userId:(NSString *)userId callback:(RCTResponseSenderBlock)callback)
322
+ {
323
+ BOOL isSuccess = [[appICE sharedInstance] updateInboxMessage:type messageId:messageId userid:userId];
324
+ RCTLog(@"Update Inbox Message Success: %@", isSuccess ? @"YES" : @"NO");
325
+
326
+ [self returnResult:@(isSuccess) withCallback:callback andError:nil];
327
+ }
328
+
329
+ /**
330
+ * synchronizeInbox message Ttue or False.
331
+ * @param messageId - message id of the notification
332
+ * @param type - integer value for status
333
+ * @param userId - single userid in string
334
+ * @callback will have the boolean
335
+ */
336
+ RCT_EXPORT_METHOD(synchronizeInbox:(int)timeout callback:(RCTResponseSenderBlock)callback)
337
+ {
338
+ // Save the callback for later use
339
+ RCTLog(@"synchronizeInbox");
340
+
341
+ [[appICE sharedInstance] synchronizeInbox:^(BOOL success) {
342
+
343
+ [self returnResult:@(success) withCallback:callback andError:nil];
344
+
345
+ } timeoutinSec:timeout];
346
+
347
+ }
348
+
349
+ // Add a method to format AppICEInboxMessage to a dictionary
350
+ - (NSDictionary *)formatInboxMessage:(AppICEInboxMessage *)inboxMessage {
351
+ if (inboxMessage) {
352
+ return @{
353
+ @"messageId": inboxMessage.messageId,
354
+ @"id": inboxMessage.messageMid,
355
+ @"icon": inboxMessage.messageImage,
356
+ @"message": inboxMessage.messageBody,
357
+ @"title": inboxMessage.messageTitle,
358
+ @"messageStatus": inboxMessage.messageStatus,
359
+ @"messageLanguage": inboxMessage.messageLanguage,
360
+ @"campId": inboxMessage.messageCampid,
361
+ @"cdata": inboxMessage.customData,
362
+ @"messageExpiryTime": @(inboxMessage.messageExpiryTime),
363
+ @"campType": inboxMessage.campType
364
+ };
365
+ } else {
366
+ return @{};
367
+ }
368
+ }
369
+
370
+ - (void)returnResult:(id)result withCallback:(RCTResponseSenderBlock)callback andError:(NSString *)error {
371
+
372
+ if (callback == nil) {
373
+ RCTLog(@"callback was nil");
374
+ return;
375
+ }
376
+ // id e = error != nil ? error : [NSNull null];
377
+ id r = result != nil ? result : [NSNull null];
378
+ RCTLog(@"r: %@",r);
379
+ callback(@[r]);
380
+ }
381
+
213
382
  @end
214
383
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactnative-plugin-appice",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "appICE React Native SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,5 +0,0 @@
1
- package com.reactlibrary;
2
-
3
- public interface ClickCallback {
4
- void clickPayload(String obj);
5
- }
@@ -1,68 +0,0 @@
1
- package com.reactlibrary;
2
- import android.annotation.SuppressLint;
3
- import android.content.Context;
4
- import android.graphics.Point;
5
- import android.util.DisplayMetrics;
6
- import android.util.TypedValue;
7
- import android.view.View;
8
- import android.webkit.WebView;
9
-
10
- @SuppressLint("ViewConstructor")
11
- class InAppWebView extends WebView {
12
-
13
- final Point dim = new Point();
14
-
15
- private int height;
16
-
17
- private int heightPercentage;
18
-
19
- private int width;
20
-
21
- private int widthPercentage;
22
-
23
- @SuppressLint("ResourceType")
24
- public InAppWebView(Context context, int width, int height, int widthPercentage, int heightPercentage) {
25
- super(context);
26
- this.width = width;
27
- this.height = height;
28
- this.widthPercentage = widthPercentage;
29
- this.heightPercentage = heightPercentage;
30
- setHorizontalScrollBarEnabled(false);
31
- setVerticalScrollBarEnabled(false);
32
- setHorizontalFadingEdgeEnabled(false);
33
- setVerticalFadingEdgeEnabled(false);
34
- setOverScrollMode(View.OVER_SCROLL_NEVER);
35
- setBackgroundColor(0x00000000);
36
- //noinspection ResourceType
37
- setId(188293);
38
- }
39
-
40
- @Override
41
- public boolean performClick() {
42
- return super.performClick();
43
- }
44
-
45
- @Override
46
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
47
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
48
- updateDimension();
49
- setMeasuredDimension(dim.x, dim.y);
50
- }
51
-
52
- void updateDimension() {
53
- if (width != 0) {
54
- dim.x = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
55
- width, getResources().getDisplayMetrics());
56
- } else {
57
- DisplayMetrics metrics = getResources().getDisplayMetrics();
58
- dim.x = (int) (metrics.widthPixels * widthPercentage / 100f);
59
- }
60
- if (height != 0) {
61
- dim.y = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
62
- height, getResources().getDisplayMetrics());
63
- } else {
64
- DisplayMetrics metrics = getResources().getDisplayMetrics();
65
- dim.y = (int) (metrics.heightPixels * heightPercentage / 100f);
66
- }
67
- }
68
- }