7
7
import android .content .res .TypedArray ;
8
8
import android .graphics .PorterDuff ;
9
9
import android .graphics .Typeface ;
10
+ import android .graphics .drawable .Drawable ;
10
11
import android .os .Build ;
11
12
import android .telephony .PhoneNumberUtils ;
12
13
import android .telephony .TelephonyManager ;
@@ -75,6 +76,7 @@ public class CountryCodePicker extends RelativeLayout {
75
76
// see attr.xml to see corresponding values for pref
76
77
AutoDetectionPref selectedAutoDetectionPref = AutoDetectionPref .SIM_NETWORK_LOCALE ;
77
78
PhoneNumberUtil phoneUtil ;
79
+ boolean rippleEnable = true ;
78
80
boolean showNameCode = true ;
79
81
boolean showPhoneCode = true ;
80
82
boolean ccpDialogShowPhoneCode = true ;
@@ -83,6 +85,7 @@ public class CountryCodePicker extends RelativeLayout {
83
85
boolean showFastScroller = true ;
84
86
boolean ccpDialogShowTitle = true ;
85
87
boolean ccpDialogShowFlag = true ;
88
+ boolean ccpDialogRippleEnable = true ;
86
89
boolean searchAllowed = true ;
87
90
boolean showArrow = true ;
88
91
boolean showCloseIcon = false ;
@@ -264,6 +267,9 @@ private void applyCustomProperty(AttributeSet attrs) {
264
267
//ccpDialog initial scroll to selection
265
268
ccpDialogInitialScrollToSelection = a .getBoolean (R .styleable .CountryCodePicker_ccpDialog_initialScrollToSelection , false );
266
269
270
+ //ripple enable on dialog
271
+ ccpDialogRippleEnable = a .getBoolean (R .styleable .CountryCodePicker_ccpDialog_rippleEnable , true );
272
+
267
273
//show full name
268
274
showFullName = a .getBoolean (R .styleable .CountryCodePicker_ccp_showFullName , false );
269
275
@@ -322,6 +328,10 @@ private void applyCustomProperty(AttributeSet attrs) {
322
328
//show close icon
323
329
showCloseIcon = a .getBoolean (R .styleable .CountryCodePicker_ccpDialog_showCloseIcon , false );
324
330
331
+ //ripple enable
332
+ rippleEnable = a .getBoolean (R .styleable .CountryCodePicker_ccp_rippleEnable , true );
333
+ refreshEnableRipple ();
334
+
325
335
//show flag
326
336
showFlag (a .getBoolean (R .styleable .CountryCodePicker_ccp_showFlag , true ));
327
337
@@ -494,6 +504,17 @@ private void refreshArrowViewVisibility() {
494
504
}
495
505
}
496
506
507
+ private void refreshEnableRipple () {
508
+ if (rippleEnable ) {
509
+ TypedValue outValue = new TypedValue ();
510
+ getContext ().getTheme ().resolveAttribute (android .R .attr .selectableItemBackground , outValue , true );
511
+ if (outValue .resourceId !=0 )
512
+ relativeClickConsumer .setBackgroundResource (outValue .resourceId );
513
+ else
514
+ relativeClickConsumer .setBackgroundResource (outValue .data );
515
+ }
516
+ }
517
+
497
518
/**
498
519
* this will read last selected country name code from the shared pref.
499
520
* if that name code is not null, load that country in the CCP
@@ -594,6 +615,22 @@ public void setCcpDialogShowFlag(boolean ccpDialogShowFlag) {
594
615
this .ccpDialogShowFlag = ccpDialogShowFlag ;
595
616
}
596
617
618
+ /**
619
+ * To show/hide ripple from country selection dialog
620
+ */
621
+ public boolean getCcpDialogRippleEnable () {
622
+ return this .ccpDialogRippleEnable ;
623
+ }
624
+
625
+ /**
626
+ * To show/hide ripple from country selection dialog
627
+ *
628
+ * @param ccpDialogRippleEnable
629
+ */
630
+ public void setCcpDialogRippleEnable (boolean ccpDialogRippleEnable ) {
631
+ this .ccpDialogRippleEnable = ccpDialogRippleEnable ;
632
+ }
633
+
597
634
boolean isShowPhoneCode () {
598
635
return showPhoneCode ;
599
636
}
0 commit comments