-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a8c745f
Showing
62 changed files
with
2,864 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.2" | ||
defaultConfig { | ||
applicationId "com.ssw.utilsmanagerdemo" | ||
minSdkVersion 17 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
|
||
implementation project(path: ':commonutilsmanager') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
27 changes: 27 additions & 0 deletions
27
app/src/androidTest/java/com/ssw/utilsmanagerdemo/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.ssw.utilsmanagerdemo; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
|
||
assertEquals("com.ssw.utilsmanagerdemo", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.ssw.utilsmanagerdemo"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
230 changes: 230 additions & 0 deletions
230
app/src/main/java/com/ssw/utilsmanagerdemo/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
package com.ssw.utilsmanagerdemo; | ||
|
||
import android.os.Bundle; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.ssw.commonutilsmanager.app.AppManager; | ||
import com.ssw.commonutilsmanager.calendar.CalendarUtilsManager; | ||
import com.ssw.commonutilsmanager.credit_cards.CardNumberValidations; | ||
import com.ssw.commonutilsmanager.currencyamounts.AmountManager; | ||
import com.ssw.commonutilsmanager.device.DeviceManager; | ||
import com.ssw.commonutilsmanager.email.EmailManager; | ||
import com.ssw.commonutilsmanager.fingerprint.FingerPrintAuthenticationHandler; | ||
import com.ssw.commonutilsmanager.mobile.MobileManager; | ||
import com.ssw.commonutilsmanager.network.NetworkManager; | ||
import com.ssw.commonutilsmanager.nic.NICManager; | ||
import com.ssw.commonutilsmanager.toasts.ToastManager; | ||
import com.ssw.commonutilsmanager.utils.Utilizer; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
private static final String TAG = "MainActivity"; | ||
|
||
private TextView textView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
initComponents(); | ||
} | ||
|
||
private void initComponents() { | ||
textView = findViewById(R.id.textView); | ||
} | ||
|
||
// <editor-fold defaultstate="collapsed" desc="App Manager"> | ||
private void checkAppRunning() { | ||
System.out.println(AppManager.getInstance().isAppRunning(this, getPackageName())); | ||
} | ||
|
||
private void getAppVersion() { | ||
System.out.println(AppManager.getInstance().getAppVersion(this)); | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Finger Print Handler"> | ||
private void verifyFingerPrints() { | ||
if (DeviceManager.getInstance().isFingerPrintAvailable(this) && DeviceManager.getInstance().hasEnrolledFingerprints(this)) { | ||
FingerPrintAuthenticationHandler fingerPrintAuthenticationHandler = new FingerPrintAuthenticationHandler(this, new FingerPrintAuthenticationHandler.FingerPrintAuthenticationHandlerEvents() { | ||
@Override | ||
public void onAuthenticationSuccess() { | ||
ToastManager.getInstance().showTopToast(MainActivity.this, "Authentication Success", ToastManager.TOP_DURATION_LONG); | ||
} | ||
|
||
@Override | ||
public void onAuthenticationFailed() { | ||
ToastManager.getInstance().showTopToast(MainActivity.this, "Authentication Failed", ToastManager.TOP_DURATION_LONG); | ||
} | ||
|
||
@Override | ||
public void onAuthenticationCancelled() { | ||
ToastManager.getInstance().showTopToast(MainActivity.this, "Authentication Cancelled", ToastManager.TOP_DURATION_LONG); | ||
} | ||
}); | ||
|
||
fingerPrintAuthenticationHandler.startAuthentication("Title", "SubTitle", "Description", "BTNTEXT", R.mipmap.ic_launcher); | ||
} else { | ||
ToastManager.getInstance().showTopToast(this, "Fingerprint Not Support", ToastManager.TOAST_LENGTH_LONG); | ||
} | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Network Checker"> | ||
private void checkInternetOn() { | ||
System.out.println(NetworkManager.getInstance().isInternetOn(this)); | ||
} | ||
|
||
private void checkInternetAvailable() { | ||
NetworkManager.getInstance().isInternetAvailable(new NetworkManager.NetworkCheckListener() { | ||
@Override | ||
public void onInternetAvailable() { | ||
System.out.println("onInternetAvailable"); | ||
} | ||
|
||
@Override | ||
public void onError() { | ||
System.out.println("onError"); | ||
} | ||
}); | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="String Validations"> | ||
private void checkEmptyString() { | ||
System.out.println(Utilizer.getInstance().isStringEmpty("")); | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Card Number Validations, Card Types, Card Number Formatting"> | ||
private void validateCardNumber() { | ||
System.out.println(CardNumberValidations.getInstance().validateCreditCardNumber("123456789123456789")); | ||
} | ||
|
||
private void getFormattedCardNumber() { | ||
System.out.println(CardNumberValidations.getInstance().getFormattedCardNumber("1234567898765432", 4)); | ||
} | ||
|
||
private void getCardTypeFromNumber() { | ||
if (CardNumberValidations.getInstance().getCardTypeFromCardNumber("123456789123456789") == CardNumberValidations.CARD_TYPE_VISA) { | ||
|
||
} | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Calendar, Date Time ago"> | ||
private void getCurrentDateInCustomFormat() { | ||
System.out.println(CalendarUtilsManager.getInstance().getCurrentDateCustomFormat("yyyy-MMM-dd HH:mm:ss")); | ||
} | ||
|
||
private void getPreviousDate() { | ||
System.out.println(CalendarUtilsManager.getInstance().getPreviousDate(3, "yyyy-MMM-dd HH:mm:ss")); | ||
} | ||
|
||
private void convertDateStrings() { | ||
System.out.println(CalendarUtilsManager.getInstance().convertDateString(CalendarUtilsManager.getInstance().getCurrentDateCustomFormat("yyyy-MMM-dd HH:mm:ss"), "dd-MM-yyyy HH:mm:ss", "yyyy-MMM-dd HH:mm:ss", "yyyy-MMM-dd HH:mm:ss")); | ||
} | ||
|
||
private void getTimeAgo() { | ||
System.out.println(CalendarUtilsManager.getInstance().getDuration(System.currentTimeMillis() - CalendarUtilsManager.getInstance().getPreviousDate(3).getTime())); | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Mobile Numbers, Careers"> | ||
private void isValidMobileNumber() { | ||
//If career validation is true, number will validate with all the mobile number careers in Sri Lanka | ||
//Mobile number formats - +94773606094, 0094773606094, 0773606094 | ||
MobileManager.getInstance().isValidMobileNumber("+94773606094", true); | ||
} | ||
|
||
private void getCareerFromMobileNumber() { | ||
//Mobile number formats - +94773606094, 0094773606094, 0773606094 | ||
if (MobileManager.getInstance().getCareerFromMobileNumber("+94773606094") == MobileManager.CAREER_DIALOG) { | ||
|
||
} | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Toast Messages, SnackBards, Top Toasts"> | ||
private void showBasicSnackBar() { | ||
ToastManager.getInstance().showSnackBar(this.textView, "Test Message"); | ||
} | ||
|
||
private void showSnackBarWithAction() { | ||
ToastManager.getInstance().showSnackBar(this.textView, "Test Message", "OK", new ToastManager.SnackBarButtonAction() { | ||
@Override | ||
public void buttonClick() { | ||
Toast.makeText(getApplicationContext(), "Button Clicked", Toast.LENGTH_SHORT).show(); | ||
} | ||
}); | ||
} | ||
|
||
private void showToast() { | ||
ToastManager.getInstance().showToast(this, "Test Message", ToastManager.TOAST_LENGTH_LONG); | ||
} | ||
|
||
private void showTopToastShort() { | ||
ToastManager.getInstance().showTopToast(this, "Test Message", ToastManager.TOP_DURATION_SHORT); | ||
} | ||
|
||
private void showTopToastLong() { | ||
ToastManager.getInstance().showTopToast(this, "Test Message", ToastManager.TOP_DURATION_LONG); | ||
} | ||
|
||
private void showTopToastIndefinite() { | ||
ToastManager.getInstance().showTopToast(this, "Test Message", ToastManager.TOP_DURATION_INDEFINITE); | ||
} | ||
|
||
private void showTopToastWithStyles() { | ||
ToastManager.getInstance().showTopToast(this, "Test Message", ToastManager.TOP_DURATION_LONG, "#880000", "#880000", "#FFFFFF", 10); | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="NIC Numbers, Birthdays, Gender"> | ||
private void isValidNIC() { | ||
System.out.println(NICManager.getInstance().isValidNICNumber("199410900877")); //New NIC | ||
System.out.println(NICManager.getInstance().isValidNICNumber("942490259V")); // Old NIC | ||
} | ||
|
||
private void getBirthYearFromNIC() { | ||
System.out.println(NICManager.getInstance().getBirthYearFromNIC("199410900877")); //New NIC | ||
System.out.println(NICManager.getInstance().getBirthYearFromNIC("942490259V")); // Old NIC | ||
} | ||
|
||
private void getGenderFromNIC() { | ||
//New NIC | ||
if (NICManager.getInstance().getGenderFromNIC("199410900877") == NICManager.GENDER_FEMALE) { | ||
|
||
} | ||
|
||
// Old NIC | ||
else if (NICManager.getInstance().getGenderFromNIC("942490259V") == NICManager.GENDER_MALE) { | ||
|
||
} | ||
} | ||
|
||
private void getBirthdayFromNIC() { | ||
System.out.println(NICManager.getInstance().getBirthdayFromNIC("199410900877")); //New NIC | ||
System.out.println(NICManager.getInstance().getBirthdayFromNIC("942490259V")); //Old NIC | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Email Validations"> | ||
private void isValidEmailAddress() { | ||
System.out.println(EmailManager.getInstance().isValidEmailAddress("[email protected]")); | ||
} | ||
// </editor-fold> | ||
|
||
// <editor-fold defaultstate="collapsed" desc="Amounts"> | ||
private void getFormattedAmount() { | ||
System.out.println(AmountManager.getInstance().getFormattedAmount(15548.25)); | ||
} | ||
|
||
private void getCleanAmount() { | ||
System.out.println(AmountManager.getInstance().getDoubleValueOfAmount("15,753.14")); | ||
} | ||
// </editor-fold> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108"> | ||
<path | ||
android:fillType="evenOdd" | ||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:endX="78.5885" | ||
android:endY="90.9159" | ||
android:startX="48.7653" | ||
android:startY="61.0927" | ||
android:type="linear"> | ||
<item | ||
android:color="#44000000" | ||
android:offset="0.0" /> | ||
<item | ||
android:color="#00000000" | ||
android:offset="1.0" /> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:fillType="nonZero" | ||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000" /> | ||
</vector> |
Oops, something went wrong.