Skip to content

Commit 261484c

Browse files
committed
1. Updated README.md
1 parent 450ef49 commit 261484c

File tree

2 files changed

+210
-5
lines changed

2 files changed

+210
-5
lines changed

README.md

Lines changed: 207 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ allprojects{
1616
```
1717
dependencies {
1818
...
19-
implementation 'com.github.amitjangid80:multiutillib:v1.1.2'
19+
implementation 'com.github.amitjangid80:multiutillib:v1.1.4'
2020
}
2121
```
2222

@@ -34,7 +34,7 @@ dependencies {
3434
<dependency>
3535
<groupId>com.github.amitjangid80</groupId>
3636
<artifactId>multiutillib</artifactId>
37-
version>v1.1.2</version>
37+
version>v1.1.4</version>
3838
dependency>
3939
```
4040

@@ -67,7 +67,54 @@ public class ProjectApplication extends Application
6767
```java
6868
// use it in the activity or class you want to.
6969
SharedPreferenceData sharedPreferenceData = new SharedPreferenceData(context);
70+
71+
// FOR SETTING DATA TO SHARED PREFERENCE.
72+
// generic method storing string values.
7073
sharedPreferenceData.setValue("keyname", "value for that keyname");
74+
75+
// specific for string values.
76+
sharedPreferenceData.setStrValue("keyname", "value for that keyname");
77+
78+
// specific for int values.
79+
sharedPreferenceData.setIntValue("keyname", 1);
80+
81+
// specific for boolean values.
82+
sharedPreferenceData.setBooleanValue("keyname", true);
83+
84+
// spefici for float values.
85+
sharedPreferenceData.setFloatValue("keyname", 1.0);
86+
87+
// specific for long values.
88+
sharedPreferenceData.setLongValue("keyname", 123456789);
89+
90+
// specific for String set values.
91+
sharedPreferenceData.setStrSetValue("keyname", Set<String> value);
92+
93+
94+
// FOR GETTING DATA FROM SHARED PREFERENCE.
95+
// all the below methods will return some defaults values.
96+
97+
// generic method for getting values returns 0 by default as string type.
98+
sharedPreferenceData.getValue(key);
99+
100+
// specific for getting string values returns 0 by default as string type.
101+
sharedPreferenceData.getStrValue(key);
102+
103+
// specific for getting int values returns 0 by default as int type.
104+
sharedPreferenceData.getIntValue(key);
105+
106+
// specific for getting boolean values returns false by default as int type.
107+
sharedPreferenceData.getBooleanValue(key);
108+
109+
// specific for getting float values returns 0f by default as int type.
110+
sharedPreferenceData.getFloatValue(key);
111+
112+
// specific for getting long values returns 0 by default as int type.
113+
sharedPreferenceData.getLongValue(key);
114+
115+
// specific for getting set of string values returns null by default as int type.
116+
sharedPreferenceData.getStrSetValue(key);
117+
71118
```
72119

73120
### ApiServices
@@ -474,3 +521,161 @@ Validator.noSpecialCharacters("abcd123");
474521
Validator.atLeastOneSpecialCharacters("abcd@123");
475522
```
476523

524+
### UiUtils
525+
526+
>**This class has utils for ui like setting max length to TextView, EditText, TextInputEditText.**
527+
528+
**Usage: For setting char count on edittext or textinputedittext**
529+
530+
```java
531+
/**
532+
* set char counter
533+
* Shows live character counter for the number of characters
534+
* typed in the parameter {@link android.widget.EditText}
535+
*
536+
* @param editText Characters to count from
537+
* @param tvCounterView {@link android.widget.TextView} to show live character count in
538+
* @param maxCharCount Max characters that can be typed in into the parameter edit text
539+
* @param countDown if true, only the remaining of the max character count will be displayed.
540+
* if false, current character count as well as max character count will be displayed in the UI.
541+
**/
542+
UiUtils.setCharCounter(editText, tvCounterView, maxCharCount, countDown);
543+
544+
545+
/**
546+
* set char counter
547+
* Shows live character counter for the number of characters
548+
*
549+
* @param textInputEditText Characters to count from
550+
* @param tvCounterView {@link android.widget.TextView} to show live character count in
551+
* @param maxCharCount Max characters that can be typed in into the parameter edit text
552+
* @param countDown if true, only the remaining of the max character count will be displayed.
553+
* if false, current character count as well as max character count will be displayed in the UI.
554+
**/
555+
UiUtils.setCharCounter(textInputEditText, tvCounterView, maxCharCount, countDown);
556+
557+
/**
558+
* set max length
559+
* this method sets max text length for text view
560+
*
561+
* @param textView - text view on which you want to set max length
562+
* @param maxLength - length to set on text view
563+
**/
564+
UiUtils.setMaxLength(textView, maxLength);
565+
566+
/**
567+
* set max length
568+
* this method sets max text length for text view
569+
*
570+
* @param editText - text view on which you want to set max length
571+
* @param maxLength - length to set on text view
572+
**/
573+
UiUtils.setMaxLength(editText, maxLength);
574+
575+
/**
576+
* set max length
577+
* this method sets max text length for text view
578+
*
579+
* @param textInputEditText - text view on which you want to set max length
580+
* @param maxLength - length to set on text view
581+
**/
582+
UiUtils.setMaxLength(textInputEditText, maxLength);
583+
584+
```
585+
586+
### Utils
587+
588+
>**This utils class helps for generic usages.**
589+
590+
**Usage**
591+
592+
```java
593+
/**
594+
* is Sd Card Mounted
595+
* this method will check if sd card is mounted or not
596+
*
597+
* @return - true or false
598+
* if sd card available then will return true
599+
* else will return false
600+
**/
601+
Utils.isSdCardMounted();
602+
603+
604+
/**
605+
* this method gets IMEI number after getting the permission.
606+
* To this method you must have asked user for READ_PHONE_STATE PERMISSION.
607+
*
608+
* @return - it will return IMEI number if permission granted
609+
* else if no permission granted then will return empty string.
610+
**/
611+
Util.sgetIMEINumber(context);
612+
613+
614+
/**
615+
* is url valid
616+
* this method will check if the url provided is valid or not
617+
*
618+
* @param url - url to check
619+
* @return - will return true if the url is valid
620+
* else will return false
621+
**/
622+
Utils.isUrlValid(url);
623+
624+
625+
/**
626+
* to Bold
627+
* this method will convert the normal text to bold
628+
*
629+
* @param sourceText - text to convert to bold
630+
*
631+
* @return - {@link android.text.SpannableString} in BOLD TypeFace
632+
**/
633+
Utils.toBold(sourceText);
634+
635+
636+
/**
637+
* to Bold
638+
* this method will convert a string or a sub string to bold
639+
*
640+
* @param string - string in which the sub string has to be converted to bold
641+
* or string to be converted to bold
642+
*
643+
* @param subString - The subString within the string to bold.
644+
* Pass null to bold entire string.
645+
*
646+
* @return - {@link android.text.SpannableString} in Bold TypeFace
647+
**/
648+
Utils.toBold(string, subString);
649+
650+
651+
/**
652+
* hide keyboard
653+
* this method will hide the keyboard
654+
*
655+
* @param context - context of the application
656+
**/
657+
Utils.hideKeyboard(context);
658+
659+
660+
/**
661+
* get sha 512 hash
662+
* this method will convert a string to byte array.
663+
*
664+
* @param stringToHash - string to convert to hash.
665+
*
666+
* @return string converted to hash value.
667+
**/
668+
Utils.getSha512Hash(stringToHash);
669+
670+
671+
/**
672+
* get sha 512 hash
673+
* this method will convert the byte array to string
674+
* which is converted to hash
675+
*
676+
* @param dataToHash - byte array to convert to hash value
677+
*
678+
* @return string converted into hash value.
679+
**/
680+
Utils.getSha512Hash(byte[] dataToHash);
681+
```

app/src/main/java/com/amit/utilities/Utils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ public static boolean isSdCardMounted()
6565
* else if no permission granted then will return empty string.
6666
**/
6767
@CheckResult
68-
public static String getIMEINumber(Context mContext)
68+
public static String getIMEINumber(Context context)
6969
{
7070
try
7171
{
7272
String imeiNumber;
73-
TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
73+
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
7474

7575
if (telephonyManager != null)
7676
{
7777
// checking if read phone state permission given or not
7878
// if yes the getting the imei number
7979
// else asking for permission
80-
if (ActivityCompat.checkSelfPermission(mContext,
80+
if (ActivityCompat.checkSelfPermission(context,
8181
Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED)
8282
{
8383
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)

0 commit comments

Comments
 (0)