1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2018 AmrDeveloper (Amr Hesham)
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
1
25
package com .amrdeveloper .reactbutton ;
2
26
3
27
import android .annotation .SuppressLint ;
30
54
import java .util .Arrays ;
31
55
import java .util .List ;
32
56
57
+ /**
58
+ * ReactButton custom class based on Button View
59
+ *
60
+ * Provide like and unlike feature depend on use single click
61
+ * and reactions dialog feature when user provide long click event
62
+ */
33
63
@ SuppressLint ("AppCompatCustomView" )
34
64
public class ReactButton
35
65
extends Button
@@ -119,7 +149,6 @@ public class ReactButton
119
149
*/
120
150
private static final int ICON_SIZE_WITH_PADDING = 45 + ICON_PADDING ;
121
151
122
-
123
152
/**
124
153
* Full reaction icon size converted from dp
125
154
*/
@@ -309,35 +338,40 @@ private void updateReactButtonByReaction(Reaction react) {
309
338
}
310
339
311
340
/**
312
- * @param drawableShape set xml Shape for react dialog layout
341
+ * Modify the reactions dialog layout shape
342
+ * @param drawableShape the new xml shape
313
343
*/
314
344
public void setReactionDialogShape (@ DrawableRes int drawableShape ) {
315
345
this .mReactDialogShape = drawableShape ;
316
346
}
317
347
318
348
/**
319
- * @param offset from the reaction icon
349
+ * Modify the tooltip offset from the reaction icon
350
+ * @param offset the new tooltip offset value
320
351
*/
321
352
public void setTooltipOffsetFromReaction (int offset ) {
322
353
mTooltipOffsetFromReaction = offset ;
323
354
}
324
355
325
356
/**
326
- * @param color tooltip text color
357
+ * Modify the tooltip text color
358
+ * @param color the new text color value
327
359
*/
328
360
public void setReactionTooltipTextColor (@ ColorInt int color ) {
329
361
mReactTooltipTextColor = color ;
330
362
}
331
363
332
364
/**
333
- * @param drawableShape tooltip shape for the layout
365
+ * Modify the tooltip layout shape
366
+ * @param drawableShape the new xml shape
334
367
*/
335
368
public void setReactionTooltipShape (@ DrawableRes int drawableShape ) {
336
369
mReactTooltipShape = drawableShape ;
337
370
}
338
371
339
372
/**
340
- * @param isEnable enable/disable the reactions tooltip feature
373
+ * Enable or disable the reactions tooltip feature
374
+ * @param isEnable True to enable reactions tooltip feature
341
375
*/
342
376
public void setEnableReactionTooltip (boolean isEnable ) {
343
377
enableReactionTooltip = isEnable ;
@@ -355,6 +389,7 @@ public void setReactions(Reaction... reactions) {
355
389
/**
356
390
* Append new reactions to the current reactions list
357
391
* @param reactions Array of Reactions
392
+ * @since 2.1.0
358
393
*/
359
394
public void addReactions (Reaction ... reactions ) {
360
395
mReactions .addAll (Arrays .asList (reactions ));
@@ -363,21 +398,24 @@ public void addReactions(Reaction... reactions) {
363
398
}
364
399
365
400
/**
366
- * @param reaction set This Reaction as current Reaction
401
+ * Modify the current reactions with new one
402
+ * @param reaction new reactions to set as a current reaction
367
403
*/
368
404
public void setCurrentReaction (Reaction reaction ) {
369
405
updateReactButtonByReaction (reaction );
370
406
}
371
407
372
408
/**
373
- * @return The Current reaction Object
409
+ * Return the current reaction object
410
+ * @return The Current reaction
374
411
*/
375
412
public Reaction getCurrentReaction () {
376
413
return mCurrentReaction ;
377
414
}
378
415
379
416
/**
380
- * @param reaction Update library default Reaction by other Reaction
417
+ * Update the default Reaction by other Reaction
418
+ * @param reaction the new reaction be to set as a default reaction
381
419
*/
382
420
public void setDefaultReaction (Reaction reaction ) {
383
421
mDefaultReaction = reaction ;
@@ -386,20 +424,23 @@ public void setDefaultReaction(Reaction reaction) {
386
424
}
387
425
388
426
/**
389
- * @return The current default Reaction object
427
+ * Return the default reaction object
428
+ * @return The default Reaction
390
429
*/
391
430
public Reaction getDefaultReaction () {
392
431
return mDefaultReaction ;
393
432
}
394
433
395
434
/**
396
- * @param number the number of reactions dialog columns
435
+ * Modify the columns number for the reactions dialog
436
+ * @param number the new columns number valud
397
437
*/
398
438
public void setDialogColumnsNumber (int number ) {
399
439
if (number > 0 ) mDialogColumnsNumber = number ;
400
440
}
401
441
402
442
/**
443
+ * Modify the reactions dialog dim amount value
403
444
* @param amount The new dim amount, from 0 for no dim to 1 for full dim.
404
445
*/
405
446
public void setDimAmount (float amount ) {
0 commit comments