Add new changes GeoFencing-GeoTaging and hide Manual Inword Option etc
This commit is contained in:
@@ -0,0 +1,688 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.cpm.lorealbaautomation">
|
||||
|
||||
<permission
|
||||
android:name="com.cpm.lorealbaautomation.android.permission.SET_TIME"
|
||||
android:protectionLevel="signature|system"
|
||||
tools:ignore="ReservedSystemPermission" />
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:resizeable="true"
|
||||
android:smallScreens="true"
|
||||
android:xlargeScreens="true" />
|
||||
|
||||
<!-- Existing Permissions -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.hardware.camera.autofocus"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="true" />
|
||||
|
||||
<application
|
||||
android:name=".LorealBa"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/app_icon_rec"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:roundIcon="@mipmap/app_icon"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="@xml/backup_config"
|
||||
tools:replace="android:allowBackup"
|
||||
tools:ignore="DataExtractionRules">
|
||||
|
||||
<activity
|
||||
android:name=".reports.PerformanceHistoryActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.MeSaleReport"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.RetailExcellenceActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".makeupexpert.SalesActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".competitionoffer.CompetitionOfferActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.SkinGeniusScreenshotActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.SkinGeniusCategoryActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".timer.TimerActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".upload.UploadKeyData"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".upload.ManualUploadActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".consumeractivity.ConsumerReturnReplaceProductActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.SalesReportsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportDayWiseActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportConsumerWiseActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportConsumerProductWiseActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.FilledRegularStockDataActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.TargetAchievementActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".promooffer.PromoOffersActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".promooffer.PromoOfferDetailsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.MeQuizListActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.DamagedCategoryActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".pinviewactivity.PinViewActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.GWPActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_gwp"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.BAProfileActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_baprofile"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.VisibilityElimentsActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_visibility_eliments"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.CounterProfileActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_visibility_eliments"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.StoreImageActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_store_image"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.SuggestedStockActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_suggested_stock"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.DamagedActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_damaged"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.SampleStockActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_sample_stock"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.TesterStockActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_tester_stock"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.GroomedActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.TabLoginActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_change_password"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".UserLoginActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_user_login"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".password.MPinActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_mpin"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".password.ChangePasswordActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_change_password"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".AutoUpdateActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_auto_update"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".DealarBoardActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.CounterImageActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".IMEILoginActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".CounterLoginActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".download.DownloadActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name="io.github.memfis19.annca.internal.ui.camera.Camera1Activity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/ThemeFullscreen"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" /> <!-- Declaring Service in Manifest -->
|
||||
<activity
|
||||
android:name="io.github.memfis19.annca.internal.ui.preview.PreviewActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/ThemeFullscreen"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" /> <!-- for custom camera -->
|
||||
<activity
|
||||
android:name=".dailyactivity.ServiceActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.ConsumerReturnActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.StockCheckActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.NotificationDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.NotificationsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.InWardStockActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.InwardStockDetailsActivity"
|
||||
android:label="@string/title_activity_suggested_stock"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".consumeractivity.InvoiceReportProformaActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".consumeractivity.ConsumerUserDetailsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".consumeractivity.ConsumerIntractionDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".printer.PrinterActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".printer.DeviceListActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.ManualInWardStockActivity"
|
||||
android:label="@string/title_activity_suggested_stock"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".leavemanagement.ApplyForLeaveActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".leavemanagement.LeaveManagemntActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".breakmanagement.BreakManagementActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".consumeractivity.ConsumerReturnsHistoryActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.MyLibraryActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportsTop10Value"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportsInwordStock"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportAttendanceSummaryActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.TesterReportActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.KPITrackerActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.DashbordOffTakeReportActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.dailyTva.DailyTVAActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.testerdetails.TesterUsageReportActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.countervaluevolume.CounterValueVolumeDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".reports.inwarddetails.CounterInwordDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".forgotpassword.ForgotpasswordActity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.ReportBaAvailability"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".makeupexpert.MakeoverDetailsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".makeupexpert.MakeoverActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".makeupexpert.MEQuizActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity"
|
||||
tools:replace="screenOrientation" />
|
||||
|
||||
<activity
|
||||
android:name=".notification.NotificationView"
|
||||
android:label="Details of notification"
|
||||
android:parentActivityName=".DealarBoardActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".DealarBoardActivity" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".dailyactivity.BASurveyActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".dailyactivity.BASurveyListActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
<activity
|
||||
android:name=".reports.DamagedStockHistory"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".leavemanagement.LeaveCalenderViewActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".geotag.GeoTaggingActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
|
||||
|
||||
<!-- <meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyAJIqKPhsyYTp6WnM387Fri4nLJo4-mOvc"
|
||||
/>
|
||||
android:value="@string/google_geo_api_key"-->
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyCs2VZqLl4OgStAraUHr8012cUc7vf3Uo8" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.file provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true"
|
||||
tools:replace="android:authorities">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths"
|
||||
tools:replace="android:resource" />
|
||||
</provider>
|
||||
|
||||
<service
|
||||
android:name=".service.MyFirebaseMessagingService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".download.Downloader"
|
||||
android:exported="false"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.cpm.lorealbaautomation;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.view.Window;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class AutoUpdateActivity extends AppCompatActivity {
|
||||
private static final int PERMISSION_ALL = 99;
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
private String path = "";
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_auto_update);
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
Intent intent = getIntent();
|
||||
path = intent.getStringExtra(CommonString.KEY_PATH);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(getString(R.string.parinaam));
|
||||
builder.setMessage(getString(R.string.new_update_available))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, (dialog, id) -> new DownloadTask(AutoUpdateActivity.this).execute());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
private class DownloadTask extends AsyncTask<Void, Data, String> {
|
||||
private final Context context;
|
||||
|
||||
DownloadTask(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
dialog = new Dialog(context);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
||||
dialog.setContentView(R.layout.custom_dialog_progress);
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
Data data = new Data();
|
||||
data.name = "Downloading Application";
|
||||
publishProgress(data);
|
||||
String versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
||||
data.name = "Upgrading Version : " + versionCode;
|
||||
publishProgress(data);
|
||||
// download application
|
||||
URL url = new URL(path);
|
||||
HttpURLConnection c = (HttpURLConnection) url.openConnection();
|
||||
c.setRequestMethod("GET");
|
||||
c.getResponseCode();
|
||||
c.connect();
|
||||
int length = c.getContentLength();
|
||||
String size = new DecimalFormat("##.##").format((double) length / 1024 / 1024) + " MB";
|
||||
String PATH = CommonString.getLorealBaApkFolder(context);
|
||||
File outputFile = new File(PATH, "app.apk");
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
InputStream is = c.getInputStream();
|
||||
int bytes = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
int len1;
|
||||
while ((len1 = is.read(buffer)) != -1) {
|
||||
bytes = (bytes + len1);
|
||||
String s = new DecimalFormat("##.##").format((double) (bytes / 1024) / 1024);
|
||||
String p = s.length() == 3 ? s + "0" : s;
|
||||
p = p + " MB";
|
||||
data.value = (int) (((double) bytes) / length * 100);
|
||||
data.name = "Download " + p + "/" + size;
|
||||
publishProgress(data);
|
||||
fos.write(buffer, 0, len1);
|
||||
}
|
||||
fos.close();
|
||||
is.close();
|
||||
return CommonString.KEY_SUCCESS;
|
||||
} catch (PackageManager.NameNotFoundException | MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
runOnUiThread(() -> {
|
||||
// TODO Auto-generated method stub
|
||||
AlertandMessages.showAlert((Activity) context, CommonString.MESSAGE_EXCEPTION + "\n" + e.getLocalizedMessage(), true);
|
||||
});
|
||||
} catch (IOException e) {
|
||||
runOnUiThread(() -> {
|
||||
// TODO Auto-generated method stub
|
||||
AlertandMessages.showAlert((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION + "\n" + e.getLocalizedMessage(), true);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
runOnUiThread(() -> AlertandMessages.showAlert((Activity) context, CommonString.MESSAGE_EXCEPTION + "\n" + e.getLocalizedMessage(), true));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onProgressUpdate(Data... values) {
|
||||
// TODO Auto-generated method stub
|
||||
pb.setProgress(values[0].value);
|
||||
percentage.setText(values[0].value + "%");
|
||||
message.setText(values[0].name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
dialog.dismiss();
|
||||
if (result.equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
File toInstall = new File(CommonString.getLorealBaApkFolder(context) + "app.apk");
|
||||
Uri apkUri;
|
||||
Intent intent;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
apkUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", toInstall);
|
||||
intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
intent.setData(apkUri);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
} else {
|
||||
apkUri = Uri.fromFile(toInstall);
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int value;
|
||||
String name;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
||||
package com.cpm.lorealbaautomation.Get_IMEI_number;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
public class ImeiNumberClass extends AppCompatActivity {
|
||||
|
||||
private TelephonyManager mTelephonyManager;
|
||||
Context context;
|
||||
|
||||
public ImeiNumberClass(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String[] getDeviceImei() {
|
||||
|
||||
String deviceid[] = null;
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (mTelephonyManager != null) {
|
||||
deviceid = getSimImei();
|
||||
} else {
|
||||
return new String[]{"0"};
|
||||
}
|
||||
return deviceid;
|
||||
}
|
||||
|
||||
|
||||
public String[] getSimImei() {
|
||||
TelephonyInfo telephonyInfo = TelephonyInfo.getInstance(context);
|
||||
|
||||
String imeiSIM1 = null, imeiSIM2 = null;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (mTelephonyManager.getPhoneCount() > 1) {
|
||||
imeiSIM1 = telephonyInfo.getImeiSIM1();
|
||||
imeiSIM2 = telephonyInfo.getImeiSIM2();
|
||||
return new String[]{imeiSIM1, imeiSIM2};
|
||||
} else {
|
||||
imeiSIM1 = telephonyInfo.getImeiSIM1();
|
||||
return new String[]{imeiSIM1};
|
||||
}
|
||||
} else {
|
||||
if (telephonyInfo.isDualSIM()) {
|
||||
imeiSIM1 = telephonyInfo.getImeiSIM1();
|
||||
imeiSIM2 = telephonyInfo.getImeiSIM2();
|
||||
return new String[]{imeiSIM1, imeiSIM2};
|
||||
} else {
|
||||
imeiSIM1 = telephonyInfo.getImeiSIM1();
|
||||
return new String[]{imeiSIM1};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.cpm.lorealbaautomation.Get_IMEI_number;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Created by deepakp on 9/27/2017.
|
||||
*/
|
||||
|
||||
public class TelephonyInfo {
|
||||
|
||||
private static TelephonyInfo telephonyInfo;
|
||||
private String imeiSIM1;
|
||||
private String imeiSIM2;
|
||||
|
||||
public String getImeiSIM1() {
|
||||
return imeiSIM1;
|
||||
}
|
||||
|
||||
public String getImeiSIM2() {
|
||||
return imeiSIM2;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDualSIM() {
|
||||
return imeiSIM2 != null;
|
||||
}
|
||||
|
||||
|
||||
public static TelephonyInfo getInstance(Context context) {
|
||||
|
||||
if (telephonyInfo == null) {
|
||||
|
||||
telephonyInfo = new TelephonyInfo();
|
||||
|
||||
telephonyInfo.imeiSIM1 = null;
|
||||
telephonyInfo.imeiSIM2 = null;
|
||||
try {
|
||||
telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceIdGemini", 0);
|
||||
telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceIdGemini", 1);
|
||||
} catch (GeminiMethodNotFoundException e) {
|
||||
e.fillInStackTrace();
|
||||
|
||||
try {
|
||||
telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceId", 0);
|
||||
telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceId", 1);
|
||||
} catch (GeminiMethodNotFoundException e1) {
|
||||
//Call here for next manufacturer's predicted method name if you wish
|
||||
e1.fillInStackTrace();
|
||||
try {
|
||||
telephonyInfo.imeiSIM1 = getDeviceIdBySlotNew(context, "getDeviceId", 0);
|
||||
telephonyInfo.imeiSIM2 = getDeviceIdBySlotNew(context, "getDeviceId", 1);
|
||||
} catch (GeminiMethodNotFoundException e2) {
|
||||
e2.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return telephonyInfo;
|
||||
}
|
||||
|
||||
|
||||
private static String getDeviceIdBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException {
|
||||
|
||||
String imei = null;
|
||||
|
||||
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
try {
|
||||
|
||||
Class<?> telephonyClass = Class.forName(telephony.getClass().getName());
|
||||
Class<?>[] parameter = new Class[1];
|
||||
parameter[0] = int.class;
|
||||
Method getSimID = telephonyClass.getMethod(predictedMethodName, parameter);
|
||||
|
||||
Object[] obParameter = new Object[1];
|
||||
obParameter[0] = slotID;
|
||||
Object ob_phone = getSimID.invoke(telephony, obParameter);
|
||||
|
||||
|
||||
if (ob_phone != null) {
|
||||
imei = ob_phone.toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
if (e instanceof NoSuchMethodException && predictedMethodName.equalsIgnoreCase("getDeviceId")) {
|
||||
Class<?> telephonyClass = null;
|
||||
try {
|
||||
telephonyClass = Class.forName(telephony.getClass().getName());
|
||||
Class<?>[] parameter = new Class[1];
|
||||
parameter[0] = int.class;
|
||||
Method getSimID = telephonyClass.getMethod("getDefault", parameter);
|
||||
Object[] obParameter = new Object[1];
|
||||
obParameter[0] = slotID;
|
||||
//TelephonyManager ob_phone = (TelephonyManager) getSimID.invoke(null, obParameter);
|
||||
TelephonyManager ob_phone = (TelephonyManager) getSimID.invoke(telephony, obParameter);
|
||||
if (ob_phone != null) {
|
||||
imei = ob_phone.getDeviceId().toString();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.fillInStackTrace();
|
||||
throw new GeminiMethodNotFoundException(predictedMethodName);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new GeminiMethodNotFoundException(predictedMethodName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return imei;
|
||||
}
|
||||
|
||||
private static String getDeviceIdBySlotNew(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException {
|
||||
String imei = "0";
|
||||
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
try {
|
||||
if (telephony.getDeviceId() != null) {
|
||||
imei = telephony.getDeviceId().toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return imei;
|
||||
}
|
||||
|
||||
|
||||
private static class GeminiMethodNotFoundException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -996812356902545308L;
|
||||
|
||||
public GeminiMethodNotFoundException(String info) {
|
||||
super(info);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,742 @@
|
||||
package com.cpm.lorealbaautomation;
|
||||
|
||||
import static com.cpm.lorealbaautomation.constant.CommonFunctions.checkincomplete_upload_data;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.PendingResult;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.location.LocationListener;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.location.LocationSettingsRequest;
|
||||
import com.google.android.gms.location.LocationSettingsResult;
|
||||
import com.google.android.gms.location.LocationSettingsStatusCodes;
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.google.gson.Gson;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.Get_IMEI_number.ImeiNumberClass;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.dailyactivity.NotificationDetailActivity;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.CounterDeviceLoginGetterSetter;
|
||||
import com.cpm.lorealbaautomation.retrofit.PostApi;
|
||||
import com.cpm.lorealbaautomation.upload.ManualUploadActivity;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class IMEILoginActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks,
|
||||
GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
||||
private String[] imeiNumbers;
|
||||
private String app_ver;
|
||||
private Context context;
|
||||
private static final int LOGIN_AFTER_NOTIFICATION = 2;
|
||||
ProgressDialog loading = null;
|
||||
private Retrofit adapter;
|
||||
private SharedPreferences preferences = null;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
private double lat = 0.0;
|
||||
private double lon = 0.0;
|
||||
private int versionCode;
|
||||
private String manufacturer;
|
||||
private String model;
|
||||
private String os_version;
|
||||
GoogleApiClient mGoogleApiClient;
|
||||
private static int UPDATE_INTERVAL = 200; // 5 sec
|
||||
private static int FATEST_INTERVAL = 100; // 1 sec
|
||||
private static int DISPLACEMENT = 1; // 10 meters
|
||||
private static final int REQUEST_LOCATION = 1;
|
||||
private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000;
|
||||
private Location mLastLocation;
|
||||
private LocationRequest mLocationRequest;
|
||||
private static final int PERMISSION_ALL = 99;
|
||||
private ImeiNumberClass imei;
|
||||
Lorealba_Database db;
|
||||
String title = "", body = "", path = "", counter_id, type, visit_date;
|
||||
TextView versioncode_txt;
|
||||
LinearLayout rl_counterlogin;
|
||||
CounterDeviceLoginGetterSetter userapp_databaseObject = null;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_counter_login);
|
||||
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
|
||||
if (getIntent().getExtras() != null) {
|
||||
long value = 0;
|
||||
for (String key : getIntent().getExtras().keySet()) {
|
||||
if (key.equalsIgnoreCase("title")) {
|
||||
title = getIntent().getExtras().getString(key);
|
||||
} else if (key.equalsIgnoreCase("body")) {
|
||||
body = getIntent().getExtras().getString(key);
|
||||
} else if (key.equalsIgnoreCase("path")) {
|
||||
path = getIntent().getExtras().getString(key);
|
||||
} else if (key.equalsIgnoreCase("Mediatype")) {
|
||||
type = getIntent().getExtras().getString(key);
|
||||
}
|
||||
}
|
||||
assert title != null;
|
||||
if (!title.isEmpty() && !Objects.requireNonNull(body).isEmpty()) {
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
value = db.insertNotificationData(title, body, path, visit_date, type, counter_id);
|
||||
if (value > 0) {
|
||||
Toast.makeText(context, "Notification Inserted", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(context, "Notification Not Inserted", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
getViewId();
|
||||
}
|
||||
|
||||
if (!title.isEmpty()) {
|
||||
Intent in = new Intent(this, NotificationDetailActivity.class);
|
||||
in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
in.putExtra("Type", type);
|
||||
in.putExtra("Title", title);
|
||||
in.putExtra("Body", body);
|
||||
in.putExtra("Path", path);
|
||||
in.putExtra("KEY_ID", value + "");
|
||||
startActivityForResult(in, LOGIN_AFTER_NOTIFICATION);
|
||||
}
|
||||
} else {
|
||||
getViewId();
|
||||
}
|
||||
|
||||
versioncode_txt = (TextView) findViewById(R.id.versioncode_txt);
|
||||
rl_counterlogin = (LinearLayout) findViewById(R.id.rl_counterlogin);
|
||||
rl_counterlogin.setVisibility(View.GONE);
|
||||
try {
|
||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
String version = pInfo.versionName;
|
||||
versioncode_txt.setText("Version : " + version);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.fillInStackTrace();
|
||||
versioncode_txt.setText("Version : 0.0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
context = this;
|
||||
if (mGoogleApiClient != null) {
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
|
||||
checkgpsEnableDevice();
|
||||
if (checkAndRequestPermissions()) {
|
||||
imeiNumbers = imei.getDeviceImei();
|
||||
getDeviceName();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("VisibleForTests")
|
||||
protected void createLocationRequest() {
|
||||
mLocationRequest = new LocationRequest();
|
||||
if (mLocationRequest != null)
|
||||
mLocationRequest.setInterval(UPDATE_INTERVAL);
|
||||
mLocationRequest.setFastestInterval(FATEST_INTERVAL);
|
||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
|
||||
}
|
||||
|
||||
private void checkgpsEnableDevice() {
|
||||
if (!hasGPSDevice(context)) {
|
||||
Toast.makeText(context, "Gps not Supported", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(context)) {
|
||||
enableLoc();
|
||||
} else if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(context)) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasGPSDevice(Context context) {
|
||||
final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
if (mgr == null)
|
||||
return false;
|
||||
final List<String> providers = mgr.getAllProviders();
|
||||
if (providers == null)
|
||||
return false;
|
||||
return providers.contains(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
|
||||
@SuppressLint("VisibleForTests")
|
||||
private void enableLoc() {
|
||||
LocationRequest locationRequest = LocationRequest.create();
|
||||
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
locationRequest.setInterval(30 * 1000);
|
||||
locationRequest.setFastestInterval(5 * 1000);
|
||||
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
|
||||
builder.setAlwaysShow(true);
|
||||
if (mGoogleApiClient != null) {
|
||||
PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
|
||||
result.setResultCallback(result1 -> {
|
||||
final Status status = result1.getStatus();
|
||||
if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
|
||||
try {
|
||||
// Show the dialog by calling startResolutionForResult(),
|
||||
// and check the result in onActivityResult().
|
||||
status.startResolutionForResult((Activity) context, REQUEST_LOCATION);
|
||||
} catch (IntentSender.SendIntentException e) {
|
||||
// Ignore the error.
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean checkPlayServices() {
|
||||
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
|
||||
if (resultCode != ConnectionResult.SUCCESS) {
|
||||
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
|
||||
GooglePlayServicesUtil.getErrorDialog(resultCode, (Activity) context, PLAY_SERVICES_RESOLUTION_REQUEST).show();
|
||||
} else {
|
||||
Toast.makeText(context, getResources().getString(R.string.notsuppoted), Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected synchronized void buildGoogleApiClient() {
|
||||
if (mGoogleApiClient == null) {
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(context).addConnectionCallbacks(this).addOnConnectionFailedListener(this)
|
||||
.addApi(LocationServices.API).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
private void AttempLogin() {
|
||||
try {
|
||||
try {
|
||||
app_ver = String.valueOf(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
loading = ProgressDialog.show(IMEILoginActivity.this, "Processing", "Please wait...", false, false);
|
||||
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
jsonObject.put("OSVersion", os_version);
|
||||
jsonObject.put("Manufacturer", manufacturer);
|
||||
jsonObject.put("ModelNumber", model);
|
||||
jsonObject.put("Networkstatus", "0");
|
||||
jsonObject.put("Attmode", "0");
|
||||
jsonObject.put("Appversion", app_ver);
|
||||
jsonObject.put("Latitude", lat);
|
||||
jsonObject.put("Longitude", lon);
|
||||
jsonObject.put("CounterCode", "0");
|
||||
jsonObject.put("AppId", BuildConfig.APPLICATION_ID);
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
||||
@SuppressLint("HardwareIds") String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
jsonObject.put("IMEINumber1", android_id);
|
||||
} else {
|
||||
if (imeiNumbers != null && imeiNumbers.length > 0) {
|
||||
jsonObject.put("IMEINumber1", imeiNumbers[0]);
|
||||
} else {
|
||||
jsonObject.put("IMEINumber1", "0");
|
||||
}
|
||||
}
|
||||
|
||||
String jsonString = jsonObject.toString();
|
||||
Log.e("jsonlogindata", jsonString);
|
||||
try {
|
||||
final OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).writeTimeout
|
||||
(CommonString.TIMEOUT, TimeUnit.SECONDS).connectTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).build();
|
||||
RequestBody jsonData = RequestBody.create(MediaType.parse("application/json"), jsonString);
|
||||
adapter = new Retrofit.Builder().baseUrl(CommonString.URL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create()).build();
|
||||
PostApi api = adapter.create(PostApi.class);
|
||||
Call<ResponseBody> call = api.getLogindetail(jsonData);
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
|
||||
ResponseBody responseBody = response.body();
|
||||
String data = null;
|
||||
if (responseBody != null && response.isSuccessful()) {
|
||||
try {
|
||||
assert response.body() != null;
|
||||
data = response.body().string();
|
||||
data = data.substring(1, data.length() - 1).replace("\\", "");
|
||||
Gson gson = new Gson();
|
||||
final CounterDeviceLoginGetterSetter userObject = gson.fromJson(data, CounterDeviceLoginGetterSetter.class);
|
||||
if (data.equalsIgnoreCase(CommonString.KEY_FAILURE)) {
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.KEY_FAILURE + " Please try again");
|
||||
loading.dismiss();
|
||||
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
} else if (userObject != null) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("Downloadtype", "AppDatabaseName");
|
||||
jsonObject1.put("Username", "");
|
||||
jsonObject1.put("Param1", "");
|
||||
jsonObject1.put("Param2", "");
|
||||
|
||||
final OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS)
|
||||
.writeTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).connectTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).build();
|
||||
RequestBody jsonData = RequestBody.create(MediaType.parse("application/json"), jsonObject1.toString());
|
||||
adapter = new Retrofit.Builder().baseUrl(CommonString.URL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create()).build();
|
||||
PostApi api = adapter.create(PostApi.class);
|
||||
Call<String> call_appdatabase = api.getDownloadAll(jsonData);
|
||||
call_appdatabase.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
String responseBody_dab = response.body();
|
||||
String data_datab = null;
|
||||
if (responseBody_dab != null && response.isSuccessful()) {
|
||||
data_datab = response.body();
|
||||
assert data_datab != null;
|
||||
if (!data_datab.isEmpty()) {
|
||||
if (!data_datab.contains("No Data")) {
|
||||
userapp_databaseObject = new Gson().fromJson(data_datab, CounterDeviceLoginGetterSetter.class);
|
||||
}
|
||||
}
|
||||
if (userapp_databaseObject != null && !userapp_databaseObject.getAppDatabaseName().isEmpty()) {
|
||||
int temp_db_versioncode = preferences.getInt(CommonString.KEY_TEMP_DB_VERSION, 0);
|
||||
if (userapp_databaseObject.getAppDatabaseName().get(0).getAppVersion() != temp_db_versioncode) {
|
||||
////for Database delete
|
||||
delete_local_database();
|
||||
}
|
||||
editor.putInt(CommonString.KEY_TEMP_DB_VERSION, userapp_databaseObject.getAppDatabaseName().get(0).getAppVersion());
|
||||
}
|
||||
editor.putString(CommonString.KEY_VERSION, userObject.getCounterDeviceLogin().get(0).getAppVersion().toString());
|
||||
editor.putString(CommonString.KEY_PATH, userObject.getCounterDeviceLogin().get(0).getAppPath());
|
||||
editor.putString(CommonString.KEY_DATE, userObject.getCounterDeviceLogin().get(0).getVisitDate());
|
||||
editor.putString(CommonString.KEY_COUNTER_ID, userObject.getCounterDeviceLogin().get(0).getCounterId().toString());
|
||||
editor.putString(CommonString.KEY_COUNTER_CODE, userObject.getCounterDeviceLogin().get(0).getCounterCode());
|
||||
editor.putString(CommonString.KEY_COUNTER_NAME, userObject.getCounterDeviceLogin().get(0).getCounterName());
|
||||
editor.apply();
|
||||
if (userObject.getCounterDeviceLogin().get(0).getAppVersion().equals(versionCode)) {
|
||||
//-------upload previous day pending data---------------------
|
||||
if (userObject.getCounterDeviceLogin().get(0).getCounterId().equals(0)) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
Intent intent = new Intent(getBaseContext(), CounterLoginActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
finish();
|
||||
} else {
|
||||
db.open();
|
||||
String datee = userObject.getCounterDeviceLogin().get(0).getVisitDate();
|
||||
if (!db.getmasterTransaction(datee, userObject.getCounterDeviceLogin().get(0).getCounterId().toString(), true).isEmpty()
|
||||
|| !checkincomplete_upload_data(datee,
|
||||
userObject.getCounterDeviceLogin().get(0).getCounterId().toString(), db, true)) {
|
||||
startActivity(new Intent(context, ManualUploadActivity.class).putExtra(CommonString.TAG_OBJECT,
|
||||
userObject.getCounterDeviceLogin().get(0).getCounterId()));
|
||||
} else {
|
||||
Intent intent = new Intent(getBaseContext(), UserLoginActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
IMEILoginActivity.this.finish();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
Intent intent = new Intent(getBaseContext(), AutoUpdateActivity.class);
|
||||
intent.putExtra(CommonString.KEY_PATH, preferences.getString(CommonString.KEY_PATH, ""));
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
IMEILoginActivity.this.finish();
|
||||
}
|
||||
} else {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_NO_RESPONSE_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_NO_RESPONSE_SERVER);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
loading.dismiss();
|
||||
FirebaseCrashlytics.getInstance().recordException(e);
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
|
||||
e.fillInStackTrace();
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION + " - " + e.toString());
|
||||
}
|
||||
} else {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_NO_RESPONSE_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
loading.dismiss();
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
e.fillInStackTrace();
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION + " - " + e.toString());
|
||||
|
||||
}
|
||||
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
AlertandMessages.showAlertCounterlogin((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION + " - " + e.toString());
|
||||
|
||||
} catch (JSONException e) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getDeviceName() {
|
||||
try {
|
||||
manufacturer = Build.MANUFACTURER;
|
||||
model = Build.MODEL;
|
||||
os_version = Build.VERSION.RELEASE;
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void delete_local_database() {
|
||||
boolean deleted = true;
|
||||
try {
|
||||
File datadbfile = Environment.getDataDirectory();
|
||||
String currentDBPath = "//data//" + BuildConfig.APPLICATION_ID + "//databases//" + Lorealba_Database.DATABASE_NAME;
|
||||
File currentDB = new File(datadbfile, currentDBPath);
|
||||
deleted = SQLiteDatabase.deleteDatabase(currentDB);
|
||||
if (deleted) {
|
||||
AlertandMessages.showToastMsg(context, "Database Deleted Successfully");
|
||||
}
|
||||
new Lorealba_Database(context).open();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onConnected(Bundle bundle) {
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
// here to request the missing permissions, and then overriding
|
||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
return;
|
||||
}
|
||||
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (mLastLocation != null) {
|
||||
lat = mLastLocation.getLatitude();
|
||||
lon = mLastLocation.getLongitude();
|
||||
}
|
||||
|
||||
startLocationUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuspended(int i) {
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
|
||||
if (mGoogleApiClient != null) {
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (mGoogleApiClient != null) {
|
||||
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (mGoogleApiClient != null) {
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
}
|
||||
|
||||
protected void startLocationUpdates() {
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (mGoogleApiClient != null) {
|
||||
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getViewId() {
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
editor = preferences.edit();
|
||||
imei = new ImeiNumberClass(context);
|
||||
if (checkAndRequestPermissions()) {
|
||||
imeiNumbers = imei.getDeviceImei();
|
||||
getDeviceName();
|
||||
AttempLogin();
|
||||
}
|
||||
|
||||
try {
|
||||
app_ver = String.valueOf(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case (LOGIN_AFTER_NOTIFICATION): {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
// TODO Extract the data returned from the child Activity.
|
||||
getViewId();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAndRequestPermissions() {
|
||||
int CAMERA = ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA);
|
||||
int ACCESS_NETWORK_STATE = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_NETWORK_STATE);
|
||||
int ACCESS_COARSE_LOCATION = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
int locationPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
int READ_PHONE_STATE = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
|
||||
List<String> listPermissionsNeeded = new ArrayList<>();
|
||||
|
||||
if (CAMERA != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.CAMERA);
|
||||
}
|
||||
|
||||
if (ACCESS_NETWORK_STATE != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_NETWORK_STATE);
|
||||
}
|
||||
if (ACCESS_COARSE_LOCATION != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
if (locationPermission != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
|
||||
if (READ_PHONE_STATE != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
|
||||
}
|
||||
|
||||
|
||||
if (!listPermissionsNeeded.isEmpty()) {
|
||||
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), PERMISSION_ALL);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showDialogOK(DialogInterface.OnClickListener okListener) {
|
||||
new AlertDialog.Builder(this).setMessage("Location,File,Call and Camera Services Permission required for this app").setPositiveButton("OK", okListener).setNegativeButton("Cancel", okListener).create().show();
|
||||
}
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
Log.d("", "Permission callback called-------");
|
||||
if (requestCode == PERMISSION_ALL) {
|
||||
Map<String, Integer> perms = new HashMap<>();
|
||||
// Initialize the map with both permissions
|
||||
perms.put(Manifest.permission.CAMERA, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.ACCESS_NETWORK_STATE, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.ACCESS_COARSE_LOCATION, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.ACCESS_FINE_LOCATION, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.READ_PHONE_STATE, PackageManager.PERMISSION_GRANTED);
|
||||
// Fill with actual results from user
|
||||
if (grantResults.length > 0) {
|
||||
for (int i = 0; i < permissions.length; i++)
|
||||
perms.put(permissions[i], grantResults[i]);
|
||||
// Check for both permissions
|
||||
boolean allPermissionsGranted =
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.CAMERA)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.ACCESS_NETWORK_STATE)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.ACCESS_COARSE_LOCATION)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.ACCESS_FINE_LOCATION)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.READ_PHONE_STATE));
|
||||
|
||||
if (allPermissionsGranted){
|
||||
getDeviceName();
|
||||
imeiNumbers = imei.getDeviceImei();
|
||||
AttempLogin();
|
||||
}
|
||||
|
||||
Log.d("", "sms & location services permission granted");
|
||||
} else {
|
||||
Log.d("", "Some permissions are not granted ask again ");
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_NETWORK_STATE) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
|
||||
showDialogOK(
|
||||
(dialog, which) -> {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
checkAndRequestPermissions();
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
// proceed with logic by disabling the related features or quit the app.
|
||||
Intent startMain = new Intent(Intent.ACTION_MAIN);
|
||||
startMain.addCategory(Intent.CATEGORY_HOME);
|
||||
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(startMain);
|
||||
break;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(this, "Go to settings and enable permissions", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MultiPurposeDialog extends Dialog {
|
||||
public MultiPurposeDialog(Context context) {
|
||||
super(context);
|
||||
WindowManager.LayoutParams wmLayoutParams = Objects.requireNonNull(getWindow()).getAttributes();
|
||||
wmLayoutParams.gravity = Gravity.CENTER;
|
||||
getWindow().setAttributes(wmLayoutParams);
|
||||
setTitle(null);
|
||||
setCancelable(false);
|
||||
setOnCancelListener(null);
|
||||
LinearLayout layout = new LinearLayout(context);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
try {
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.cpm.lorealbaautomation;
|
||||
import android.app.Application;
|
||||
|
||||
public class LorealBa extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
package com.cpm.lorealbaautomation;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.dailyactivity.NotificationDetailActivity;
|
||||
import com.cpm.lorealbaautomation.dailyactivity.TabLoginActivity;
|
||||
import com.cpm.lorealbaautomation.gettersetter.LoginGetterSetter;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.BaListGetterSetter;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JCPGetterSetter;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.TableStructure;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.TableStructureGetterSetter;
|
||||
import com.cpm.lorealbaautomation.retrofit.DownloadAllDatawithRetro;
|
||||
import com.cpm.lorealbaautomation.retrofit.PostApi;
|
||||
import com.cpm.lorealbaautomation.retrofit.UploadDataWithRetrofit;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class UserLoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
String counterId = "", visitdate = "", jsonString = "", result = "", counterName = "", counter_code = "", title = "", body = "", path = "", type;
|
||||
SharedPreferences preferences;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
private Context context;
|
||||
LinearLayout lay_ba, lay_ma, lay_tba;
|
||||
Button btncontinue;
|
||||
String userId;
|
||||
Lorealba_Database db;
|
||||
int downloadindex = 0;
|
||||
ProgressDialog loading = null;
|
||||
ArrayList<BaListGetterSetter> bsListData = new ArrayList<>();
|
||||
ArrayList<LoginGetterSetter> allLoginListData = new ArrayList<>();
|
||||
EditText user_password;
|
||||
String TAG = getClass().getSimpleName();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
TextView counter_name, versioncode_txt;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_user_login);
|
||||
getViewId();
|
||||
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
if (!task.isSuccessful()) {
|
||||
Log.w(TAG, "Fetching FCM registration token failed", task.getException());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get new FCM registration token
|
||||
String token = task.getResult();
|
||||
try {
|
||||
jsonObject.put("CounterId", counterId);
|
||||
jsonObject.put("RegistrationId", token);
|
||||
jsonString = jsonObject.toString();
|
||||
UploadDataWithRetrofit upload = new UploadDataWithRetrofit(context);
|
||||
result = upload.uploadDeviceTokenDetails(jsonString, CommonString.UPLOAD_DEVICE_TOKEN_DETAILS);
|
||||
} catch (JSONException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
// Log and toast
|
||||
//test(TAG, "Token: " + token);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void getViewId() {
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
editor = preferences.edit();
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
lay_ba = (LinearLayout) findViewById(R.id.lay_ba);
|
||||
lay_ma = (LinearLayout) findViewById(R.id.lay_ma);
|
||||
lay_tba = (LinearLayout) findViewById(R.id.lay_tba);
|
||||
btncontinue = (Button) findViewById(R.id.btncontinue);
|
||||
|
||||
user_password = (EditText) findViewById(R.id.user_password);
|
||||
counter_name = (TextView) findViewById(R.id.counter_name);
|
||||
versioncode_txt = (TextView) findViewById(R.id.versioncode_txt);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setTitle(getString(R.string.user_login));
|
||||
|
||||
counterId = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
counter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
counterName = preferences.getString(CommonString.KEY_COUNTER_NAME, "");
|
||||
visitdate = preferences.getString(CommonString.KEY_DATE, "");
|
||||
counter_name.setText("Counter Name : " + counterName + "\n" + "Counter Code : " + counter_code);
|
||||
lay_ba.setOnClickListener(this);
|
||||
lay_ma.setOnClickListener(this);
|
||||
lay_tba.setOnClickListener(this);
|
||||
btncontinue.setOnClickListener(this);
|
||||
checkAndRequestPermissions();
|
||||
|
||||
bsListData = db.getBAListAllData(visitdate, counterId);
|
||||
if (bsListData.size() == 0) {
|
||||
UploadDataTask();
|
||||
}
|
||||
|
||||
if (getIntent().getExtras() != null) {
|
||||
for (String key : getIntent().getExtras().keySet()) {
|
||||
if (key.equalsIgnoreCase("title")) {
|
||||
title = getIntent().getExtras().getString(key);
|
||||
} else if (key.equalsIgnoreCase("body")) {
|
||||
body = getIntent().getExtras().getString(key);
|
||||
} else if (key.equalsIgnoreCase("path")) {
|
||||
path = getIntent().getExtras().getString(key);
|
||||
} else if (key.equalsIgnoreCase("type")) {
|
||||
type = getIntent().getExtras().getString(key);
|
||||
}
|
||||
}
|
||||
|
||||
assert title != null;
|
||||
assert body != null;
|
||||
if (!title.equalsIgnoreCase("") && !body.equalsIgnoreCase("")) {
|
||||
db.open();
|
||||
long value = db.insertNotificationData(title, body, path, visitdate, type, counterId);
|
||||
if (value > 0) {
|
||||
Toast.makeText(context, "Notification Inserted", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(context, "Notification Not Inserted", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
if (!title.equals("")) {
|
||||
Intent in = new Intent(this, NotificationDetailActivity.class);
|
||||
in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
in.putExtra("Type", type);
|
||||
in.putExtra("Title", title);
|
||||
in.putExtra("Body", body);
|
||||
in.putExtra("Path", path);
|
||||
startActivity(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.lay_ba) {
|
||||
db.open();
|
||||
if (db.getBAListAllData(visitdate, counterId).size() > 0) {
|
||||
editor.putString(CommonString.TAG_FROM, CommonString.TAG_FROM_BA);
|
||||
editor.putString(CommonString.TAG_MODE, CommonString.MODE_FROM_BA_LOGIN);
|
||||
editor.putString(CommonString.KEY_USER_TYPE, CommonString.TAG_FROM_BA);
|
||||
editor.commit();
|
||||
|
||||
Intent balogin = new Intent(context, TabLoginActivity.class);
|
||||
balogin.putExtra(CommonString.TAG_FROM, CommonString.TAG_FROM_BA);
|
||||
balogin.putExtra(CommonString.TAG_MODE, CommonString.MODE_FROM_BA_LOGIN);
|
||||
startActivity(balogin);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
DownloadData(CommonString.TAG_FROM_BA);
|
||||
}
|
||||
|
||||
} else if (v.getId() == R.id.lay_ma) {
|
||||
db.open();
|
||||
if (db.getBAListAllData(visitdate, counterId).size() > 0) {
|
||||
editor.putString(CommonString.TAG_FROM, CommonString.TAG_FROM_ME);
|
||||
editor.putString(CommonString.TAG_MODE, CommonString.MODE_FROM_ME_LOGIN);
|
||||
editor.putString(CommonString.KEY_USER_TYPE, CommonString.TAG_FROM_ME);
|
||||
editor.commit();
|
||||
Intent malogin = new Intent(context, TabLoginActivity.class);
|
||||
malogin.putExtra(CommonString.TAG_FROM, CommonString.TAG_FROM_ME);
|
||||
malogin.putExtra(CommonString.TAG_MODE, CommonString.MODE_FROM_ME_LOGIN);
|
||||
startActivity(malogin);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
DownloadData(CommonString.TAG_FROM_ME);
|
||||
}
|
||||
|
||||
|
||||
} else if (v.getId() == R.id.lay_tba) {
|
||||
db.open();
|
||||
if (db.getBAListAllData(visitdate, counterId).size() > 0) {
|
||||
editor.putString(CommonString.TAG_FROM, CommonString.TAG_FROM_TBA);
|
||||
editor.putString(CommonString.TAG_MODE, CommonString.MODE_FROM_TBA_LOGIN);
|
||||
editor.putString(CommonString.KEY_USER_TYPE, CommonString.TAG_FROM_TBA);
|
||||
editor.commit();
|
||||
|
||||
Intent tbalogin = new Intent(context, TabLoginActivity.class);
|
||||
tbalogin.putExtra(CommonString.TAG_FROM, CommonString.TAG_FROM_TBA);
|
||||
tbalogin.putExtra(CommonString.TAG_MODE, CommonString.MODE_FROM_TBA_LOGIN);
|
||||
startActivity(tbalogin);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
|
||||
} else {
|
||||
DownloadData(CommonString.TAG_FROM_TBA);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void UploadDataTask() {
|
||||
try {
|
||||
ArrayList<String> keysList = new ArrayList<>();
|
||||
ArrayList<String> jsonList = new ArrayList<>();
|
||||
ArrayList<String> KeyNames = new ArrayList<>();
|
||||
keysList.add("Table_Structure");
|
||||
keysList.add("BA_List");
|
||||
keysList.add("Mapping_JourneyPlan");
|
||||
keysList.size();
|
||||
for (int i = 0; i < keysList.size(); i++) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("Downloadtype", keysList.get(i));
|
||||
jsonObject.put("Username", "");
|
||||
jsonObject.put("Param1", counterId);
|
||||
jsonObject.put("Param2", "");
|
||||
jsonList.add(jsonObject.toString());
|
||||
KeyNames.add(keysList.get(i));
|
||||
}
|
||||
if (jsonList.size() > 0) {
|
||||
ProgressDialog pd = new ProgressDialog(context);
|
||||
DownloadAllDatawithRetro downloadData = new DownloadAllDatawithRetro(context, db, pd, CommonString.TAG_FROM_CURRENT);
|
||||
downloadData.listSize = jsonList.size();
|
||||
downloadData.downloadDataUniversalBa(jsonList, KeyNames, downloadindex, CommonString.DOWNLOAD_ALL_SERVICE);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
db.open();
|
||||
allLoginListData = db.getlistAllData(visitdate, userId);
|
||||
checkAndRequestPermissions();
|
||||
try {
|
||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
String version = pInfo.versionName;
|
||||
versioncode_txt.setText("Version : " + version);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.fillInStackTrace();
|
||||
versioncode_txt.setText("Version : 0.0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean checkAndRequestPermissions() {
|
||||
int CAMERA = ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA);
|
||||
int ACCESS_NETWORK_STATE = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_NETWORK_STATE);
|
||||
int ACCESS_COARSE_LOCATION = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
int locationPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
int READ_PHONE_STATE = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
|
||||
List<String> listPermissionsNeeded = new ArrayList<>();
|
||||
|
||||
if (CAMERA != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.CAMERA);
|
||||
}
|
||||
|
||||
if (ACCESS_NETWORK_STATE != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_NETWORK_STATE);
|
||||
}
|
||||
if (ACCESS_COARSE_LOCATION != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
if (locationPermission != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
|
||||
if (READ_PHONE_STATE != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
|
||||
}
|
||||
|
||||
|
||||
if (!listPermissionsNeeded.isEmpty()) {
|
||||
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), CommonString.PERMISSION_ALL);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showDialogOK(String message, DialogInterface.OnClickListener okListener) {
|
||||
new AlertDialog.Builder(this).setMessage(message).setPositiveButton("OK", okListener).setNegativeButton("Cancel", okListener).create().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
//test("", "Permission callback called-------");
|
||||
switch (requestCode) {
|
||||
case CommonString.PERMISSION_ALL: {
|
||||
Map<String, Integer> perms = new HashMap<>();
|
||||
// Initialize the map with both permissions
|
||||
perms.put(Manifest.permission.CAMERA, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.ACCESS_NETWORK_STATE, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.ACCESS_COARSE_LOCATION, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.ACCESS_FINE_LOCATION, PackageManager.PERMISSION_GRANTED);
|
||||
perms.put(Manifest.permission.READ_PHONE_STATE, PackageManager.PERMISSION_GRANTED);
|
||||
// Fill with actual results from user
|
||||
if (grantResults.length > 0) {
|
||||
for (int i = 0; i < permissions.length; i++)
|
||||
perms.put(permissions[i], grantResults[i]);
|
||||
// Check for both permissions
|
||||
boolean allPermissionsGranted =
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.CAMERA)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.ACCESS_NETWORK_STATE)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.ACCESS_COARSE_LOCATION)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.ACCESS_FINE_LOCATION)) &&
|
||||
Integer.valueOf(PackageManager.PERMISSION_GRANTED).equals(perms.get(Manifest.permission.READ_PHONE_STATE));
|
||||
if (allPermissionsGranted) {
|
||||
|
||||
}
|
||||
} else {
|
||||
//test("", "Some permissions are not granted ask again ");
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_NETWORK_STATE) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
|
||||
showDialogOK("Location,File,Call and Camera Services Permission required for this app", (dialog, which) -> {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
checkAndRequestPermissions();
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
// proceed with logic by disabling the related features or quit the app.
|
||||
Intent startMain = new Intent(Intent.ACTION_MAIN);
|
||||
startMain.addCategory(Intent.CATEGORY_HOME);
|
||||
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(startMain);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
//permission is denied (and never ask again is checked)
|
||||
//shouldShowRequestPermissionRationale will return false
|
||||
else {
|
||||
Toast.makeText(this, "Go to settings and enable permissions", Toast.LENGTH_LONG).show();
|
||||
// //proceed with logic by disabling the related features or quit the app.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DownloadData(String userType) {
|
||||
try {
|
||||
if (CommonFunctions.checkNetIsAvailable(context)) {
|
||||
ArrayList<String> keysList = new ArrayList<>();
|
||||
ArrayList<String> jsonList = new ArrayList<>();
|
||||
ArrayList<String> KeyNames = new ArrayList<>();
|
||||
keysList.add("Table_Structure");
|
||||
keysList.add("BA_List");
|
||||
keysList.add("Mapping_JourneyPlan");
|
||||
keysList.size();
|
||||
for (int i = 0; i < keysList.size(); i++) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("Downloadtype", keysList.get(i));
|
||||
jsonObject.put("Username", "");
|
||||
jsonObject.put("Param1", counterId);
|
||||
jsonObject.put("Param2", "");
|
||||
jsonList.add(jsonObject.toString());
|
||||
KeyNames.add(keysList.get(i));
|
||||
}
|
||||
|
||||
if (jsonList.size() > 0) {
|
||||
loading = ProgressDialog.show(context, "Downloading", "Please wait...", false, true);
|
||||
downloadBaList(context, jsonList, KeyNames, downloadindex, userType, loading);
|
||||
}
|
||||
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, getString(R.string.nonetwork));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void downloadBaList(final Context context, final ArrayList<String> jsonStringList, final ArrayList<String> KeyNames, int downloadindex, final String userType, final ProgressDialog loading) {
|
||||
final String[] data_global = {""};
|
||||
String jsonString = "", KeyName = "";
|
||||
int jsonIndex = 0;
|
||||
if (jsonStringList.size() > 0) {
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).writeTimeout(CommonString.TIMEOUT,
|
||||
TimeUnit.SECONDS).connectTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).build();
|
||||
jsonString = jsonStringList.get(downloadindex);
|
||||
KeyName = KeyNames.get(downloadindex);
|
||||
jsonIndex = downloadindex;
|
||||
|
||||
RequestBody jsonData = RequestBody.create(MediaType.parse("application/json"), jsonString);
|
||||
Retrofit adapter = new Retrofit.Builder().baseUrl(CommonString.URL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create()).build();
|
||||
PostApi api = adapter.create(PostApi.class);
|
||||
Call<String> call = api.getDownloadAll(jsonData);
|
||||
final int[] finalJsonIndex = {jsonIndex};
|
||||
final String finalKeyName = KeyName;
|
||||
|
||||
call.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
String responseBody = response.body();
|
||||
String data = null;
|
||||
if (responseBody != null && response.isSuccessful()) {
|
||||
try {
|
||||
data = response.body();
|
||||
if (data.equals("")) {
|
||||
data_global[0] = "";
|
||||
} else {
|
||||
data_global[0] = data;
|
||||
if (finalKeyName.equalsIgnoreCase("Table_Structure")) {
|
||||
TableStructureGetterSetter tableStructureObj = new Gson().fromJson(data, TableStructureGetterSetter.class);
|
||||
String isAllTableCreated = createTable(tableStructureObj);
|
||||
|
||||
if (isAllTableCreated != CommonString.KEY_SUCCESS) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
|
||||
AlertandMessages.showAlert((Activity) context, isAllTableCreated + " not created", true);
|
||||
}
|
||||
} else {
|
||||
switch (finalKeyName) {
|
||||
case "BA_List":
|
||||
if (!data.contains("No Data")) {
|
||||
JCPGetterSetter baListObject = new Gson().fromJson(data, JCPGetterSetter.class);
|
||||
if (baListObject != null && !db.insertBalistData(baListObject)) {
|
||||
AlertandMessages.showToastMsg(context, "Ba List data not saved");
|
||||
}
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "Mapping_JourneyPlan":
|
||||
if (!data.contains("No Data")) {
|
||||
JCPGetterSetter jcpObject = new Gson().fromJson(data, JCPGetterSetter.class);
|
||||
if (jcpObject != null && !db.insertJCPData(jcpObject)) {
|
||||
AlertandMessages.showToastMsg(context, "JCP data not saved");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
finalJsonIndex[0]++;
|
||||
if (finalJsonIndex[0] != KeyNames.size()) {
|
||||
downloadBaList(context, jsonStringList, KeyNames, finalJsonIndex[0], userType, loading);
|
||||
} else {
|
||||
loading.dismiss();
|
||||
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
|
||||
AlertandMessages.showToastMsg(context, "BA List data downloaded Successfully");
|
||||
|
||||
if (userType.equalsIgnoreCase(CommonString.TAG_FROM_BA)) {
|
||||
editor.putString(CommonString.TAG_FROM, CommonString.TAG_FROM_BA);
|
||||
editor.putString(CommonString.TAG_MODE, CommonString.MODE_FROM_BA_LOGIN);
|
||||
editor.putString(CommonString.KEY_USER_TYPE, CommonString.TAG_FROM_BA);
|
||||
editor.commit();
|
||||
|
||||
Intent balogin = new Intent(context, TabLoginActivity.class);
|
||||
balogin.putExtra(CommonString.TAG_FROM, CommonString.TAG_FROM_BA);
|
||||
balogin.putExtra(CommonString.TAG_MODE, CommonString.MODE_FROM_BA_LOGIN);
|
||||
startActivity(balogin);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (userType.equalsIgnoreCase(CommonString.TAG_FROM_ME)) {
|
||||
|
||||
editor.putString(CommonString.TAG_FROM, CommonString.TAG_FROM_ME);
|
||||
editor.putString(CommonString.TAG_MODE, CommonString.MODE_FROM_ME_LOGIN);
|
||||
editor.putString(CommonString.KEY_USER_TYPE, CommonString.TAG_FROM_ME);
|
||||
editor.commit();
|
||||
|
||||
Intent malogin = new Intent(context, TabLoginActivity.class);
|
||||
malogin.putExtra(CommonString.TAG_FROM, CommonString.TAG_FROM_ME);
|
||||
malogin.putExtra(CommonString.TAG_MODE, CommonString.MODE_FROM_ME_LOGIN);
|
||||
startActivity(malogin);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (userType.equalsIgnoreCase(CommonString.TAG_FROM_TBA)) {
|
||||
|
||||
editor.putString(CommonString.TAG_FROM, CommonString.TAG_FROM_TBA);
|
||||
editor.putString(CommonString.TAG_MODE, CommonString.MODE_FROM_TBA_LOGIN);
|
||||
editor.putString(CommonString.KEY_USER_TYPE, CommonString.TAG_FROM_TBA);
|
||||
editor.commit();
|
||||
|
||||
Intent tbalogin = new Intent(context, TabLoginActivity.class);
|
||||
tbalogin.putExtra(CommonString.TAG_FROM, CommonString.TAG_FROM_TBA);
|
||||
tbalogin.putExtra(CommonString.TAG_MODE, CommonString.MODE_FROM_TBA_LOGIN);
|
||||
startActivity(tbalogin);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
loading.dismiss();
|
||||
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
|
||||
AlertandMessages.showToastMsg(context, "Ba List Data Not Found. Please Contact To Supervisor");
|
||||
|
||||
}
|
||||
} else {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
AlertandMessages.showAlertlogin((Activity) context, CommonString.MESSAGE_NO_RESPONSE_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
loading.dismiss();
|
||||
if (loading != null && loading.isShowing()) {
|
||||
loading.dismiss();
|
||||
}
|
||||
|
||||
AlertandMessages.showAlertlogin((Activity) context, CommonString.MESSAGE_SOCKETEXCEPTION);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String createTable(TableStructureGetterSetter tableGetSet) {
|
||||
List<TableStructure> tableList = tableGetSet.getTableStructure();
|
||||
for (int i = 0; i < tableList.size(); i++) {
|
||||
String table = tableList.get(i).getSqlText();
|
||||
if (db.createtable(table) == 0) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
return CommonString.KEY_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.leaves.TLeaveRequestDetail;
|
||||
import java.util.List;
|
||||
|
||||
public class ApprovedLeaveAdapter extends RecyclerView.Adapter<ApprovedLeaveAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
String type;
|
||||
List<TLeaveRequestDetail> data;
|
||||
|
||||
public ApprovedLeaveAdapter(Context context, String type, List<TLeaveRequestDetail> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(type.equals("GovtHolidays") ? R.layout.item_gov_holidays : R.layout.item_approved_leaves, parent, false);
|
||||
return new MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint({"NotifyDataSetChanged", "SetTextI18n"})
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
|
||||
final TLeaveRequestDetail current = data.get(position);
|
||||
if (type.equals("GovtHolidays")) {
|
||||
holder.titleTV.setText(current.getLeaveType());
|
||||
holder.descTV.setText(current.getReason());
|
||||
} else {
|
||||
String day = current.getDay().toString().length() == 1 ? "0" + current.getDay().toString() : current.getDay().toString();
|
||||
String month = current.getMonth().toString().length() == 1 ? "0" + current.getMonth().toString() : current.getMonth().toString();
|
||||
holder.dateTV.setText(CommonFunctions.formatDate(month + "/" + day + "/" + current.getYear().toString()));
|
||||
|
||||
|
||||
if (!current.getApprovedStatus().isEmpty() && current.getApprovedStatus().equalsIgnoreCase("Pending")) {
|
||||
holder.pendingCardView.setVisibility(View.VISIBLE);
|
||||
holder.rejectCardView.setVisibility(View.GONE);
|
||||
holder.approveCardView.setVisibility(View.GONE);
|
||||
} else if (!current.getApprovedStatus().isEmpty() && current.getApprovedStatus().equalsIgnoreCase("Reject")) {
|
||||
holder.pendingCardView.setVisibility(View.GONE);
|
||||
holder.rejectCardView.setVisibility(View.VISIBLE);
|
||||
holder.approveCardView.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.pendingCardView.setVisibility(View.GONE);
|
||||
holder.rejectCardView.setVisibility(View.GONE);
|
||||
holder.approveCardView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
holder.titleTV.setText(current.getLeaveSubType() != null && !current.getLeaveSubType().isEmpty() ? current.getLeaveType() + " - " + current.getLeaveSubType() : current.getLeaveType());
|
||||
holder.descTV.setText(current.getReason());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
LinearLayoutCompat rlParent;
|
||||
TextView dateTV, titleTV, descTV;
|
||||
CardView approveCardView, pendingCardView, rejectCardView;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
rlParent = (LinearLayoutCompat) itemView.findViewById(R.id.rlParent);
|
||||
dateTV = (TextView) itemView.findViewById(R.id.dateTV);
|
||||
titleTV = (TextView) itemView.findViewById(R.id.titleTV);
|
||||
descTV = (TextView) itemView.findViewById(R.id.descTV);
|
||||
approveCardView = (CardView) itemView.findViewById(R.id.approveCardView);
|
||||
pendingCardView = (CardView) itemView.findViewById(R.id.pendingCardView);
|
||||
rejectCardView = (CardView) itemView.findViewById(R.id.rejectCardView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterInvoiceType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class InvoiceTypeSpinnerAdapter extends ArrayAdapter<MasterInvoiceType> {
|
||||
List<MasterInvoiceType> list;
|
||||
Context context;
|
||||
int resourceId;
|
||||
|
||||
public InvoiceTypeSpinnerAdapter(Context context, int resourceId, ArrayList<MasterInvoiceType> list) {
|
||||
super(context, resourceId, list);
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@SuppressLint("ViewHolder")
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View view = convertView;
|
||||
LayoutInflater inflater =(LayoutInflater.from(context));
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
MasterInvoiceType cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.txt_sp_text);
|
||||
txt_spinner.setText(list.get(position).getInvoiceType());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = (LayoutInflater.from(context));
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
MasterInvoiceType cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.txt_sp_text);
|
||||
txt_spinner.setText(cm.getInvoiceType());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.inwordDetail.ReportCounterInwardStockDetail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InwardStkDetailAdapter extends RecyclerView.Adapter<InwardStkDetailAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
List<ReportCounterInwardStockDetail> data;
|
||||
|
||||
public InwardStkDetailAdapter(Context context, List<ReportCounterInwardStockDetail> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.row_counter_inward_details, parent, false);
|
||||
return new MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint({"SetTextI18n", "DefaultLocale"})
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
|
||||
final ReportCounterInwardStockDetail current = data.get(position);
|
||||
setText(holder.tvParamCode, position, current.getParamCode(), inflator.getContext());
|
||||
setText(holder.tvParamName, position, current.getParamName(), inflator.getContext());
|
||||
|
||||
setText(holder.tvInvoiceQty, position, current.getInvoiceQty() != null ? current.getInvoiceQty().toString() : "0", inflator.getContext());
|
||||
setText(holder.tvActualQty, position, current.getActualQty() != null ? current.getActualQty().toString() : "0", inflator.getContext());
|
||||
setText(holder.tvDamageQty, position, current.getDamageQty() != null ? current.getDamageQty().toString() : "0", inflator.getContext());
|
||||
setText(holder.tvMissedQty, position, current.getMissedQty() != null ? current.getMissedQty().toString() : "0", inflator.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvInvoiceQty, tvActualQty, tvDamageQty,tvMissedQty, tvParamCode, tvParamName;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvMissedQty = (TextView) itemView.findViewById(R.id.tvMissedQty);
|
||||
tvInvoiceQty = (TextView) itemView.findViewById(R.id.tvInvoiceQty);
|
||||
tvActualQty = (TextView) itemView.findViewById(R.id.tvActualQty);
|
||||
tvDamageQty = (TextView) itemView.findViewById(R.id.tvDamageQty);
|
||||
tvParamCode = (TextView) itemView.findViewById(R.id.tvParamCode);
|
||||
tvParamName = (TextView) itemView.findViewById(R.id.tvParamName);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
private void setText(TextView tv, int pos, String value, Context context) {
|
||||
tv.setTextColor(ContextCompat.getColor(context, R.color.black));
|
||||
tv.setText(value);
|
||||
tv.setId(pos);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.tbaleavemodel.TBAMELeaveHistory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LeaveDetailAdapter extends RecyclerView.Adapter<LeaveDetailAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
List<TBAMELeaveHistory> data;
|
||||
|
||||
public LeaveDetailAdapter(Context context, List<TBAMELeaveHistory> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.item_leave_details, parent, false);
|
||||
return new MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint({"NotifyDataSetChanged", "SetTextI18n"})
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
|
||||
final TBAMELeaveHistory current = data.get(position);
|
||||
if (position % 2 == 0) {
|
||||
holder.rlLeaveDetail.setBackgroundColor(ContextCompat.getColor(inflator.getContext(), R.color.white));
|
||||
} else {
|
||||
holder.rlLeaveDetail.setBackgroundColor(ContextCompat.getColor(inflator.getContext(), R.color.gray));
|
||||
}
|
||||
if (CommonFunctions.isTablet(inflator.getContext())) {
|
||||
holder.tvDatefromTo.setText(current.getFromDate() + " - " + current.getToDate());
|
||||
} else {
|
||||
holder.tvDatefromTo.setText(current.getFromDate() + "\n" + current.getToDate());
|
||||
}
|
||||
|
||||
holder.tvDatefromTo.setId(position);
|
||||
holder.tvLeaveType.setText(current.getLeaveType());
|
||||
holder.tvLeaveType.setId(position);
|
||||
holder.tvNoOfDays.setText(current.getNoOfDays() != null ? current.getNoOfDays().toString() : "0");
|
||||
holder.tvNoOfDays.setId(position);
|
||||
holder.tvStatus.setText(current.getApprovedStatus());
|
||||
holder.tvStatus.setId(position);
|
||||
holder.tvRemark.setText(current.getRejectRemark());
|
||||
holder.tvRemark.setId(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
LinearLayout rlLeaveDetail;
|
||||
TextView tvDatefromTo, tvLeaveType, tvNoOfDays, tvStatus, tvRemark;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
rlLeaveDetail = (LinearLayout) itemView.findViewById(R.id.rlLeaveDetail);
|
||||
tvDatefromTo = (TextView) itemView.findViewById(R.id.tvDatefromTo);
|
||||
tvLeaveType = (TextView) itemView.findViewById(R.id.tvLeaveType);
|
||||
tvNoOfDays = (TextView) itemView.findViewById(R.id.tvNoOfDays);
|
||||
tvStatus = (TextView) itemView.findViewById(R.id.tvStatus);
|
||||
tvRemark = (TextView) itemView.findViewById(R.id.tvRemark);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterPromoOffer;
|
||||
import com.cpm.lorealbaautomation.promooffer.PromoOfferDetailsActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MyPager extends PagerAdapter {
|
||||
Context context;
|
||||
ArrayList<MasterPromoOffer> list;
|
||||
|
||||
public MyPager(Context context, ArrayList<MasterPromoOffer> list) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
/*
|
||||
This callback is responsible for creating a page. We inflate the layout and set the drawable
|
||||
to the ImageView based on the position. In the end we add the inflated layout to the parent
|
||||
container .This method returns an object key to identify the page view, but in this example page view
|
||||
itself acts as the object key
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.linear_layout, null);
|
||||
ImageView imageView = view.findViewById(R.id.image);
|
||||
final MasterPromoOffer object = list.get(position);
|
||||
|
||||
if (object.getPromoId()!=null && !object.getPromoId().isEmpty() && object.getPromoId().equalsIgnoreCase("No Data")){
|
||||
imageView.setImageResource(R.mipmap.no_promo_banner);
|
||||
}else {
|
||||
if (isTablet(context)) {
|
||||
String path = CommonString.getPromosFolder(context) + object.getPromoOfferTab();
|
||||
File dir = new File(path);
|
||||
if (dir.exists()) {
|
||||
Bitmap myBitmap = BitmapFactory.decodeFile(dir.getAbsolutePath());
|
||||
imageView.setImageBitmap(myBitmap);
|
||||
}
|
||||
} else {
|
||||
String path = CommonString.getPromosFolder(context) + object.getPromoOfferMobile();
|
||||
File dir = new File(path);
|
||||
if (dir.exists()) {
|
||||
Bitmap myBitmap = BitmapFactory.decodeFile(dir.getAbsolutePath());
|
||||
imageView.setImageBitmap(myBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
imageView.setOnClickListener(view1 -> context.startActivity(new Intent(context, PromoOfferDetailsActivity.class)
|
||||
.putExtra(CommonString.KEY_PROMO_ID,object.getPromoId())));
|
||||
}
|
||||
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
/*
|
||||
This callback is responsible for destroying a page. Since we are using view only as the
|
||||
object key we just directly remove the view from parent container
|
||||
*/
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, @NonNull Object view) {
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the count of the total pages
|
||||
*/
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/*
|
||||
Used to determine whether the page view is associated with object key returned by instantiateItem.
|
||||
Since here view only is the key we return view==object
|
||||
*/
|
||||
@Override
|
||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||
return object == view;
|
||||
}
|
||||
|
||||
public boolean isTablet(Context context) {
|
||||
boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
|
||||
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
|
||||
return (xlarge || large);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterNonStockReason;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ReasonSpinnerAdapter extends ArrayAdapter<MasterNonStockReason> {
|
||||
List<MasterNonStockReason> list;
|
||||
Context context;
|
||||
int resourceId;
|
||||
|
||||
public ReasonSpinnerAdapter(Context context, int resourceId, ArrayList<MasterNonStockReason> list) {
|
||||
super(context, resourceId, list);
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@SuppressLint("ViewHolder")
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = (LayoutInflater.from(context));
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
MasterNonStockReason cm = null;
|
||||
if (position < list.size()) cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.txt_sp_text);
|
||||
if (cm != null && cm.getReason() != null) {
|
||||
txt_spinner.setText(cm.getReason());
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = (LayoutInflater.from(context));
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
MasterNonStockReason cm = null;
|
||||
if (position < list.size()) cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.txt_sp_text);
|
||||
if (cm != null && cm.getReason() != null) {
|
||||
txt_spinner.setText(cm.getReason());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.ProductMaster;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubAxeValueAdapter extends RecyclerView.Adapter<SubAxeValueAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
List<ProductMaster> masterList;
|
||||
private String selectedSubAxe;
|
||||
boolean disable, network_check;
|
||||
Onclick onclick;
|
||||
|
||||
public SubAxeValueAdapter(Context context, List<ProductMaster> data, String selectedSubAxe, boolean disable, boolean network_check, Onclick onclick) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.selectedSubAxe = selectedSubAxe;
|
||||
this.network_check = network_check;
|
||||
this.onclick = onclick;
|
||||
this.masterList = data;
|
||||
this.disable = disable;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.item_filter, parent, false);
|
||||
return new MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint({"NotifyDataSetChanged"})
|
||||
@Override
|
||||
public void onBindViewHolder(final MyViewHolder holder, final int position) {
|
||||
final ProductMaster current = masterList.get(position);
|
||||
holder.tv_item.setText(current.getSubAxeName());
|
||||
holder.tv_item.setId(position);
|
||||
|
||||
if (!disable) {
|
||||
holder.tv_item.setOnClickListener(v -> {
|
||||
if (network_check && !CommonFunctions.checkNetIsAvailable(inflator.getContext())) {
|
||||
AlertandMessages.showToastMsg(inflator.getContext(), inflator.getContext().getString(R.string.nonetwork));
|
||||
return;
|
||||
}
|
||||
String placeHolder = "Axe Name";
|
||||
selectedSubAxe = current.getSubAxeName();
|
||||
switch (current.getSubAxeName()) {
|
||||
case "Product":
|
||||
placeHolder = "Product Name";
|
||||
break;
|
||||
case "Axe":
|
||||
placeHolder = "Axe Name";
|
||||
break;
|
||||
case "Sub Axe":
|
||||
placeHolder = "Sub Axe Name";
|
||||
break;
|
||||
case "Signature":
|
||||
placeHolder = "Signature Name";
|
||||
break;
|
||||
case "Sub Brand":
|
||||
placeHolder = "Sub Brand Name";
|
||||
break;
|
||||
case "Brand":
|
||||
placeHolder = "Brand Name";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
onclick.onClick(current.getSubAxeName(), placeHolder);
|
||||
current.setSelected(true);
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
if (!disable) {
|
||||
holder.tv_item.setTextColor(inflator.getContext().getResources().getColor(R.color.white));
|
||||
holder.tv_item.setId(position);
|
||||
if (current.getSubAxeName().equalsIgnoreCase(selectedSubAxe)) {
|
||||
holder.card.setCardBackgroundColor(inflator.getContext().getResources().getColor(R.color.dashboard_ach));
|
||||
holder.card.setId(position);
|
||||
} else {
|
||||
holder.card.setCardBackgroundColor(inflator.getContext().getResources().getColor(R.color.grey_dark_background));
|
||||
holder.card.setId(position);
|
||||
}
|
||||
} else {
|
||||
holder.card.setCardBackgroundColor(inflator.getContext().getResources().getColor(R.color.circular_progress_default_background));
|
||||
holder.card.setId(position);
|
||||
|
||||
holder.tv_item.setTextColor(inflator.getContext().getResources().getColor(R.color.disable_txt_color));
|
||||
holder.tv_item.setId(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return masterList.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tv_item;
|
||||
CardView card;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tv_item = (TextView) itemView.findViewById(R.id.tv_item);
|
||||
card = (CardView) itemView.findViewById(R.id.item_card);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface Onclick {
|
||||
void onClick(String filterText, String placeHolder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.cpm.lorealbaautomation.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.countervolune.ReportCounterVolumeDetail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VolumeDetailAdapter extends RecyclerView.Adapter<VolumeDetailAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
List<ReportCounterVolumeDetail> data;
|
||||
|
||||
public VolumeDetailAdapter(Context context, List<ReportCounterVolumeDetail> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.row_counter_volume, parent, false);
|
||||
return new MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint({"SetTextI18n", "DefaultLocale"})
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
|
||||
final ReportCounterVolumeDetail current = data.get(position);
|
||||
setText(holder.tvParamCode, position, current.getParamCode(), inflator.getContext());
|
||||
setText(holder.tvParamName, position, current.getParamName(), inflator.getContext());
|
||||
setText(holder.tvRMTDVolume, position, current.getMTDVolume() != null ? current.getMTDVolume().toString() : "0", inflator.getContext());
|
||||
setText(holder.tvAvgPerDayVolume, position, current.getAvgPerDayVolume() != null ? current.getAvgPerDayVolume().toString() : "0", inflator.getContext());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvAvgPerDayVolume, tvRMTDVolume, tvParamCode, tvParamName;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvAvgPerDayVolume = (TextView) itemView.findViewById(R.id.tvAvgPerDayVolume);
|
||||
tvRMTDVolume = (TextView) itemView.findViewById(R.id.tvRMTDVolume);
|
||||
tvParamCode = (TextView) itemView.findViewById(R.id.tvParamCode);
|
||||
tvParamName = (TextView) itemView.findViewById(R.id.tvParamName);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
private void setText(TextView tv, int pos, String value, Context context) {
|
||||
tv.setTextColor(ContextCompat.getColor(context, R.color.black));
|
||||
tv.setText(value);
|
||||
tv.setId(pos);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.cpm.lorealbaautomation.autoconnectblutooth;
|
||||
import android.bluetooth.BluetoothA2dp;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
|
||||
public class BluetoothA2DPRequester implements BluetoothProfile.ServiceListener {
|
||||
Callback mCallback;
|
||||
|
||||
/**
|
||||
* Creates a new instance of an A2DP Proxy requester with the
|
||||
* callback that should receive the proxy once it is acquired
|
||||
* @param callback the callback that should receive the proxy
|
||||
*/
|
||||
public BluetoothA2DPRequester(Callback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start an asynchronous request to acquire the A2DP proxy. The callback
|
||||
* will be notified when the proxy is acquired
|
||||
* @param c the context used to obtain the proxy
|
||||
* @param adapter the BluetoothAdapter that should receive the request for proxy
|
||||
*/
|
||||
public void request (Context c, BluetoothAdapter adapter) {
|
||||
adapter.getProfileProxy(c, this, BluetoothProfile.A2DP);
|
||||
}
|
||||
@Override
|
||||
public void onServiceConnected(int i, BluetoothProfile bluetoothProfile) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onA2DPProxyReceived((BluetoothA2dp) bluetoothProfile);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onServiceDisconnected(int i) {
|
||||
//It's a one-off connection attempt; we don't care about the disconnection event.
|
||||
}
|
||||
public static interface Callback {
|
||||
public void onA2DPProxyReceived (BluetoothA2dp proxy);
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package com.cpm.lorealbaautomation.autoconnectblutooth;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.bluetooth.BluetoothA2dp;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class BluetoothActivity extends Activity implements BluetoothBroadcastReceiver.Callback, BluetoothA2DPRequester.Callback {
|
||||
private static final String TAG = "BluetoothActivity";
|
||||
|
||||
/**
|
||||
* This is the name of the device to connect to. You can replace this with the name of
|
||||
* your device.
|
||||
*/
|
||||
private static final String HTC_MEDIA = "HTC Car A100 V2.4B";
|
||||
|
||||
/**
|
||||
* Local reference to the device's BluetoothAdapter
|
||||
*/
|
||||
private BluetoothAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Store a local reference to the BluetoothAdapter
|
||||
mAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
//Already connected, skip the rest
|
||||
if (mAdapter.isEnabled()) {
|
||||
onBluetoothConnected();
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if we're allowed to enable Bluetooth. If so, listen for a
|
||||
//successful enabling
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
if (mAdapter.enable()) {
|
||||
BluetoothBroadcastReceiver.register(this, this);
|
||||
} else {
|
||||
//test(TAG, "Unable to enable Bluetooth. Is Airplane Mode enabled?");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBluetoothError() {
|
||||
//test(TAG, "There was an error enabling the Bluetooth Adapter.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBluetoothConnected() {
|
||||
new BluetoothA2DPRequester(this).request(this, mAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onA2DPProxyReceived(BluetoothA2dp proxy) {
|
||||
Method connect = getConnectMethod();
|
||||
BluetoothDevice device = findBondedDeviceByName(mAdapter, HTC_MEDIA);
|
||||
|
||||
//If either is null, just return. The errors have already been logged
|
||||
if (connect == null || device == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
connect.setAccessible(true);
|
||||
connect.invoke(proxy, device);
|
||||
} catch (InvocationTargetException ex) {
|
||||
//test(TAG, "Unable to invoke connect(BluetoothDevice) method on proxy. " + ex.toString());
|
||||
} catch (IllegalAccessException ex) {
|
||||
//test(TAG, "Illegal Access! " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around some reflection code to get the hidden 'connect()' method
|
||||
*
|
||||
* @return the connect(BluetoothDevice) method, or null if it could not be found
|
||||
*/
|
||||
@SuppressLint("DiscouragedPrivateApi")
|
||||
private Method getConnectMethod() {
|
||||
try {
|
||||
return BluetoothA2dp.class.getDeclaredMethod("connect", BluetoothDevice.class);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
//test(TAG, "Unable to find connect(BluetoothDevice) method in BluetoothA2dp proxy.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the set of bonded devices in the BluetoothAdapter for one that matches
|
||||
* the given name
|
||||
*
|
||||
* @param adapter the BluetoothAdapter whose bonded devices should be queried
|
||||
* @param name the name of the device to search for
|
||||
* @return the BluetoothDevice by the given name (if found); null if it was not found
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
private static BluetoothDevice findBondedDeviceByName(BluetoothAdapter adapter, String name) {
|
||||
for (BluetoothDevice device : getBondedDevices(adapter)) {
|
||||
if (name.matches(device.getName())) {
|
||||
Log.v(TAG, String.format("Found device with name %s and address %s.", device.getName(), device.getAddress()));
|
||||
return device;
|
||||
}
|
||||
}
|
||||
Log.w(TAG, String.format("Unable to find device with name %s.", name));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safety wrapper around BluetoothAdapter#getBondedDevices() that is guaranteed
|
||||
* to return a non-null result
|
||||
*
|
||||
* @param adapter the BluetoothAdapter whose bonded devices should be obtained
|
||||
* @return the set of all bonded devices to the adapter; an empty set if there was an error
|
||||
*/
|
||||
private static Set<BluetoothDevice> getBondedDevices(BluetoothAdapter adapter) {
|
||||
@SuppressLint("MissingPermission")
|
||||
Set<BluetoothDevice> results = adapter.getBondedDevices();
|
||||
if (results == null) {
|
||||
results = new HashSet<>();
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package com.cpm.lorealbaautomation.autoconnectblutooth;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
public class BluetoothBroadcastReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "BluetoothBroadcastReceiver";
|
||||
|
||||
private Callback mCallback;
|
||||
|
||||
private BluetoothBroadcastReceiver (Callback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to register a new instance of this receiver with the
|
||||
* necessary IntentFilter, which will notify the callback upon a successful
|
||||
* connection or error case.
|
||||
* @param callback the callback that should be notified on success or failure
|
||||
* of Bluetooth being enabled
|
||||
* @param c the context from which to register the receiver
|
||||
*/
|
||||
|
||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
||||
public static void register (Callback callback, Context c) {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2){
|
||||
c.registerReceiver(new BluetoothBroadcastReceiver(callback), getFilter());
|
||||
}else {
|
||||
c.registerReceiver(new BluetoothBroadcastReceiver(callback), getFilter(), Context.RECEIVER_NOT_EXPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
private static IntentFilter getFilter () {
|
||||
return new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
@Override
|
||||
public void onReceive (Context context, Intent intent) {
|
||||
if (!BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
|
||||
Log.v(TAG, "Received irrelevant broadcast. Disregarding.");
|
||||
return;
|
||||
}
|
||||
|
||||
//This is a State Change event, get the state extra, falling back to ERROR
|
||||
//if it isn't there (which shouldn't happen)
|
||||
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
||||
|
||||
switch (state) {
|
||||
case BluetoothAdapter.STATE_CONNECTED:
|
||||
safeUnregisterReceiver(context, this);
|
||||
fireOnBluetoothConnected();
|
||||
break;
|
||||
case BluetoothAdapter.ERROR:
|
||||
safeUnregisterReceiver(context, this);
|
||||
fireOnBluetoothError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to do a checked unregistration of a broadcast receiver. Occasionally
|
||||
* you can get into a state where the receiver was already unregistered, throwing an
|
||||
* IllegalArgumentException. This method just swallows that exception and logs the error.
|
||||
* @param c the context from which to unregister the receiver
|
||||
* @param receiver the receiver that should be unregistered if it is not already unregistered
|
||||
*/
|
||||
private static void safeUnregisterReceiver (Context c, BroadcastReceiver receiver) {
|
||||
try {
|
||||
c.unregisterReceiver(receiver);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Log.w(TAG, "Tried to unregister BluetoothBroadcastReceiver that was not registered.");
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnBluetoothConnected () {
|
||||
if (mCallback != null) {
|
||||
mCallback.onBluetoothConnected();
|
||||
}
|
||||
}
|
||||
|
||||
private void fireOnBluetoothError () {
|
||||
if (mCallback != null) {
|
||||
mCallback.onBluetoothError();
|
||||
}
|
||||
}
|
||||
|
||||
public static interface Callback {
|
||||
public void onBluetoothConnected();
|
||||
public void onBluetoothError();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/16.
|
||||
*/
|
||||
|
||||
public class BigButtonView extends FrameLayout {
|
||||
|
||||
private FrameLayout frameLayout;
|
||||
private View clickEffect;
|
||||
private TextView text;
|
||||
private TextView subText;
|
||||
private String textString = "";
|
||||
private String subTextString = "";
|
||||
private ObjectAnimator clickEffectAnimator;
|
||||
private int duration = 500;
|
||||
private OnPressListener onPressListener;
|
||||
|
||||
public BigButtonView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BigButtonView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.big_button_view, this, true);
|
||||
|
||||
Resources resources = getResources();
|
||||
|
||||
frameLayout = (FrameLayout)findViewById(R.id.frame_layout);
|
||||
|
||||
text = (TextView)findViewById(R.id.text);
|
||||
text.setText(textString);
|
||||
text.setTextColor(ContextCompat.getColor(context, R.color.default_big_button_text_color));
|
||||
text.setTextSize(resources.getInteger(R.integer.default_big_button_text_size));
|
||||
|
||||
subText = (TextView)findViewById(R.id.sub_text);
|
||||
subText.setText(subTextString);
|
||||
subText.setTextColor(ContextCompat.getColor(context, R.color.default_big_button_sub_text_color));
|
||||
subText.setTextSize(resources.getInteger(R.integer.default_big_button_sub_text_size));
|
||||
|
||||
clickEffect = findViewById(R.id.click_effect);
|
||||
clickEffect.setAlpha(0);
|
||||
clickEffectAnimator = ObjectAnimator.ofFloat(clickEffect, "alpha", 1f, 0f);
|
||||
clickEffectAnimator.setDuration(duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the listener, for returning what happened to BlurLockView.
|
||||
*
|
||||
* @param onPressListener OnPressListener.
|
||||
*/
|
||||
public void setOnPressListener(OnPressListener onPressListener) {
|
||||
this.onPressListener = onPressListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of the button.
|
||||
*
|
||||
* @param width Width, in pixels.
|
||||
*/
|
||||
public void setWidth(int width) {
|
||||
ViewGroup.LayoutParams layoutParams = frameLayout.getLayoutParams();
|
||||
layoutParams.width = width;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the button.
|
||||
*
|
||||
* @param height Height, in pixels.
|
||||
*/
|
||||
public void setHeight(int height) {
|
||||
ViewGroup.LayoutParams layoutParams = frameLayout.getLayoutParams();
|
||||
layoutParams.height = height;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the resource of background.
|
||||
*
|
||||
* @param resourceId ResourceId.
|
||||
*/
|
||||
public void setBackground(int resourceId) {
|
||||
frameLayout.setBackgroundResource(resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the resource of click effect.
|
||||
*
|
||||
* @param resourceId ResourceId.
|
||||
*/
|
||||
public void setEffect(int resourceId) {
|
||||
clickEffect.setBackgroundResource(resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the duration of the effect.
|
||||
*
|
||||
* @param duration Duration, in ms.
|
||||
*/
|
||||
public void setEffectDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text size of the main text.
|
||||
*
|
||||
* @param size Text size, in sp.
|
||||
*/
|
||||
public void setTextSize(int size) {
|
||||
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text size of the sub text.
|
||||
*
|
||||
* @param size Text size, in sp.
|
||||
*/
|
||||
public void setSubTextSize(int size) {
|
||||
subText.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text color of main text.
|
||||
*
|
||||
* @param color Color.
|
||||
*/
|
||||
public void setTextColor(int color) {
|
||||
text.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text color of sub text.
|
||||
*
|
||||
* @param color Color.
|
||||
*/
|
||||
public void setSubTextColor(int color) {
|
||||
subText.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font of button.
|
||||
*
|
||||
* @param typeFace New font.
|
||||
*/
|
||||
public void setTypeFace(Typeface typeFace) {
|
||||
text.setTypeface(typeFace);
|
||||
subText.setTypeface(typeFace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string of the text.
|
||||
*
|
||||
* @param textString The new string.
|
||||
*/
|
||||
public void setText(String textString) {
|
||||
this.textString = textString;
|
||||
if (text != null) text.setText(textString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string of the sub text.
|
||||
*
|
||||
* @param subTextString The new string.
|
||||
*/
|
||||
public void setSubText(String subTextString) {
|
||||
this.subTextString = subTextString;
|
||||
if (subText != null) subText.setText(subTextString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility of sub textview.
|
||||
*
|
||||
* @param visibility The visibility.
|
||||
*/
|
||||
public void setSubTextVisibility(int visibility) {
|
||||
if (visibility == GONE) {
|
||||
text.setGravity(Gravity.CENTER);
|
||||
} else {
|
||||
text.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
|
||||
}
|
||||
subText.setVisibility(visibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the click effect.
|
||||
*
|
||||
* @param event MotionEvent.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
switch(event.getAction()){
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (onPressListener != null) onPressListener.onPress(textString);
|
||||
clickEffectAnimator.cancel();
|
||||
clickEffect.setAlpha(1);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
clickEffectAnimator.start();
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the animation.
|
||||
*/
|
||||
public void clearAnimation() {
|
||||
if (clickEffect.getAlpha() == 1) {
|
||||
clickEffectAnimator.cancel();
|
||||
clickEffectAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnPressListener {
|
||||
void onPress(String string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,869 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Typeface;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.blurlockview.Directions.HideType;
|
||||
import com.cpm.lorealbaautomation.blurlockview.Directions.ShowType;
|
||||
import com.cpm.lorealbaautomation.blurlockview.Eases.EaseType;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/16.
|
||||
*/
|
||||
public class BlurLockView extends FrameLayout
|
||||
implements
|
||||
BigButtonView.OnPressListener,
|
||||
SmallButtonView.OnPressListener {
|
||||
|
||||
private final char CHARS[][] = {
|
||||
{'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'},
|
||||
{'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'},
|
||||
{ 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L' },
|
||||
{ 'Z', 'X', 'C', 'V', 'B', 'N', 'M' }
|
||||
};
|
||||
|
||||
private Password type = Password.NUMBER;
|
||||
|
||||
private int passwordLength = 4;
|
||||
private String correctPassword = null;
|
||||
private int incorrectInputTimes = 0;
|
||||
private Typeface typeface;
|
||||
|
||||
private boolean animationIsPlaying = false;
|
||||
|
||||
public boolean isIs_Password_Check_Mode() {
|
||||
return is_Password_Check_Mode;
|
||||
}
|
||||
|
||||
public void setIs_Password_Check_Mode(boolean is_Password_Check_Mode) {
|
||||
this.is_Password_Check_Mode = is_Password_Check_Mode;
|
||||
}
|
||||
|
||||
private boolean is_Password_Check_Mode = false;
|
||||
|
||||
private Stack<String> passwordStack = null;
|
||||
|
||||
private TextView title;
|
||||
private Indicator indicator;
|
||||
|
||||
private BigButtonView[] bigButtonViews;
|
||||
private SmallButtonView[][] smallButtonViews;
|
||||
private BlurView mBlurView;
|
||||
private TextView leftButton;
|
||||
private TextView rightButton;
|
||||
|
||||
private OnLeftButtonClickListener onLeftButtonClickListener;
|
||||
private OnPasswordInputListener onPasswordInputListener;
|
||||
|
||||
public BlurLockView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BlurLockView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init.
|
||||
*/
|
||||
private void init() {
|
||||
// number password
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.number_lock_view, this, true);
|
||||
|
||||
bigButtonViews = new BigButtonView[10];
|
||||
bigButtonViews[0] = (BigButtonView)findViewById(R.id.button_0);
|
||||
bigButtonViews[1] = (BigButtonView)findViewById(R.id.button_1);
|
||||
bigButtonViews[2] = (BigButtonView)findViewById(R.id.button_2);
|
||||
bigButtonViews[3] = (BigButtonView)findViewById(R.id.button_3);
|
||||
bigButtonViews[4] = (BigButtonView)findViewById(R.id.button_4);
|
||||
bigButtonViews[5] = (BigButtonView)findViewById(R.id.button_5);
|
||||
bigButtonViews[6] = (BigButtonView)findViewById(R.id.button_6);
|
||||
bigButtonViews[7] = (BigButtonView)findViewById(R.id.button_7);
|
||||
bigButtonViews[8] = (BigButtonView)findViewById(R.id.button_8);
|
||||
bigButtonViews[9] = (BigButtonView)findViewById(R.id.button_9);
|
||||
|
||||
String[] texts = getResources().getStringArray(R.array.default_big_button_text);
|
||||
String[] subTexts = getResources().getStringArray(R.array.default_big_button_sub_text);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
bigButtonViews[i].setOnPressListener(this);
|
||||
bigButtonViews[i].setText(texts[i]);
|
||||
//bigButtonViews[i].setSubText(subTexts[i]);
|
||||
}
|
||||
|
||||
bigButtonViews[0].setSubTextVisibility(View.GONE);
|
||||
bigButtonViews[1].setSubTextVisibility(View.INVISIBLE);
|
||||
|
||||
// text password
|
||||
smallButtonViews = new SmallButtonView[4][10];
|
||||
|
||||
// get screen width
|
||||
Display display = ((Activity)getContext()).getWindowManager().getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getSize(size);
|
||||
int width = size.x;
|
||||
|
||||
int buttonHorizontalMargin = 6;
|
||||
int buttonVerticalMargin = 24;
|
||||
int buttonWidth = (width - 11 * buttonHorizontalMargin) / 10;
|
||||
|
||||
// add buttons to lines
|
||||
LinearLayout line1 = (LinearLayout)findViewById(R.id.line_1);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
smallButtonViews[0][i] = new SmallButtonView(getContext());
|
||||
smallButtonViews[0][i].setOnPressListener(this);
|
||||
smallButtonViews[0][i].setText(CHARS[0][i] + "");
|
||||
smallButtonViews[0][i].setWidth(buttonWidth);
|
||||
smallButtonViews[0][i].setHeight(buttonWidth);
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
buttonWidth,
|
||||
buttonWidth
|
||||
);
|
||||
if (i == 0)
|
||||
params.setMargins(buttonHorizontalMargin, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
else if (i == 9)
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin, buttonVerticalMargin / 2);
|
||||
else
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
line1.addView(smallButtonViews[0][i], params);
|
||||
}
|
||||
|
||||
LinearLayout line2 = (LinearLayout)findViewById(R.id.line_2);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
smallButtonViews[1][i] = new SmallButtonView(getContext());
|
||||
smallButtonViews[1][i].setOnPressListener(this);
|
||||
smallButtonViews[1][i].setText(CHARS[1][i] + "");
|
||||
smallButtonViews[1][i].setWidth(buttonWidth);
|
||||
smallButtonViews[1][i].setHeight(buttonWidth);
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
buttonWidth,
|
||||
buttonWidth
|
||||
);
|
||||
if (i == 0)
|
||||
params.setMargins(buttonHorizontalMargin, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
else if (i == 9)
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin, buttonVerticalMargin / 2);
|
||||
else
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
line2.addView(smallButtonViews[1][i], params);
|
||||
}
|
||||
|
||||
LinearLayout line3 = (LinearLayout)findViewById(R.id.line_3);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
smallButtonViews[2][i] = new SmallButtonView(getContext());
|
||||
smallButtonViews[2][i].setOnPressListener(this);
|
||||
smallButtonViews[2][i].setText(CHARS[2][i] + "");
|
||||
smallButtonViews[2][i].setWidth(buttonWidth);
|
||||
smallButtonViews[2][i].setHeight(buttonWidth);
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
buttonWidth,
|
||||
buttonWidth
|
||||
);
|
||||
|
||||
if (i == 0)
|
||||
params.setMargins(buttonHorizontalMargin, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
else if (i == 8)
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin, buttonVerticalMargin / 2);
|
||||
else
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
line3.addView(smallButtonViews[2][i], params);
|
||||
}
|
||||
|
||||
LinearLayout line4 = (LinearLayout)findViewById(R.id.line_4);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
smallButtonViews[3][i] = new SmallButtonView(getContext());
|
||||
smallButtonViews[3][i].setOnPressListener(this);
|
||||
smallButtonViews[3][i].setText(CHARS[3][i] + "");
|
||||
smallButtonViews[3][i].setWidth(buttonWidth);
|
||||
smallButtonViews[3][i].setHeight(buttonWidth);
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
buttonWidth,
|
||||
buttonWidth
|
||||
);
|
||||
|
||||
if (i == 0)
|
||||
params.setMargins(buttonHorizontalMargin, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
else if (i == 6)
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin, buttonVerticalMargin / 2);
|
||||
else
|
||||
params.setMargins(buttonHorizontalMargin / 2, buttonVerticalMargin / 2, buttonHorizontalMargin / 2, buttonVerticalMargin / 2);
|
||||
line4.addView(smallButtonViews[3][i], params);
|
||||
}
|
||||
|
||||
passwordStack = new Stack<>();
|
||||
|
||||
mBlurView = (BlurView)findViewById(R.id.blurview);
|
||||
mBlurView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Resources resources = getResources();
|
||||
|
||||
indicator = (Indicator)findViewById(R.id.indicator);
|
||||
indicator.setPasswordLength(passwordLength);
|
||||
|
||||
title = (TextView)findViewById(R.id.title);
|
||||
title.setTextColor(ContextCompat.getColor(getContext(), R.color.default_title_text_color));
|
||||
title.setTextSize(resources.getInteger(R.integer.default_title_text_size));
|
||||
|
||||
leftButton = (TextView)findViewById(R.id.left_button);
|
||||
leftButton.setTextColor(ContextCompat.getColor(getContext(), R.color.default_left_button_text_color));
|
||||
leftButton.setTextSize(resources.getInteger(R.integer.default_left_button_text_size));
|
||||
leftButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onLeftButtonClickListener != null) onLeftButtonClickListener.onClick();
|
||||
}
|
||||
});
|
||||
|
||||
rightButton = (TextView)findViewById(R.id.right_button);
|
||||
rightButton.setTextColor(ContextCompat.getColor(getContext(), R.color.default_right_button_text_color));
|
||||
rightButton.setTextSize(resources.getInteger(R.integer.default_right_button_text_size));
|
||||
rightButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (passwordStack.size() > 0) {
|
||||
passwordStack.pop();
|
||||
indicator.delete();
|
||||
if (onPasswordInputListener != null){
|
||||
StringBuilder nowPassword = new StringBuilder("");
|
||||
for (String s : passwordStack) {
|
||||
nowPassword.append(s);
|
||||
}
|
||||
onPasswordInputListener.clear(nowPassword.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the text keyboard smoothly or not.
|
||||
*
|
||||
* @param smoothly Smoothly or not.
|
||||
*/
|
||||
private void showText(boolean smoothly) {
|
||||
if (animationIsPlaying) return;
|
||||
animationIsPlaying = true;
|
||||
if (smoothly) {
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.layout_123), "alpha", 1f, 0f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.layout_456), "alpha", 1f, 0f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.layout_789), "alpha", 1f, 0f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.button_0), "alpha", 1f, 0f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator showAnimator =
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.text_layout), "alpha", 0f, 1f);
|
||||
showAnimator.setDuration(500).addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
super.onAnimationStart(animation);
|
||||
findViewById(R.id.text_layout).setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
findViewById(R.id.layout_123).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.layout_456).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.layout_789).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.button_0).setVisibility(INVISIBLE);
|
||||
animationIsPlaying = false;
|
||||
}
|
||||
});
|
||||
showAnimator.start();
|
||||
} else {
|
||||
findViewById(R.id.layout_123).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.layout_456).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.layout_789).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.button_0).setVisibility(INVISIBLE);
|
||||
findViewById(R.id.text_layout).setVisibility(VISIBLE);
|
||||
animationIsPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the number keyboard smoothly or not.
|
||||
*
|
||||
* @param smoothly Smoothly or not.
|
||||
*/
|
||||
private void showNumber(boolean smoothly) {
|
||||
if (animationIsPlaying) return;
|
||||
animationIsPlaying = true;
|
||||
if (smoothly) {
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.layout_123), "alpha", 0f, 1f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.layout_456), "alpha", 0f, 1f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.layout_789), "alpha", 0f, 1f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.button_0), "alpha", 0f, 1f)
|
||||
.setDuration(500).start();
|
||||
ObjectAnimator showAnimator =
|
||||
ObjectAnimator.ofFloat(findViewById(R.id.text_layout), "alpha", 1f, 0f);
|
||||
showAnimator.setDuration(500).addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
super.onAnimationStart(animation);
|
||||
findViewById(R.id.layout_123).setVisibility(VISIBLE);
|
||||
findViewById(R.id.layout_456).setVisibility(VISIBLE);
|
||||
findViewById(R.id.layout_789).setVisibility(VISIBLE);
|
||||
findViewById(R.id.button_0).setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
findViewById(R.id.text_layout).setVisibility(INVISIBLE);
|
||||
animationIsPlaying = false;
|
||||
}
|
||||
});
|
||||
showAnimator.start();
|
||||
} else {
|
||||
findViewById(R.id.layout_123).setVisibility(VISIBLE);
|
||||
findViewById(R.id.layout_456).setVisibility(VISIBLE);
|
||||
findViewById(R.id.layout_789).setVisibility(VISIBLE);
|
||||
findViewById(R.id.button_0).setVisibility(VISIBLE);
|
||||
findViewById(R.id.text_layout).setVisibility(INVISIBLE);
|
||||
animationIsPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view that need to be blurred.
|
||||
*
|
||||
* @param blurredView The view.
|
||||
*/
|
||||
public void setBlurredView(View blurredView) {
|
||||
mBlurView.setBlurredView(blurredView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the listener.
|
||||
*
|
||||
* @param onLeftButtonClickListener Listener.
|
||||
*/
|
||||
public void setOnLeftButtonClickListener(OnLeftButtonClickListener onLeftButtonClickListener) {
|
||||
this.onLeftButtonClickListener = onLeftButtonClickListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the listener.
|
||||
*
|
||||
* @param onPasswordInputListener Listener.
|
||||
*/
|
||||
public void setOnPasswordInputListener(OnPasswordInputListener onPasswordInputListener) {
|
||||
this.onPasswordInputListener = onPasswordInputListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* From the button views.
|
||||
*
|
||||
* @param string The string from button views.
|
||||
*/
|
||||
@Override
|
||||
public void onPress(String string) {
|
||||
if (correctPassword == null) {
|
||||
throw new RuntimeException("The correct password has NOT been set!");
|
||||
}
|
||||
if (passwordStack.size() >= passwordLength) return;
|
||||
passwordStack.push(string);
|
||||
indicator.add();
|
||||
StringBuilder nowPassword = new StringBuilder("");
|
||||
for (String s : passwordStack) {
|
||||
nowPassword.append(s);
|
||||
}
|
||||
String nowPasswordString = nowPassword.toString();
|
||||
if (correctPassword.equals(nowPasswordString)) {
|
||||
// correct password
|
||||
if (onPasswordInputListener != null)
|
||||
onPasswordInputListener.correct(nowPasswordString);
|
||||
} else {
|
||||
if (correctPassword.length() > nowPasswordString.length()) {
|
||||
// input right now
|
||||
if (onPasswordInputListener != null)
|
||||
onPasswordInputListener.input(nowPasswordString);
|
||||
} else {
|
||||
// incorrect password
|
||||
if (onPasswordInputListener != null)
|
||||
onPasswordInputListener.incorrect(nowPasswordString);
|
||||
if(is_Password_Check_Mode){
|
||||
// perform the clear animation
|
||||
incorrectInputTimes++;
|
||||
indicator.clear();
|
||||
passwordStack.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent click 2 or above buttons at the same time.
|
||||
*
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
if (event.getPointerCount() > 1) {
|
||||
if (Password.NUMBER.equals(type)) {
|
||||
for (int i = 0; i < bigButtonViews.length; i++) bigButtonViews[i].clearAnimation();
|
||||
} else if (Password.TEXT.equals(type)) {
|
||||
for (int i = 0; i < smallButtonViews.length; i++) {
|
||||
for (int j = 0; j < smallButtonViews[i].length; j++) {
|
||||
if (smallButtonViews[i][j] != null) smallButtonViews[i][j].clearAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set big buttons' background.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setBigButtonViewsBackground(int id) {
|
||||
for (int i = 0; i < 10; i++) bigButtonViews[i].setBackground(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set big buttons' click effect.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setBigButtonViewsClickEffect(int id) {
|
||||
for (int i = 0; i < 10; i++) bigButtonViews[i].setEffect(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the click effect duration.
|
||||
*
|
||||
* @param duration
|
||||
*/
|
||||
public void setBigButtonViewsClickEffectDuration(int duration) {
|
||||
for (int i = 0; i < 10; i++) bigButtonViews[i].setEffectDuration(duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set small buttons' background.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setSmallButtonViewsBackground(int id) {
|
||||
for (int i = 0; i < smallButtonViews.length; i++)
|
||||
for (int j = 0; j < smallButtonViews[i].length; j++)
|
||||
if (smallButtonViews[i][j] != null)
|
||||
smallButtonViews[i][j].setBackground(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set small buttons' click effect.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setSmallButtonViewsClickEffect(int id) {
|
||||
for (int i = 0; i < smallButtonViews.length; i++)
|
||||
for (int j = 0; j < smallButtonViews[i].length; j++)
|
||||
if (smallButtonViews[i][j] != null)
|
||||
smallButtonViews[i][j].setEffect(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the click effect duration.
|
||||
*
|
||||
* @param duration
|
||||
*/
|
||||
public void setSmallButtonViewsClickEffectDuration(int duration) {
|
||||
for (int i = 0; i < smallButtonViews.length; i++)
|
||||
for (int j = 0; j < smallButtonViews[i].length; j++)
|
||||
if (smallButtonViews[i][j] != null)
|
||||
smallButtonViews[i][j].setEffectDuration(duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the fonts.
|
||||
*
|
||||
* @param typeface
|
||||
*/
|
||||
public void setTypeface(Typeface typeface) {
|
||||
this.typeface = typeface;
|
||||
if (type.equals(Password.NUMBER)) {
|
||||
for (int i = 0; i < 10; i++) bigButtonViews[i].setTypeFace(typeface);
|
||||
} else if (type.equals(Password.TEXT)) {
|
||||
for (int i = 0; i < smallButtonViews.length; i++)
|
||||
for (int j = 0; j < smallButtonViews[i].length; j++)
|
||||
if (smallButtonViews[i][j] != null)
|
||||
smallButtonViews[i][j].setTypeFace(typeface);
|
||||
}
|
||||
title.setTypeface(typeface);
|
||||
leftButton.setTypeface(typeface);
|
||||
rightButton.setTypeface(typeface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all the text color.
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setTextColor(int color) {
|
||||
if (type.equals(Password.NUMBER)) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
bigButtonViews[i].setTextColor(color);
|
||||
bigButtonViews[i].setSubTextColor(color);
|
||||
}
|
||||
} else if (type.equals(Password.TEXT)) {
|
||||
for (int i = 0; i < smallButtonViews.length; i++)
|
||||
for (int j = 0; j < smallButtonViews[i].length; j++)
|
||||
if (smallButtonViews[i][j] != null)
|
||||
smallButtonViews[i][j].setTextColor(color);
|
||||
}
|
||||
title.setTextColor(color);
|
||||
leftButton.setTextColor(color);
|
||||
rightButton.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the length of the password.
|
||||
* Default length is 4.
|
||||
*
|
||||
* @param passwordLength
|
||||
*/
|
||||
public void setPasswordLength(int passwordLength) {
|
||||
this.passwordLength = passwordLength;
|
||||
indicator.setPasswordLength(passwordLength);
|
||||
passwordStack.clear();
|
||||
correctPassword = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Password getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password type.
|
||||
*
|
||||
* @param type Number or text.
|
||||
*/
|
||||
public void setType(Password type, boolean smoothly) {
|
||||
if (animationIsPlaying) return;
|
||||
this.type = type;
|
||||
indicator.clear();
|
||||
passwordStack.clear();
|
||||
if (Password.NUMBER.equals(type)) {
|
||||
showNumber(smoothly);
|
||||
} else if (Password.TEXT.equals(type)) {
|
||||
showText(smoothly);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title text.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setTitle(String string) {
|
||||
title.setText(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of left button.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setLeftButton(String string) {
|
||||
leftButton.setText(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of right button.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setRightButton(String string) {
|
||||
rightButton.setText(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the target password.
|
||||
*
|
||||
* @param correctPassword The target password.
|
||||
*/
|
||||
public void setCorrectPassword(String correctPassword) {
|
||||
setPasswordLength(correctPassword.length());
|
||||
this.correctPassword = correctPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* You can use this to reset the incorrect input times.
|
||||
*
|
||||
* @param incorrectInputTimes The incorrect input times.
|
||||
*/
|
||||
public void setIncorrectInputTimes(int incorrectInputTimes) {
|
||||
this.incorrectInputTimes = incorrectInputTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the incorrect input times.
|
||||
*
|
||||
* @return Incorrect input times.
|
||||
*/
|
||||
public int getIncorrectInputTimes() {
|
||||
return incorrectInputTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate the blur view.
|
||||
*/
|
||||
public void update() {
|
||||
mBlurView.invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show this BlurLockView.
|
||||
*
|
||||
* @param duration Duration, in ms.
|
||||
* @param showType Direction, in ShowType.
|
||||
* @param easeType Ease type, in EaseType.
|
||||
*/
|
||||
public void show(int duration, ShowType showType, EaseType easeType) {
|
||||
if (animationIsPlaying) return;
|
||||
animationIsPlaying = true;
|
||||
indicator.clear();
|
||||
passwordStack.clear();
|
||||
ObjectAnimator animator = null;
|
||||
setVisibility(VISIBLE);
|
||||
if (showType.equals(ShowType.FROM_TOP_TO_BOTTOM)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationY",
|
||||
getTranslationY() - getHeight(),
|
||||
getTranslationY());
|
||||
} else if (showType.equals(ShowType.FROM_RIGHT_TO_LEFT)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationX",
|
||||
getTranslationX() + getWidth(),
|
||||
getTranslationX());
|
||||
} else if (showType.equals(ShowType.FROM_BOTTOM_TO_TOP)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationY",
|
||||
getTranslationY() + getHeight(),
|
||||
getTranslationY());
|
||||
} else if (showType.equals(ShowType.FROM_LEFT_TO_RIGHT)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationX",
|
||||
getTranslationX() - getWidth(),
|
||||
getTranslationX());
|
||||
} else if (showType.equals(ShowType.FADE_IN)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "alpha",
|
||||
0,
|
||||
1);
|
||||
}
|
||||
animator.setDuration(duration);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
animationIsPlaying = false;
|
||||
}
|
||||
});
|
||||
animator.setInterpolator(InterpolatorFactory.getInterpolator(easeType));
|
||||
animator.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide this BlurLockView.
|
||||
*
|
||||
* @param duration Duration, in ms.
|
||||
* @param hideType Direction, in HideType.
|
||||
* @param easeType Ease type, in EaseType.
|
||||
*/
|
||||
public void hide(int duration, HideType hideType, EaseType easeType) {
|
||||
if (animationIsPlaying) return;
|
||||
animationIsPlaying = true;
|
||||
ObjectAnimator animator = null;
|
||||
final float originalX = getTranslationX();
|
||||
final float originalY = getTranslationY();
|
||||
if (hideType.equals(HideType.FROM_TOP_TO_BOTTOM)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationY",
|
||||
getTranslationY(),
|
||||
getTranslationY() + getHeight());
|
||||
} else if (hideType.equals(HideType.FROM_RIGHT_TO_LEFT)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationX",
|
||||
getTranslationX(),
|
||||
getTranslationX() - getWidth());
|
||||
} else if (hideType.equals(HideType.FROM_BOTTOM_TO_TOP)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationY",
|
||||
getTranslationY(),
|
||||
getTranslationY() - getHeight());
|
||||
} else if (hideType.equals(HideType.FROM_LEFT_TO_RIGHT)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "translationX",
|
||||
getTranslationX(),
|
||||
getTranslationX() + getWidth());
|
||||
} else if (hideType.equals(HideType.FADE_OUT)) {
|
||||
animator = ObjectAnimator.ofFloat(this, "alpha",
|
||||
1,
|
||||
0);
|
||||
}
|
||||
animator.setDuration(duration);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
setVisibility(INVISIBLE);
|
||||
setTranslationX(originalX);
|
||||
setTranslationY(originalY);
|
||||
setAlpha(1);
|
||||
animationIsPlaying = false;
|
||||
}
|
||||
});
|
||||
animator.setInterpolator(InterpolatorFactory.getInterpolator(easeType));
|
||||
animator.start();
|
||||
}
|
||||
|
||||
public interface OnPasswordInputListener {
|
||||
void correct(String inputPassword);
|
||||
void incorrect(String inputPassword);
|
||||
void input(String inputPassword);
|
||||
void clear(String remainingPassword);
|
||||
}
|
||||
|
||||
public interface OnLeftButtonClickListener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title.
|
||||
* @return
|
||||
*/
|
||||
public TextView getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the left button.
|
||||
* @return
|
||||
*/
|
||||
public TextView getLeftButton() {
|
||||
return leftButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the right button.
|
||||
* @return
|
||||
*/
|
||||
public TextView getRightButton() {
|
||||
return rightButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the numbers.
|
||||
* @return
|
||||
*/
|
||||
public BigButtonView[] getBigButtonViews() {
|
||||
return bigButtonViews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the texts.
|
||||
* @return
|
||||
*/
|
||||
public SmallButtonView[][] getSmallButtonViews() {
|
||||
return smallButtonViews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the blur radius.
|
||||
*/
|
||||
public void setBlurRadius(int blurRadius) {
|
||||
mBlurView.setBlurRadius(blurRadius);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the blur radius.
|
||||
* @return
|
||||
*/
|
||||
public int getBlurRadius() {
|
||||
return mBlurView.getBlurRadius();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the downsample factor.
|
||||
* @param downsampleFactor
|
||||
*/
|
||||
public void setDownsampleFactor(int downsampleFactor) {
|
||||
mBlurView.setDownsampleFactor(downsampleFactor);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the downsample factor.
|
||||
* @return
|
||||
*/
|
||||
public int getDownsampleFactor() {
|
||||
return mBlurView.getDownsampleFactor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the overlay color.
|
||||
* @param color
|
||||
*/
|
||||
public void setOverlayColor(int color) {
|
||||
mBlurView.setOverlayColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the overlay color.
|
||||
* @return
|
||||
*/
|
||||
public int getOverlayColor() {
|
||||
return mBlurView.getmOverlayColor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.renderscript.Allocation;
|
||||
import android.renderscript.Element;
|
||||
import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicBlur;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/16.
|
||||
*/
|
||||
public class BlurView extends View {
|
||||
|
||||
private int mBlurRadius;
|
||||
private int mDownsampleFactor;
|
||||
private int mOverlayColor;
|
||||
|
||||
private View mBlurredView;
|
||||
private int mBlurredViewWidth, mBlurredViewHeight;
|
||||
|
||||
private boolean mDownsampleFactorChanged;
|
||||
private Bitmap mBitmapToBlur, mBlurredBitmap;
|
||||
private Canvas mBlurringCanvas;
|
||||
private RenderScript mRenderScript;
|
||||
private ScriptIntrinsicBlur mBlurScript;
|
||||
private Allocation mBlurInput, mBlurOutput;
|
||||
|
||||
public BlurView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BlurView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
final Resources res = getResources();
|
||||
final int defaultBlurRadius = res.getInteger(R.integer.default_blur_radius);
|
||||
final int defaultDownsampleFactor = res.getInteger(R.integer.default_downsample_factor);
|
||||
final int defaultOverlayColor = res.getColor(R.color.default_overlay_color);
|
||||
|
||||
initializeRenderScript(context);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BlurView);
|
||||
setBlurRadius(a.getInt(R.styleable.BlurView_blurRadius, defaultBlurRadius));
|
||||
setDownsampleFactor(a.getInt(R.styleable.BlurView_downsampleFactor,
|
||||
defaultDownsampleFactor));
|
||||
setOverlayColor(a.getColor(R.styleable.BlurView_overlayColor, defaultOverlayColor));
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setBlurredView(View blurredView) {
|
||||
mBlurredView = blurredView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (mBlurredView != null) {
|
||||
if (prepare()) {
|
||||
// If the background of the blurred view is a color drawable, we use it to clear
|
||||
// the blurring canvas, which ensures that edges of the child views are blurred
|
||||
// as well; otherwise we clear the blurring canvas with a transparent color.
|
||||
if (mBlurredView.getBackground() != null && mBlurredView.getBackground() instanceof ColorDrawable) {
|
||||
mBitmapToBlur.eraseColor(((ColorDrawable) mBlurredView.getBackground()).getColor());
|
||||
} else {
|
||||
mBitmapToBlur.eraseColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
int[] mBlurredViewXY = new int[2];
|
||||
mBlurredView.getLocationOnScreen(mBlurredViewXY);
|
||||
int[] mBlurringViewXY = new int[2];
|
||||
getLocationOnScreen(mBlurringViewXY);
|
||||
|
||||
mBlurredView.draw(mBlurringCanvas);
|
||||
blur();
|
||||
|
||||
canvas.save();
|
||||
|
||||
// modify here to get the correct bitmap when the blurring view is in a parent
|
||||
canvas.translate(mBlurredViewXY[0] - mBlurringViewXY[0], mBlurredViewXY[1] - mBlurringViewXY[1]);
|
||||
canvas.scale(mDownsampleFactor, mDownsampleFactor);
|
||||
canvas.drawBitmap(mBlurredBitmap, 0, 0, null);
|
||||
canvas.restore();
|
||||
}
|
||||
canvas.drawColor(mOverlayColor);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlurRadius(int radius) {
|
||||
mBlurRadius = radius;
|
||||
mBlurScript.setRadius(mBlurRadius);
|
||||
}
|
||||
|
||||
public int getBlurRadius() {
|
||||
return mBlurRadius;
|
||||
}
|
||||
|
||||
public void setDownsampleFactor(int factor) {
|
||||
if (factor <= 0) {
|
||||
throw new IllegalArgumentException("Downsample factor must be greater than 0.");
|
||||
}
|
||||
|
||||
if (mDownsampleFactor != factor) {
|
||||
mDownsampleFactor = factor;
|
||||
mDownsampleFactorChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDownsampleFactor() {
|
||||
return mDownsampleFactor;
|
||||
}
|
||||
|
||||
public void setOverlayColor(int color) {
|
||||
mOverlayColor = color;
|
||||
}
|
||||
|
||||
public int getmOverlayColor() {
|
||||
return mOverlayColor;
|
||||
}
|
||||
|
||||
private void initializeRenderScript(Context context) {
|
||||
mRenderScript = RenderScript.create(context);
|
||||
mBlurScript = ScriptIntrinsicBlur.create(mRenderScript, Element.U8_4(mRenderScript));
|
||||
}
|
||||
|
||||
protected boolean prepare() {
|
||||
final int width = mBlurredView.getWidth();
|
||||
final int height = mBlurredView.getHeight();
|
||||
|
||||
if (mBlurringCanvas == null || mDownsampleFactorChanged
|
||||
|| mBlurredViewWidth != width || mBlurredViewHeight != height) {
|
||||
mDownsampleFactorChanged = false;
|
||||
|
||||
mBlurredViewWidth = width;
|
||||
mBlurredViewHeight = height;
|
||||
|
||||
int scaledWidth = width / mDownsampleFactor;
|
||||
int scaledHeight = height / mDownsampleFactor;
|
||||
|
||||
// The following manipulation is to avoid some RenderScript artifacts at the edge.
|
||||
scaledWidth = scaledWidth - scaledWidth % 4 + 4;
|
||||
scaledHeight = scaledHeight - scaledHeight % 4 + 4;
|
||||
|
||||
if (mBlurredBitmap == null
|
||||
|| mBlurredBitmap.getWidth() != scaledWidth
|
||||
|| mBlurredBitmap.getHeight() != scaledHeight) {
|
||||
mBitmapToBlur = Bitmap.createBitmap(scaledWidth, scaledHeight,
|
||||
Bitmap.Config.ARGB_8888);
|
||||
if (mBitmapToBlur == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mBlurredBitmap = Bitmap.createBitmap(scaledWidth, scaledHeight,
|
||||
Bitmap.Config.ARGB_8888);
|
||||
if (mBlurredBitmap == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mBlurringCanvas = new Canvas(mBitmapToBlur);
|
||||
mBlurringCanvas.scale(1f / mDownsampleFactor, 1f / mDownsampleFactor);
|
||||
mBlurInput = Allocation.createFromBitmap(mRenderScript, mBitmapToBlur,
|
||||
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
|
||||
mBlurOutput = Allocation.createTyped(mRenderScript, mBlurInput.getType());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void blur() {
|
||||
mBlurInput.copyFrom(mBitmapToBlur);
|
||||
mBlurScript.setInput(mBlurInput);
|
||||
mBlurScript.forEach(mBlurOutput);
|
||||
mBlurOutput.copyTo(mBlurredBitmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (mRenderScript != null) {
|
||||
mRenderScript.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Directions;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/17.
|
||||
*/
|
||||
public enum HideType {
|
||||
|
||||
FROM_TOP_TO_BOTTOM(0),
|
||||
FROM_RIGHT_TO_LEFT(1),
|
||||
FROM_BOTTOM_TO_TOP(2),
|
||||
FROM_LEFT_TO_RIGHT(3),
|
||||
FADE_OUT(4);
|
||||
|
||||
int type;
|
||||
|
||||
HideType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Directions;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/17.
|
||||
*/
|
||||
public enum ShowType {
|
||||
|
||||
FROM_TOP_TO_BOTTOM(0),
|
||||
FROM_RIGHT_TO_LEFT(1),
|
||||
FROM_BOTTOM_TO_TOP(2),
|
||||
FROM_LEFT_TO_RIGHT(3),
|
||||
FADE_IN(4);
|
||||
|
||||
int type;
|
||||
|
||||
ShowType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/17.
|
||||
*/
|
||||
public class Dot extends FrameLayout {
|
||||
|
||||
private View selected;
|
||||
private View unselected;
|
||||
|
||||
private ObjectAnimator selectedAnimator;
|
||||
private ObjectAnimator unselectedAnimator;
|
||||
|
||||
private boolean isSelected = false;
|
||||
|
||||
public Dot(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public Dot(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.dot_view, this, true);
|
||||
|
||||
selected = findViewById(R.id.selected);
|
||||
unselected = findViewById(R.id.unselected);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this dot to selected or not.
|
||||
*
|
||||
* @param isSelected Selected or not.
|
||||
*/
|
||||
public void setSelected(boolean isSelected) {
|
||||
if (!(this.isSelected ^ isSelected)) return;
|
||||
this.isSelected = isSelected;
|
||||
if (isSelected) {
|
||||
// change to selected
|
||||
selected.setAlpha(0);
|
||||
unselected.setAlpha(1);
|
||||
if (selectedAnimator != null) selectedAnimator.cancel();
|
||||
if (unselectedAnimator != null) unselectedAnimator.cancel();
|
||||
|
||||
selectedAnimator = ObjectAnimator.ofFloat(selected, "alpha", 0f, 1f);
|
||||
selectedAnimator.setDuration(300);
|
||||
selectedAnimator.start();
|
||||
|
||||
unselectedAnimator = ObjectAnimator.ofFloat(unselected, "alpha", 1f, 0f);
|
||||
unselectedAnimator.setDuration(300);
|
||||
unselectedAnimator.start();
|
||||
} else {
|
||||
// change to unselected
|
||||
selected.setAlpha(1);
|
||||
unselected.setAlpha(0);
|
||||
if (selectedAnimator != null) selectedAnimator.cancel();
|
||||
if (unselectedAnimator != null) unselectedAnimator.cancel();
|
||||
|
||||
selectedAnimator = ObjectAnimator.ofFloat(selected, "alpha", 1f, 0f);
|
||||
selectedAnimator.setDuration(300);
|
||||
selectedAnimator.start();
|
||||
|
||||
unselectedAnimator = ObjectAnimator.ofFloat(unselected, "alpha", 0f, 1f);
|
||||
unselectedAnimator.setDuration(300);
|
||||
unselectedAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the dot.
|
||||
*/
|
||||
public void clear() {
|
||||
selected.setAlpha(0);
|
||||
unselected.setAlpha(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
import android.graphics.PointF;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
public abstract class CubicBezier {
|
||||
|
||||
private PointF start;
|
||||
private PointF end;
|
||||
private PointF a = new PointF();
|
||||
private PointF b = new PointF();
|
||||
private PointF c = new PointF();
|
||||
|
||||
/**
|
||||
* init the 4 values of the cubic-bezier
|
||||
* @param startX x of start
|
||||
* @param startY y of start
|
||||
* @param endX x of end
|
||||
* @param endY y of end
|
||||
*/
|
||||
public void init(float startX, float startY, float endX, float endY) {
|
||||
setStart(new PointF(startX, startY));
|
||||
setEnd(new PointF(endX, endY));
|
||||
}
|
||||
|
||||
public void init(double startX, double startY, double endX, double endY) {
|
||||
init((float) startX, (float) startY, (float) endX, (float) endY);
|
||||
}
|
||||
|
||||
public float getOffset(float offset) {
|
||||
return getBezierCoordinateY(getXForTime(offset));
|
||||
}
|
||||
|
||||
private float getBezierCoordinateY(float time) {
|
||||
c.y = 3 * start.y;
|
||||
b.y = 3 * (end.y - start.y) - c.y;
|
||||
a.y = 1 - c.y - b.y;
|
||||
return time * (c.y + time * (b.y + time * a.y));
|
||||
}
|
||||
|
||||
private float getXForTime(float time) {
|
||||
float x = time;
|
||||
float z;
|
||||
for (int i = 1; i < 14; i++) {
|
||||
z = getBezierCoordinateX(x) - time;
|
||||
if (Math.abs(z) < 1e-3) {
|
||||
break;
|
||||
}
|
||||
x -= z / getXDerivate(x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private float getXDerivate(float t) {
|
||||
return c.x + t * (2 * b.x + 3 * a.x * t);
|
||||
}
|
||||
|
||||
private float getBezierCoordinateX(float time) {
|
||||
c.x = 3 * start.x;
|
||||
b.x = 3 * (end.x - start.x) - c.x;
|
||||
a.x = 1 - c.x - b.x;
|
||||
return time * (c.x + time * (b.x + time * a.x));
|
||||
}
|
||||
|
||||
public PointF getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(PointF start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public PointF getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public void setEnd(PointF end) {
|
||||
this.end = end;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInBack extends CubicBezier {
|
||||
|
||||
public EaseInBack() {
|
||||
init(0.6, -0.28, 0.735, 0.045);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInBounce extends CubicBezier {
|
||||
|
||||
public EaseInBounce() {
|
||||
|
||||
}
|
||||
|
||||
public float getOffset(float t) {
|
||||
float b = 0;
|
||||
float c = 1;
|
||||
float d = 1;
|
||||
return c - easeOutBounce(d-t, 0, c, d) + b;
|
||||
}
|
||||
|
||||
private float easeOutBounce(float t, float b, float c, float d) {
|
||||
if ((t/=d) < (1/2.75f)) {
|
||||
return c*(7.5625f*t*t) + b;
|
||||
} else if (t < (2/2.75f)) {
|
||||
return c*(7.5625f*(t-=(1.5f/2.75f))*t + .75f) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625f*(t-=(2.25f/2.75f))*t + .9375f) + b;
|
||||
} else {
|
||||
return c*(7.5625f*(t-=(2.625f/2.75f))*t + .984375f) + b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInCirc extends CubicBezier {
|
||||
|
||||
public EaseInCirc() {
|
||||
init(0.6, 0.04, 0.98, 0.335);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInCubic extends CubicBezier {
|
||||
|
||||
public EaseInCubic() {
|
||||
init(0.55, 0.055, 0.675, 0.19);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInElastic extends CubicBezier {
|
||||
|
||||
public EaseInElastic() {
|
||||
|
||||
}
|
||||
|
||||
public float getOffset(float t) {
|
||||
float b = 0;
|
||||
float c = 1;
|
||||
float d = 1;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c;
|
||||
float p=d*.3f;
|
||||
float a=c;
|
||||
float s=p/4;
|
||||
return -(a*(float) Math.pow(2,10*(t-=1)) * (float) Math.sin( (t*d-s)*(2*(float) Math.PI)/p )) + b;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInExpo extends CubicBezier {
|
||||
|
||||
public EaseInExpo() {
|
||||
init(0.95, 0.05, 0.795, 0.035);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutBack extends CubicBezier {
|
||||
|
||||
public EaseInOutBack() {
|
||||
init(0.68, -0.55, 0.265, 1.55);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutBounce extends CubicBezier {
|
||||
|
||||
public EaseInOutBounce() {
|
||||
|
||||
}
|
||||
|
||||
public float getOffset(float t) {
|
||||
float b = 0;
|
||||
float c = 1;
|
||||
float d = 1;
|
||||
if (t < d / 2)
|
||||
return easeInBounce(t * 2, 0, c, d) * .5f + b;
|
||||
else
|
||||
return easeOutBounce(t * 2 - d, 0, c, d) * .5f + c * .5f + b;
|
||||
}
|
||||
|
||||
private float easeInBounce(float t, float b, float c, float d) {
|
||||
return c - easeOutBounce(d - t, 0, c, d) + b;
|
||||
}
|
||||
|
||||
private float easeOutBounce(float t, float b, float c, float d) {
|
||||
if ((t/=d) < (1/2.75f)) {
|
||||
return c*(7.5625f*t*t) + b;
|
||||
} else if (t < (2/2.75f)) {
|
||||
return c*(7.5625f*(t-=(1.5f/2.75f))*t + .75f) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625f*(t-=(2.25f/2.75f))*t + .9375f) + b;
|
||||
} else {
|
||||
return c*(7.5625f*(t-=(2.625f/2.75f))*t + .984375f) + b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutCirc extends CubicBezier {
|
||||
|
||||
public EaseInOutCirc() {
|
||||
init(0.785, 0.135, 0.15, 0.86);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutCubic extends CubicBezier {
|
||||
|
||||
public EaseInOutCubic() {
|
||||
init(0.645, 0.045, 0.355, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutElastic extends CubicBezier {
|
||||
|
||||
public EaseInOutElastic() {
|
||||
|
||||
}
|
||||
|
||||
public float getOffset(float t) {
|
||||
float b = 0;
|
||||
float c = 1;
|
||||
float d = 1;
|
||||
if (t==0) return b; if ((t/=d/2)==2) return b+c;
|
||||
float p=d*(.3f*1.5f);
|
||||
float a=c;
|
||||
float s=p/4;
|
||||
if (t < 1) return -.5f*(a*(float) Math.pow(2,10*(t-=1)) * (float) Math.sin( (t*d-s)*(2*(float) Math.PI)/p )) + b;
|
||||
return a*(float) Math.pow(2,-10*(t-=1)) * (float) Math.sin( (t*d-s)*(2*(float) Math.PI)/p )*.5f + c + b;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutExpo extends CubicBezier {
|
||||
|
||||
public EaseInOutExpo() {
|
||||
init(1, 0, 0, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutQuad extends CubicBezier {
|
||||
|
||||
public EaseInOutQuad() {
|
||||
init(0.455, 0.03, 0.515, 0.955);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutQuart extends CubicBezier {
|
||||
|
||||
public EaseInOutQuart() {
|
||||
init(0.77, 0, 0.175, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutQuint extends CubicBezier {
|
||||
|
||||
public EaseInOutQuint() {
|
||||
init(0.86, 0, 0.07, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutSine extends CubicBezier {
|
||||
|
||||
public EaseInOutSine() {
|
||||
init(0.445, 0.05, 0.55, 0.95);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInQuad extends CubicBezier {
|
||||
|
||||
public EaseInQuad() {
|
||||
init(0.55, 0.085, 0.68, 0.53);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInQuart extends CubicBezier {
|
||||
|
||||
public EaseInQuart() {
|
||||
init(0.895, 0.03, 0.685, 0.22);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInQuint extends CubicBezier {
|
||||
|
||||
public EaseInQuint() {
|
||||
init(0.755, 0.05, 0.855, 0.06);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInSine extends CubicBezier {
|
||||
|
||||
public EaseInSine() {
|
||||
init(0.47, 0, 0.745, 0.715);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutBack extends CubicBezier {
|
||||
|
||||
public EaseOutBack() {
|
||||
init(0.175, 0.885, 0.32, 1.275);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutBounce extends CubicBezier {
|
||||
|
||||
public EaseOutBounce() {
|
||||
|
||||
}
|
||||
|
||||
public float getOffset(float t) {
|
||||
float b = 0;
|
||||
float c = 1;
|
||||
float d = 1;
|
||||
if ((t/=d) < (1/2.75f)) {
|
||||
return c*(7.5625f*t*t) + b;
|
||||
} else if (t < (2/2.75f)) {
|
||||
return c*(7.5625f*(t-=(1.5f/2.75f))*t + .75f) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625f*(t-=(2.25f/2.75f))*t + .9375f) + b;
|
||||
} else {
|
||||
return c*(7.5625f*(t-=(2.625f/2.75f))*t + .984375f) + b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutCirc extends CubicBezier {
|
||||
|
||||
public EaseOutCirc() {
|
||||
init(0.075, 0.82, 0.165, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutCubic extends CubicBezier {
|
||||
|
||||
public EaseOutCubic() {
|
||||
init(0.215, 0.61, 0.355, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutElastic extends CubicBezier {
|
||||
|
||||
public EaseOutElastic() {
|
||||
|
||||
}
|
||||
|
||||
public float getOffset(float t) {
|
||||
float b = 0;
|
||||
float c = 1;
|
||||
float d = 1;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c;
|
||||
float p=d*.3f;
|
||||
float a=c;
|
||||
float s=p/4;
|
||||
return (a*(float) Math.pow(2,-10*t) * (float) Math.sin( (t*d-s)*(2*(float) Math.PI)/p ) + c + b);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutExpo extends CubicBezier {
|
||||
|
||||
public EaseOutExpo() {
|
||||
init(0.19, 1, 0.22, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutQuad extends CubicBezier {
|
||||
|
||||
public EaseOutQuad() {
|
||||
init(0.25, 0.46, 0.45, 0.94);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutQuart extends CubicBezier {
|
||||
|
||||
public EaseOutQuart() {
|
||||
init(0.165, 0.84, 0.44, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutQuint extends CubicBezier {
|
||||
|
||||
public EaseOutQuint() {
|
||||
init(0.23, 1, 0.32, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseOutSine extends CubicBezier {
|
||||
|
||||
public EaseOutSine() {
|
||||
init(0.39, 0.575, 0.565, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public enum EaseType {
|
||||
|
||||
EaseInSine(EaseInSine.class),
|
||||
EaseOutSine(EaseOutSine.class),
|
||||
EaseInOutSine(EaseInOutSine.class),
|
||||
|
||||
EaseInQuad(EaseInQuad.class),
|
||||
EaseOutQuad(EaseOutQuad.class),
|
||||
EaseInOutQuad(EaseInOutQuad.class),
|
||||
|
||||
EaseInCubic(EaseInCubic.class),
|
||||
EaseOutCubic(EaseOutCubic.class),
|
||||
EaseInOutCubic(EaseInOutCubic.class),
|
||||
|
||||
EaseInQuart(EaseInQuart.class),
|
||||
EaseOutQuart(EaseOutQuart.class),
|
||||
EaseInOutQuart(EaseInOutQuart.class),
|
||||
|
||||
EaseInQuint(EaseInQuint.class),
|
||||
EaseOutQuint(EaseOutQuint.class),
|
||||
EaseInOutQuint(EaseInOutQuint.class),
|
||||
|
||||
EaseInExpo(EaseInExpo.class),
|
||||
EaseOutExpo(EaseOutExpo.class),
|
||||
EaseInOutExpo(EaseInOutExpo.class),
|
||||
|
||||
EaseInCirc(EaseInCirc.class),
|
||||
EaseOutCirc(EaseOutCirc.class),
|
||||
EaseInOutCirc(EaseInOutCirc.class),
|
||||
|
||||
EaseInBack(EaseInBack.class),
|
||||
EaseOutBack(EaseOutBack.class),
|
||||
EaseInOutBack(EaseInOutBack.class),
|
||||
|
||||
EaseInElastic(EaseInElastic.class),
|
||||
EaseOutElastic(EaseOutElastic.class),
|
||||
EaseInOutElastic(EaseInOutElastic.class),
|
||||
|
||||
EaseInBounce(EaseInBounce.class),
|
||||
EaseOutBounce(EaseOutBounce.class),
|
||||
EaseInOutBounce(EaseInOutBounce.class),
|
||||
|
||||
Linear(Linear.class);
|
||||
|
||||
private Class easingType;
|
||||
|
||||
/**
|
||||
* ease animation helps to make the movement more real
|
||||
* @param easingType
|
||||
*/
|
||||
EaseType(Class easingType) {
|
||||
this.easingType = easingType;
|
||||
}
|
||||
|
||||
public float getOffset(float offset) {
|
||||
try {
|
||||
return ((CubicBezier) easingType.getConstructor().newInstance()).getOffset(offset);
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
throw new Error("CubicBezier init error.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview.Eases;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class Linear extends CubicBezier {
|
||||
|
||||
public Linear() {
|
||||
init(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/17.
|
||||
*/
|
||||
public class Indicator extends LinearLayout {
|
||||
|
||||
private Dot[] dots;
|
||||
private int number = 0;
|
||||
|
||||
public Indicator(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public Indicator(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public void setPasswordLength(int length) {
|
||||
removeAllViews();
|
||||
dots = new Dot[length];
|
||||
|
||||
for(int i = 0; i < length; i++) {
|
||||
Dot view = new Dot(getContext());
|
||||
|
||||
view.setBackgroundResource(R.drawable.indicator_background);
|
||||
|
||||
LayoutParams params = new LayoutParams(
|
||||
30,
|
||||
30
|
||||
);
|
||||
params.setMargins(20, 10, 20, 10);
|
||||
addView(view, params);
|
||||
dots[i] = view;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dot.
|
||||
*/
|
||||
public void add() {
|
||||
if (number == dots.length) return;
|
||||
dots[number++].setSelected(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a dot.
|
||||
*/
|
||||
public void delete() {
|
||||
if (number == 0) return;
|
||||
dots[--number].setSelected(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all dots.
|
||||
*/
|
||||
public void clear() {
|
||||
number = 0;
|
||||
for (int i = 0; i < dots.length; i++) dots[i].setSelected(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.cpm.lorealbaautomation.blurlockview.Eases.EaseType;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/17.
|
||||
*/
|
||||
public class InterpolatorFactory {
|
||||
|
||||
public static BLVInterpolator getInterpolator(EaseType easeType) {
|
||||
return new BLVInterpolator(easeType);
|
||||
}
|
||||
|
||||
public static class BLVInterpolator implements Interpolator {
|
||||
|
||||
private EaseType easeType;
|
||||
|
||||
public BLVInterpolator(EaseType easeType) {
|
||||
this.easeType = easeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return easeType.getOffset(input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/17.
|
||||
*/
|
||||
public enum Password {
|
||||
|
||||
NUMBER(0),
|
||||
TEXT(1);
|
||||
|
||||
private int type;
|
||||
|
||||
private Password(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.cpm.lorealbaautomation.blurlockview;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/16.
|
||||
*/
|
||||
|
||||
public class SmallButtonView extends FrameLayout {
|
||||
|
||||
private FrameLayout frameLayout;
|
||||
private View clickEffect;
|
||||
private TextView text;
|
||||
private String textString = "";
|
||||
private ObjectAnimator clickEffectAnimator;
|
||||
private int duration = 500;
|
||||
private OnPressListener onPressListener;
|
||||
|
||||
public SmallButtonView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public SmallButtonView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.small_button_view, this, true);
|
||||
|
||||
Resources resources = getResources();
|
||||
|
||||
frameLayout = (FrameLayout)findViewById(R.id.frame_layout);
|
||||
|
||||
text = (TextView)findViewById(R.id.text);
|
||||
text.setText(textString);
|
||||
text.setTextColor(ContextCompat.getColor(context, R.color.default_small_button_text_color));
|
||||
text.setTextSize(resources.getInteger(R.integer.default_small_button_text_size));
|
||||
|
||||
clickEffect = findViewById(R.id.click_effect);
|
||||
clickEffect.setAlpha(0);
|
||||
clickEffectAnimator = ObjectAnimator.ofFloat(clickEffect, "alpha", 1f, 0f);
|
||||
clickEffectAnimator.setDuration(duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the listener, for returning what happened to BlurLockView.
|
||||
*
|
||||
* @param onPressListener OnPressListener.
|
||||
*/
|
||||
public void setOnPressListener(OnPressListener onPressListener) {
|
||||
this.onPressListener = onPressListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of the button.
|
||||
*
|
||||
* @param width Width, in pixels.
|
||||
*/
|
||||
public void setWidth(int width) {
|
||||
ViewGroup.LayoutParams layoutParams = frameLayout.getLayoutParams();
|
||||
layoutParams.width = width;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
layoutParams = clickEffect.getLayoutParams();
|
||||
layoutParams.width = width;
|
||||
clickEffect.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the button.
|
||||
*
|
||||
* @param height Height, in pixels.
|
||||
*/
|
||||
public void setHeight(int height) {
|
||||
ViewGroup.LayoutParams layoutParams = frameLayout.getLayoutParams();
|
||||
layoutParams.height = height;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
layoutParams = clickEffect.getLayoutParams();
|
||||
layoutParams.height = height;
|
||||
clickEffect.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the resource of background.
|
||||
*
|
||||
* @param resourceId ResourceId.
|
||||
*/
|
||||
public void setBackground(int resourceId) {
|
||||
frameLayout.setBackgroundResource(resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the resource of click effect.
|
||||
*
|
||||
* @param resourceId ResourceId.
|
||||
*/
|
||||
public void setEffect(int resourceId) {
|
||||
clickEffect.setBackgroundResource(resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the duration of the effect.
|
||||
*
|
||||
* @param duration Duration, in ms.
|
||||
*/
|
||||
public void setEffectDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text size of the main text.
|
||||
*
|
||||
* @param size Text size, in sp.
|
||||
*/
|
||||
public void setTextSize(int size) {
|
||||
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text color of main text.
|
||||
*
|
||||
* @param color Color.
|
||||
*/
|
||||
public void setTextColor(int color) {
|
||||
text.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font of button.
|
||||
*
|
||||
* @param typeFace New font.
|
||||
*/
|
||||
public void setTypeFace(Typeface typeFace) {
|
||||
text.setTypeface(typeFace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string of the text.
|
||||
*
|
||||
* @param textString The new string.
|
||||
*/
|
||||
public void setText(String textString) {
|
||||
this.textString = textString;
|
||||
if (text != null) text.setText(textString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the click effect.
|
||||
*
|
||||
* @param event MotionEvent.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
switch(event.getAction()){
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (onPressListener != null) onPressListener.onPress(textString);
|
||||
clickEffectAnimator.cancel();
|
||||
clickEffect.setAlpha(1);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
clickEffectAnimator.start();
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the animation.
|
||||
*/
|
||||
public void clearAnimation() {
|
||||
if (clickEffect.getAlpha() == 1) {
|
||||
clickEffectAnimator.cancel();
|
||||
clickEffectAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnPressListener {
|
||||
void onPress(String string);
|
||||
}
|
||||
}
|
||||
+432
@@ -0,0 +1,432 @@
|
||||
package com.cpm.lorealbaautomation.breakmanagement;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.download.Downloader;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterBreak;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class BreakManagementActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemSelectedListener {
|
||||
ArrayList<MasterBreak> breakmanageList = new ArrayList<>();
|
||||
ArrayList<MasterBreak> insertedBreakList = new ArrayList<>();
|
||||
MasterBreak masterBreakObject = new MasterBreak();
|
||||
ArrayAdapter<CharSequence> break_managemntAdapter;
|
||||
String CounterId, visit_date, username, loginTym = "", breakType = "", breakId = "0", startTym = "", endTym = "";
|
||||
private SharedPreferences preferences;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
Button promotion_btn_first, promotion_btn_second;
|
||||
TextView txt_login_Tym, txt_start_Tym;
|
||||
RecyclerView recycl_break_managemnt;
|
||||
Spinner spin_break_Type;
|
||||
boolean clicked_flag = false, flag_update = false;
|
||||
Lorealba_Database db;
|
||||
AlertDialog.Builder alert;
|
||||
Context context;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_break_management);
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
iduserinterface();
|
||||
setTitle("Break Management -" + username);
|
||||
////update device time from server time.............
|
||||
if (CommonFunctions.checkNetIsAvailable(context)) {
|
||||
CommonFunctions.GetServerTym(context, username, db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void iduserinterface() {
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
editor = preferences.edit();
|
||||
CounterId = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
txt_login_Tym = (TextView) findViewById(R.id.txt_login_Tym);
|
||||
txt_start_Tym = (TextView) findViewById(R.id.txt_start_Tym);
|
||||
spin_break_Type = (Spinner) findViewById(R.id.spin_break_Type);
|
||||
//for demo btn
|
||||
promotion_btn_first = (Button) findViewById(R.id.posm_btn_first);
|
||||
promotion_btn_second = (Button) findViewById(R.id.posm_btn_second);
|
||||
recycl_break_managemnt = (RecyclerView) findViewById(R.id.recycl_break_managemnt);
|
||||
|
||||
promotion_btn_first.setOnClickListener(this);
|
||||
promotion_btn_second.setOnClickListener(this);
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
txt_login_Tym.setText("Login Time - " + loginTym);
|
||||
calculate_spin();
|
||||
db.open();
|
||||
calcalate_list_data(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
db.open();
|
||||
}
|
||||
|
||||
@SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables"})
|
||||
private void calcalate_list_data(boolean flag) {
|
||||
db.open();
|
||||
insertedBreakList = db.getBreakManagementList(CounterId, visit_date, username, null);
|
||||
if (insertedBreakList.size() > 0) {
|
||||
for (int k = 0; k < insertedBreakList.size(); k++) {
|
||||
if (insertedBreakList.get(k).getEndTym().equals("")) {
|
||||
masterBreakObject = insertedBreakList.get(k);
|
||||
startTym = masterBreakObject.getStartTym();
|
||||
txt_start_Tym.setText("Start Time - " + startTym);
|
||||
flag_update = true;
|
||||
|
||||
promotion_btn_first.setBackgroundColor(getResources().getColor(R.color.green));
|
||||
promotion_btn_first.setTextColor(getResources().getColor(R.color.white));
|
||||
promotion_btn_second.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_btn_color_primary));
|
||||
promotion_btn_second.setTextColor(getResources().getColor(R.color.grayfor_login));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
recycl_break_managemnt.setAdapter(new ValueAdapter(context, insertedBreakList));
|
||||
recycl_break_managemnt.setLayoutManager(new LinearLayoutManager(context));
|
||||
|
||||
|
||||
if (flag_update) {
|
||||
if (flag) {
|
||||
for (int k = 0; k < breakmanageList.size(); k++) {
|
||||
if (breakmanageList.get(k).getBreakType().equalsIgnoreCase(masterBreakObject.getBreakType())) {
|
||||
spin_break_Type.setSelection(k + 1);
|
||||
spin_break_Type.setEnabled(false);
|
||||
promotion_btn_first.setEnabled(false);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
if (clicked_flag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id1) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
BreakManagementActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id12) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
BreakManagementActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (clicked_flag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
BreakManagementActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
BreakManagementActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.posm_btn_first) {
|
||||
if (spin_break_Type.getSelectedItemId() == 0) {
|
||||
AlertandMessages.showToastMsg(context, "Please Select Break Type");
|
||||
} else if (!startTym.isEmpty()) {
|
||||
AlertandMessages.showToastMsg(context, "Already Take a Break");
|
||||
} else {
|
||||
alert = new AlertDialog.Builder(context).setTitle(R.string.parinaam).setMessage("Are you sure you want to Take a Break ?").setCancelable(false).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables"})
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// hh:mm a will print hours in 12hrs clock, mins and AM/PM (e.g. 02:30 PM)
|
||||
startTym = getTime();
|
||||
txt_start_Tym.setText("Start Time - " + startTym);
|
||||
promotion_btn_first.setBackgroundColor(getResources().getColor(R.color.green));
|
||||
|
||||
promotion_btn_first.setTextColor(getResources().getColor(R.color.white));
|
||||
promotion_btn_second.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_btn_color_primary));
|
||||
promotion_btn_second.setTextColor(getResources().getColor(R.color.grayfor_login));
|
||||
|
||||
masterBreakObject = new MasterBreak();
|
||||
masterBreakObject.setLoginTym(loginTym);
|
||||
masterBreakObject.setBreakType(breakType);
|
||||
masterBreakObject.setBreakId(Integer.valueOf(breakId));
|
||||
masterBreakObject.setStartTym(startTym);
|
||||
masterBreakObject.setEndTym("");
|
||||
masterBreakObject.setTotalDuration("");
|
||||
db.open();
|
||||
db.insertBreakManagement(username, visit_date, CounterId, masterBreakObject);
|
||||
clicked_flag = false;
|
||||
calcalate_list_data(true);
|
||||
}
|
||||
}).setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
|
||||
alert.show();
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.posm_btn_second) {
|
||||
if (masterBreakObject != null && masterBreakObject.getStartTym().equals("")) {
|
||||
AlertandMessages.showToastMsg(context, "No Break.");
|
||||
} else {
|
||||
alert = new AlertDialog.Builder(context).setTitle(R.string.parinaam).setMessage("Are you sure you want to End The Break ?").setCancelable(false).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
endTym = getTime();
|
||||
promotion_btn_first.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_btn_color_primary));
|
||||
promotion_btn_first.setTextColor(getResources().getColor(R.color.grayfor_login));
|
||||
promotion_btn_second.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_btn_color_primary));
|
||||
promotion_btn_second.setTextColor(getResources().getColor(R.color.grayfor_login));
|
||||
db.open();
|
||||
masterBreakObject.setEndTym(endTym);
|
||||
masterBreakObject.setTotalDuration(calculateTotalDuration() + "");
|
||||
masterBreakObject.setTransId(CommonFunctions.getUUID(context));
|
||||
db.open();
|
||||
db.update_break_management(CounterId, visit_date, username, masterBreakObject);
|
||||
//download service
|
||||
Intent intent = new Intent(context, Downloader.class);
|
||||
intent.putExtra(CommonString.KEY_Break_Mangemennt, masterBreakObject);
|
||||
Downloader.enqueueWork(context, intent);
|
||||
AlertandMessages.showToastMsg(context, "Break End Successfully.");
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
BreakManagementActivity.this.finish();
|
||||
|
||||
}
|
||||
|
||||
}).setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void calculate_spin() {
|
||||
db.open();
|
||||
breakmanageList = db.getmasterBreak();
|
||||
break_managemntAdapter = new ArrayAdapter<>(context, R.layout.spinner_custom_item);
|
||||
break_managemntAdapter.add("- Select Break Type -");
|
||||
|
||||
for (int i = 0; i < breakmanageList.size(); i++) {
|
||||
break_managemntAdapter.add(breakmanageList.get(i).getBreakType());
|
||||
}
|
||||
|
||||
spin_break_Type.setAdapter(break_managemntAdapter);
|
||||
break_managemntAdapter.setDropDownViewResource(R.layout.spinner_custom_item);
|
||||
spin_break_Type.setOnItemSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
|
||||
if (pos != 0) {
|
||||
clicked_flag = true;
|
||||
breakType = breakmanageList.get(pos - 1).getBreakType();
|
||||
breakId = breakmanageList.get(pos - 1).getBreakId().toString();
|
||||
if (breakType.equalsIgnoreCase("Lunch Break")) {
|
||||
if (!validatefor_lunch()) {
|
||||
AlertandMessages.showToastMsg(context, "Only One Time Lunch Break Allowed");
|
||||
spin_break_Type.setSelection(0);
|
||||
breakType = "";
|
||||
breakId = "0";
|
||||
}
|
||||
} else if (breakType.equalsIgnoreCase("Tea Break")) {
|
||||
if (validatefor_tea() == 2) {
|
||||
AlertandMessages.showToastMsg(context, "Only Two Time Tea Break Allowed");
|
||||
spin_break_Type.setSelection(0);
|
||||
breakType = "";
|
||||
breakId = "0";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
breakType = "";
|
||||
breakId = "0";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
|
||||
public class ValueAdapter extends RecyclerView.Adapter<ValueAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
List<MasterBreak> data;
|
||||
|
||||
public ValueAdapter(Context context, List<MasterBreak> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ValueAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.break_management_list, parent, false);
|
||||
return new ValueAdapter.MyViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ValueAdapter.MyViewHolder holder, final int position) {
|
||||
final MasterBreak current = data.get(position);
|
||||
|
||||
holder.txt_breakType.setText(current.getBreakType());
|
||||
holder.txt_breakType.setId(position);
|
||||
|
||||
holder.startTym.setText(current.getStartTym());
|
||||
holder.startTym.setId(position);
|
||||
|
||||
holder.endTym.setText(current.getEndTym());
|
||||
holder.endTym.setId(position);
|
||||
|
||||
holder.totalDuration.setText(current.getTotalDuration());
|
||||
holder.totalDuration.setId(position);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txt_breakType, startTym, endTym, totalDuration;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
txt_breakType = (TextView) itemView.findViewById(R.id.txt_breakType);
|
||||
startTym = (TextView) itemView.findViewById(R.id.startTym);
|
||||
endTym = (TextView) itemView.findViewById(R.id.endTym);
|
||||
totalDuration = (TextView) itemView.findViewById(R.id.totalDuration);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getTime() {
|
||||
Calendar currnetDateTime = Calendar.getInstance();
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat df = new SimpleDateFormat("hh:mm a");
|
||||
return df.format(currnetDateTime.getTime());
|
||||
}
|
||||
|
||||
private String calculateTotalDuration() {
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm a");
|
||||
int days = 0, hours = 0, min = 0;
|
||||
try {
|
||||
Date date1 = simpleDateFormat.parse(startTym);
|
||||
Date date2 = simpleDateFormat.parse(endTym);
|
||||
assert date2 != null;
|
||||
assert date1 != null;
|
||||
long difference = date2.getTime() - date1.getTime();
|
||||
days = (int) (difference / (1000 * 60 * 60 * 24));
|
||||
hours = (int) ((difference - (1000 * 60 * 60 * 24 * days)) / (1000 * 60 * 60));
|
||||
min = (int) (difference - (1000 * 60 * 60 * 24 * days) - (1000 * 60 * 60 * hours)) / (1000 * 60);
|
||||
hours = (hours < 0 ? -hours : hours);
|
||||
Log.i("======= Hours", " :: " + hours);
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
return hours + ":" + min;
|
||||
}
|
||||
|
||||
private boolean validatefor_lunch() {
|
||||
String str = "Lunch";
|
||||
boolean flag = true;
|
||||
if (insertedBreakList.size() > 0) {
|
||||
for (int k = 0; k < insertedBreakList.size(); k++) {
|
||||
if (!insertedBreakList.get(k).getEndTym().equals("") && insertedBreakList.get(k).getBreakType().equalsIgnoreCase(str)) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private int validatefor_tea() {
|
||||
String str = "Tea";
|
||||
int count = 0;
|
||||
if (insertedBreakList.size() > 0) {
|
||||
for (int k = 0; k < insertedBreakList.size(); k++) {
|
||||
if (!insertedBreakList.get(k).getEndTym().equals("") && insertedBreakList.get(k).getBreakType().equalsIgnoreCase(str)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.cpm.lorealbaautomation.bulkInsert;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import com.cpm.lorealbaautomation.BuildConfig;
|
||||
|
||||
public class DBContract {
|
||||
/*Content Authority its a name for the content provider, is convenient to use the
|
||||
package app name to be unique on the device */
|
||||
public static final String CONTENT_AUTHORITY = BuildConfig.APPLICATION_ID;
|
||||
|
||||
//Use CONTENT_AUTHORITY to create all the database URI's that
|
||||
// the app will use to link the content provider.
|
||||
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
|
||||
|
||||
/*the name of the uri that can be the same as the name of your table.
|
||||
this will translate to content://com.yourdomain.yourapp/user/ as a valid URI
|
||||
*/
|
||||
public static final String PATH_USER = "User";
|
||||
|
||||
// To prevent someone from accidentally instantiating the contract class,
|
||||
// give it an empty constructor.
|
||||
public DBContract() {
|
||||
}
|
||||
|
||||
//Intern class that defines the user table
|
||||
public static final class UserEntry implements BaseColumns {
|
||||
public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().
|
||||
appendPath(PATH_USER).build();
|
||||
|
||||
public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_USER;
|
||||
|
||||
//Name of the table
|
||||
public static final String TABLE_NAME = "User";
|
||||
//Columns of the user table
|
||||
public static final String COLUMN_Name = "Name";
|
||||
public static final String COLUMN_Password = "Password";
|
||||
public static Uri buildUri(long id) {
|
||||
return ContentUris.withAppendedId(CONTENT_URI, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.cpm.lorealbaautomation.bulkInsert;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
public class DBHelper extends SQLiteOpenHelper {
|
||||
//if you change the schema of the database, you must increment this number
|
||||
private static final int DATABASE_VERSION=1;
|
||||
static final String DATABASE_NAME="mydatabase.db";
|
||||
private static DBHelper mInstance=null;
|
||||
public static DBHelper getInstance(Context ctx){
|
||||
if(mInstance==null){
|
||||
mInstance= new DBHelper(ctx.getApplicationContext());
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public DBHelper(Context context){
|
||||
super(context,DATABASE_NAME,null,DATABASE_VERSION);
|
||||
}
|
||||
|
||||
public int GetDatabase_Version() {
|
||||
return DATABASE_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase sqLiteDatabase){
|
||||
//Create the table users
|
||||
final String SQL_CREATE_TABLE_USERS="CREATE TABLE "+ DBContract.UserEntry.TABLE_NAME+ " ("+
|
||||
DBContract.UserEntry._ID+" INTEGER PRIMARY KEY, "+
|
||||
DBContract.UserEntry.COLUMN_Name+" TEXT , "+
|
||||
DBContract.UserEntry.COLUMN_Password+" TEXT "+
|
||||
" ); ";
|
||||
|
||||
sqLiteDatabase.execSQL(SQL_CREATE_TABLE_USERS);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
|
||||
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + DBContract.UserEntry.TABLE_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.cpm.lorealbaautomation.bulkInsert;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
|
||||
public class DBProvider extends ContentProvider {
|
||||
private static final UriMatcher sUriMatcher = buildUriMatcher();
|
||||
private DBHelper mDBHelper;
|
||||
private Context mContext;
|
||||
static final int USER = 100;
|
||||
|
||||
static UriMatcher buildUriMatcher() {
|
||||
|
||||
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
final String authority = DBContract.CONTENT_AUTHORITY;
|
||||
|
||||
matcher.addURI(authority, DBContract.PATH_USER, USER);
|
||||
|
||||
return matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
mDBHelper = new DBHelper(getContext());
|
||||
return false;
|
||||
}
|
||||
|
||||
public void PeaberryProvider(Context context) {
|
||||
mDBHelper = DBHelper.getInstance(context);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
// determine what type of Uri is
|
||||
final int match = sUriMatcher.match(uri);
|
||||
|
||||
switch (match) {
|
||||
case USER:
|
||||
return DBContract.UserEntry.CONTENT_TYPE;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("Uri unknown: " + uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[]
|
||||
selectionArgs, String sortOrder) {
|
||||
Cursor retCursor;
|
||||
try {
|
||||
switch (sUriMatcher.match(uri)) {
|
||||
case USER: {
|
||||
retCursor = mDBHelper.getReadableDatabase().query(
|
||||
DBContract.UserEntry.TABLE_NAME,
|
||||
projection,
|
||||
selection,
|
||||
selectionArgs,
|
||||
null,
|
||||
null,
|
||||
sortOrder
|
||||
);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new UnsupportedOperationException("Uri unknown: " + uri);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//test("Cursor", ex.toString());
|
||||
} finally {
|
||||
mDBHelper.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
final SQLiteDatabase db = mDBHelper.getWritableDatabase();
|
||||
final int match = sUriMatcher.match(uri);
|
||||
Uri returnUri;
|
||||
try {
|
||||
|
||||
switch (match) {
|
||||
case USER: {
|
||||
long _id = db.insert(DBContract.UserEntry.TABLE_NAME, null, values);
|
||||
if (_id > 0)
|
||||
returnUri = DBContract.UserEntry.buildUri(_id);
|
||||
else
|
||||
throw new android.database.SQLException("Error at inserting row in " + uri);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new UnsupportedOperationException("Uri unknown: " + uri);
|
||||
}
|
||||
mContext.getContentResolver().notifyChange(uri, null);
|
||||
return returnUri;
|
||||
} catch (Exception ex) {
|
||||
//test("Insert", ex.toString());
|
||||
db.close();
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
try (SQLiteDatabase db = DBHelper.getInstance(mContext).getWritableDatabase()) {
|
||||
final int match = sUriMatcher.match(uri);
|
||||
int deletedRows;
|
||||
if (null == selection) selection = "1";
|
||||
try {
|
||||
switch (match) {
|
||||
case USER:
|
||||
deletedRows = db.delete(
|
||||
DBContract.UserEntry.TABLE_NAME, selection, selectionArgs);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Uri unknown: " + uri);
|
||||
}
|
||||
if (deletedRows != 0) {
|
||||
mContext.getContentResolver().notifyChange(uri, null);
|
||||
}
|
||||
return deletedRows;
|
||||
} catch (Exception ex) {
|
||||
//test("Insert", ex.toString());
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
final SQLiteDatabase db = mDBHelper.getWritableDatabase();
|
||||
final int match = sUriMatcher.match(uri);
|
||||
int updatedRows;
|
||||
try {
|
||||
switch (match) {
|
||||
case USER:
|
||||
updatedRows = db.update(DBContract.UserEntry.TABLE_NAME, values, selection, selectionArgs);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Uri unknown: " + uri);
|
||||
}
|
||||
if (updatedRows != 0) {
|
||||
mContext.getContentResolver().notifyChange(uri, null);
|
||||
}
|
||||
return updatedRows;
|
||||
} catch (Exception ex) {
|
||||
//test("Update", ex.toString());
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+1534
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,113 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.cpm.lorealbaautomation.download.DownloadActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* Created by jeevanp on 14-12-2017.
|
||||
*/
|
||||
|
||||
public class AlertandMessages {
|
||||
public static final String MESSAGE_SOCKETEXCEPTION = "Network Communication Failure. Check Your Network Connection";
|
||||
public static void showAlert(final Activity activity, String str, final Boolean activityFinish) {
|
||||
try {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
|
||||
if (activityFinish) {
|
||||
activity.finish();
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showAlertfordatanotSyncedcompeletetly(final Activity activity, String str, final Boolean activityFinish) {
|
||||
try {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
|
||||
if (activityFinish) {
|
||||
activity.finish();
|
||||
activity.startActivity(new Intent(activity, DownloadActivity.class).putExtra(CommonString.TAG_FROM, 1));
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void showAlertlogin(final Activity activity, String str) {
|
||||
try {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, id) -> dialog.dismiss());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showAlertCounterlogin(final Activity activity, String str) {
|
||||
try {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
|
||||
dialog.dismiss();
|
||||
activity.finish();
|
||||
|
||||
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void showToastMsg(Context context, String message) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public static void showSnackbarMsg(Context context, String message) {
|
||||
Snackbar.make(Objects.requireNonNull(((Activity) context).getCurrentFocus()), message, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void backpressedAlert(final Activity activity) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Alert");
|
||||
builder.setMessage("Do you want to exit? Filled data will be lost").setCancelable(false)
|
||||
.setPositiveButton("Ok", (dialog, id) -> activity.finish());
|
||||
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,755 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.ProductMaster;
|
||||
import com.cpm.lorealbaautomation.retrofit.DownloadAllDatawithRetro;
|
||||
import com.cpm.lorealbaautomation.upload.UploadKeyData;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.github.memfis19.annca.Annca;
|
||||
import io.github.memfis19.annca.internal.configuration.AnncaConfiguration;
|
||||
|
||||
/**
|
||||
* Created by jeevanp on 2/16/2017.
|
||||
*/
|
||||
|
||||
public class CommonFunctions {
|
||||
public static boolean checkNetIsAvailable(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
public static boolean isValidEmail(CharSequence target) {
|
||||
return !TextUtils.isEmpty(target) && Patterns.EMAIL_ADDRESS.matcher(target).matches();
|
||||
}
|
||||
|
||||
public static void startAnncaCameraActivity(final Context context, final String path, Fragment fragment, final boolean showGrid, final int cameraFace) {
|
||||
if (context != null) {
|
||||
final AnncaConfiguration.Builder dialogDemo = getBuilder((Activity) context, fragment, cameraFace);
|
||||
final Dialog dialog = new Dialog(context);
|
||||
dialog.setContentView(R.layout.view_horizontal_camera);
|
||||
dialog.setCancelable(false);
|
||||
if (!dialog.isShowing()) {
|
||||
dialog.show();
|
||||
}
|
||||
new Handler().postDelayed(() -> {
|
||||
if (dialog.isShowing()) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
new Annca(dialogDemo.build()).launchCamera(path, showGrid, cameraFace);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static AnncaConfiguration.Builder getBuilder(Activity context, Fragment fragment, int cameraFace) {
|
||||
final AnncaConfiguration.Builder dialogDemo;
|
||||
if (fragment == null) {
|
||||
dialogDemo = new AnncaConfiguration.Builder(context, CommonString.CAPTURE_MEDIA);
|
||||
} else {
|
||||
dialogDemo = new AnncaConfiguration.Builder(fragment, CommonString.CAPTURE_MEDIA);
|
||||
}
|
||||
dialogDemo.setMediaAction(AnncaConfiguration.MEDIA_ACTION_PHOTO);
|
||||
dialogDemo.setCameraFace(cameraFace);
|
||||
dialogDemo.setMediaResultBehaviour(AnncaConfiguration.PREVIEW);
|
||||
return dialogDemo;
|
||||
}
|
||||
|
||||
public static void setScaledImage(ImageView imageView, final String path) {
|
||||
final ImageView iv = imageView;
|
||||
ViewTreeObserver viewTreeObserver = iv.getViewTreeObserver();
|
||||
viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
public boolean onPreDraw() {
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
int imageViewHeight = iv.getMeasuredHeight();
|
||||
int imageViewWidth = iv.getMeasuredWidth();
|
||||
iv.setImageBitmap(decodeSampledBitmapFromPath(path, imageViewWidth, imageViewHeight));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Bitmap decodeSampledBitmapFromPath(String path, int reqWidth, int reqHeight) {
|
||||
// First decode with inJustDecodeBounds = true to check dimensions
|
||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
//BitmapFactory.decodeResource(res, resId, options);
|
||||
BitmapFactory.decodeFile(path, options);
|
||||
// Calculate inSampleSize
|
||||
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
|
||||
// Decode bitmap with inSampleSize set
|
||||
options.inJustDecodeBounds = false;
|
||||
return BitmapFactory.decodeFile(path, options);
|
||||
}
|
||||
|
||||
private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
||||
// Raw height and width of image_icon
|
||||
final int height = options.outHeight;
|
||||
final int width = options.outWidth;
|
||||
int inSampleSize = 1;
|
||||
if (height > reqHeight || width > reqWidth) {
|
||||
final int halfHeight = height / 2;
|
||||
final int halfWidth = width / 2;
|
||||
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
|
||||
// height and width larger than the requested height and width.
|
||||
while ((halfHeight / inSampleSize) > reqHeight && (halfWidth / inSampleSize) > reqWidth) {
|
||||
inSampleSize *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
return inSampleSize;
|
||||
}
|
||||
|
||||
public static String getCurrentTimeHHMMSS() {
|
||||
Calendar m_cal = Calendar.getInstance();
|
||||
return m_cal.get(Calendar.HOUR_OF_DAY) + "" + m_cal.get(Calendar.MINUTE) + "" + m_cal.get(Calendar.SECOND);
|
||||
}
|
||||
|
||||
|
||||
public static String setMetadataAtImages(String store_Nm, String store_Id, String type, String userId) {
|
||||
return "Store Name : " + store_Nm + " | Store Id : " + store_Id + " " + " | Merchandiser Id : " + userId + " | Image Type : " + type;
|
||||
}
|
||||
|
||||
|
||||
public static String setMetadataAtImagesforwindow(String store_Nm, String store_Id, String window_cd, String type, String userId) {
|
||||
return "Store Name : " + store_Nm + " | Store Id : " + store_Id + " " + " | Window Id : " + window_cd + " | Merchandiser Id : " + userId + " | Image Type : " + type;
|
||||
}
|
||||
|
||||
public static String setMetadataAtImagesforvisitorstorewise(String store_Nm, String store_Id, String visitor_nm, String type, String userId) {
|
||||
return "Store Name : " + store_Nm + " | Store Id : " + store_Id + " " + " | Visitor Name : " + visitor_nm + " | Merchandiser Id : " + userId + " | Image Type : " + type;
|
||||
}
|
||||
|
||||
public static String setMetadataAtImagesforvisitor(String visitor_nm, String type, String userId) {
|
||||
return "Visitor Name : " + visitor_nm + " | Merchandiser Id : " + userId + " | Image Type : " + type;
|
||||
}
|
||||
|
||||
public static String setMetadataAtImagesdpreporting(String type, String userId) {
|
||||
String ss = "Merchandiser Id : " + userId + " | Image Type : " + type;
|
||||
return ss;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap addMetadataAndTimeStampToImage(Context context, final String path, String metadata, String visit_date) {
|
||||
Bitmap bmp1 = BitmapFactory.decodeFile(path);
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.preview_image, null);
|
||||
view.layout(0, 0, bmp1.getWidth(), bmp1.getHeight());
|
||||
Bitmap bmp = getViewBitmap(view, bmp1, path, metadata, visit_date);
|
||||
try {
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File(path)));
|
||||
return bmp;
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.fillInStackTrace();
|
||||
FirebaseCrashlytics.getInstance().recordException(e);
|
||||
return bmp1;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static Bitmap getViewBitmap(View view, Bitmap bmp, String path, String metadata, String visit_date) {
|
||||
//Get the dimensions of the view so we can re-layout the view at its current size
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
|
||||
String dateTime = sdf.format(Calendar.getInstance().getTime());
|
||||
String copm = dateTime;
|
||||
ImageView temp_img = (ImageView) view.findViewById(R.id.temp_img);
|
||||
TextView storeM = (TextView) view.findViewById(R.id.storeM);
|
||||
int copleteValue = 0;
|
||||
try {
|
||||
copm = copm.replaceAll("[- ]", " ");
|
||||
String[] items = copm.split(":");
|
||||
String seconds = items[2];
|
||||
int lastIndex;
|
||||
lastIndex = Integer.parseInt(seconds);
|
||||
int day = Integer.parseInt(visit_date.substring(3, 5));
|
||||
int a = Integer.parseInt("10") * Integer.parseInt("40");
|
||||
a = a + day;
|
||||
lastIndex = lastIndex * 2;
|
||||
copleteValue = a + lastIndex;
|
||||
} catch (NumberFormatException e) {
|
||||
FirebaseCrashlytics.getInstance().recordException(e);
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
//timestamp on image_icon
|
||||
Bitmap dest = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas cs = new Canvas(dest);
|
||||
Paint tPaint = new Paint();
|
||||
tPaint.setTextSize(27);
|
||||
tPaint.setColor(Color.RED);
|
||||
tPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
cs.drawBitmap(bmp, 0f, 0f, null);
|
||||
float height_ = tPaint.measureText("yY");
|
||||
cs.drawText(dateTime + "[" + "10" + "] " + (copleteValue), 20f, height_ + 15f, tPaint);
|
||||
try {
|
||||
dest.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File(path)));
|
||||
} catch (FileNotFoundException e) {
|
||||
FirebaseCrashlytics.getInstance().recordException(e);
|
||||
// TODO Auto-generated catch block
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
storeM.setText(metadata + " | Date : " + dateTime + "[" + "10" + "] " + (copleteValue));
|
||||
bmp = BitmapFactory.decodeFile(path);
|
||||
temp_img.setImageBitmap(bmp);
|
||||
int width = bmp.getWidth();
|
||||
int height = bmp.getHeight();
|
||||
int measuredWidth = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
|
||||
int measuredHeight = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
|
||||
//Cause the view to re-layout
|
||||
view.measure(measuredWidth, measuredHeight);
|
||||
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||
//Create a bitmap backed Canvas to draw the view into
|
||||
Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(b);
|
||||
view.draw(c);
|
||||
return b;
|
||||
}
|
||||
|
||||
public static String getCurrentTime() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat mdformat = new SimpleDateFormat("HH:mm:ss");
|
||||
return mdformat.format(calendar.getTime());
|
||||
}
|
||||
|
||||
public static String getCurrentTime_only() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat mdformat = new SimpleDateFormat("HH:mm:ss");
|
||||
return mdformat.format(calendar.getTime());
|
||||
}
|
||||
|
||||
public static String getUUID(Context context) {
|
||||
SharedPreferences preferences = PrefHelper.getPrefs(context);
|
||||
String counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
return counter_id + "_" + UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public static boolean isTablet(Context context) {
|
||||
boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
|
||||
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
|
||||
return (xlarge || large);
|
||||
}
|
||||
|
||||
public static void show_image_preview(Context context, String img_name) {
|
||||
final Bitmap bmp = BitmapFactory.decodeFile(CommonString.getImagesFolder(context) + img_name);
|
||||
final Dialog dialog = new Dialog(context);
|
||||
//setting custom layout---------------------------- to dialog
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.custom_dialog_preview);
|
||||
Button cancel_btn = (Button) dialog.findViewById(R.id.cancel_btn);
|
||||
ImageView img_addit = (ImageView) dialog.findViewById(R.id.img_addit);
|
||||
img_addit.setImageBitmap(bmp);
|
||||
cancel_btn.setOnClickListener(v -> dialog.dismiss());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static String convert24to12(String loginTym) {
|
||||
String strTym = "";
|
||||
try {
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat simpleDate = new SimpleDateFormat("HH");
|
||||
Date date = simpleDate.parse(loginTym);
|
||||
assert date != null;
|
||||
simpleDate.format(date);
|
||||
Calendar calander = Calendar.getInstance();
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh");
|
||||
strTym = simpleDateFormat.format(calander.getTime());
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
return strTym;
|
||||
}
|
||||
|
||||
public static String setTimeFormat(String start_dt) {
|
||||
//test("xxxd" + start_dt);
|
||||
String newvalue = "";
|
||||
try {
|
||||
if (!start_dt.isEmpty()) {
|
||||
String s[] = start_dt.split(":");
|
||||
//test("time-----------------" + s[0] + "parseint" + Integer.parseInt(s[0]));
|
||||
int t = Integer.parseInt(s[0]);
|
||||
//test("vv....." + t);
|
||||
if (t < 12) {
|
||||
s[0] = Integer.valueOf(s[0]).toString();
|
||||
if (Integer.parseInt(s[0]) < 10 && s[0].length() == 0) {
|
||||
newvalue = "0" + s[0] + ":" + s[1] + ":" + s[2];
|
||||
} else {
|
||||
newvalue = s[0] + ":" + s[1] + ":" + s[2];
|
||||
}
|
||||
//test("value..." + newvalue);
|
||||
} else {
|
||||
int time = Integer.parseInt(s[0]) - 12;
|
||||
if (time < 10) {
|
||||
newvalue = "0" + time + ":" + s[1] + ":" + s[2];
|
||||
} else {
|
||||
newvalue = "0" + time + ":" + s[1] + ":" + s[2];
|
||||
}
|
||||
|
||||
//test("value..." + newvalue);
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return newvalue;
|
||||
}
|
||||
|
||||
public static File saveBitmapToFile(File file) {
|
||||
File file2 = file;
|
||||
try {
|
||||
int inWidth = 0;
|
||||
int inHeight = 0;
|
||||
InputStream in = new FileInputStream(file2);
|
||||
// decode image size (decode metadata only, not the whole image)
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeStream(in, null, options);
|
||||
in.close();
|
||||
in = null;
|
||||
// save width and height
|
||||
inWidth = options.outWidth;
|
||||
inHeight = options.outHeight;
|
||||
// decode full image pre-resized
|
||||
in = new FileInputStream(file2);
|
||||
options = new BitmapFactory.Options();
|
||||
// calc rought re-size (this is no exact resize)
|
||||
options.inSampleSize = Math.max(inWidth / 800, inHeight / 500);
|
||||
// decode full image
|
||||
Bitmap roughBitmap = BitmapFactory.decodeStream(in, null, options);
|
||||
if (roughBitmap == null) {
|
||||
return null;
|
||||
}
|
||||
// calc exact destination size
|
||||
Matrix m = new Matrix();
|
||||
RectF inRect = new RectF(0, 0, roughBitmap.getWidth(), roughBitmap.getHeight());
|
||||
RectF outRect = new RectF(0, 0, 800, 500);
|
||||
m.setRectToRect(inRect, outRect, Matrix.ScaleToFit.CENTER);
|
||||
float[] values = new float[9];
|
||||
m.getValues(values);
|
||||
// resize bitmap
|
||||
Bitmap resizedBitmap = Bitmap.createScaledBitmap(roughBitmap, (int) (roughBitmap.getWidth() * values[0]), (int) (roughBitmap.getHeight() * values[4]), true);
|
||||
// save image
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(file2);
|
||||
resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
|
||||
} catch (Exception e) {
|
||||
//test("Image", e.toString(), e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//test("Image", e.toString(), e);
|
||||
return file2;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public static Bitmap getResizedBitmap(Bitmap image, int maxSize) {
|
||||
int width = 0, height = 0;
|
||||
try {
|
||||
if (image != null) {
|
||||
width = image.getWidth();
|
||||
height = image.getHeight();
|
||||
|
||||
if (maxSize != 0 && width != 0 && height != 0) {
|
||||
float bitmapRatio = (float) width / (float) height;
|
||||
if (bitmapRatio > 1) {
|
||||
width = maxSize;
|
||||
height = (int) (width / bitmapRatio);
|
||||
} else {
|
||||
height = maxSize;
|
||||
width = (int) (height * bitmapRatio);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
assert image != null;
|
||||
return Bitmap.createScaledBitmap(image, width, height, true);
|
||||
}
|
||||
|
||||
public static Bitmap getCroppedBitmap(Bitmap bitmap) {
|
||||
Bitmap output = null;
|
||||
|
||||
try {
|
||||
if (bitmap != null) {
|
||||
if (bitmap.getWidth() > bitmap.getHeight()) {
|
||||
output = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
} else {
|
||||
output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getWidth(), Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
Canvas canvas = new Canvas(output);
|
||||
final int color = 0xff424242;
|
||||
final Paint paint = new Paint();
|
||||
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
|
||||
float r = 0;
|
||||
if (bitmap.getWidth() > bitmap.getHeight()) {
|
||||
r = (float) bitmap.getHeight() / 2;
|
||||
} else {
|
||||
r = (float) bitmap.getWidth() / 2;
|
||||
}
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
paint.setColor(color);
|
||||
canvas.drawCircle(r, r, r, paint);
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmap, rect, rect, paint);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static void show_incurrect_device_tym(final Context context, String serverTym) {
|
||||
if (context != null) {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
//setting custom layout---------------------------- to dialog
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.dialog_incurrect_tym);
|
||||
dialog.setCancelable(false);
|
||||
Button cancel_btn = (Button) dialog.findViewById(R.id.cancel_btn);
|
||||
TextView txt_serverTym = (TextView) dialog.findViewById(R.id.txt_serverTym);
|
||||
txt_serverTym.setText("Server Time : " + serverTym);
|
||||
|
||||
cancel_btn.setOnClickListener(v -> {
|
||||
context.startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static void delete_old_imge_from_folder(Context context, String visit_date, Lorealba_Database db) {
|
||||
db.open();
|
||||
try {
|
||||
if (db.CheckPreviousProduct(visit_date)) {
|
||||
File f = new File(CommonString.getImagesFolder(context));
|
||||
final File[] file = f.listFiles();
|
||||
if (file != null && file.length > 0) {
|
||||
String filename = "";
|
||||
for (File value : file) {
|
||||
filename = value.getName();
|
||||
if (filename.contains("_counter_img_one_") || filename.contains("_counter_img_two_") || filename.contains("_cp_img_one_") || filename.contains("_cp_img_two_") || filename.contains("_groomed_img_mrng_") || filename.contains("_groomed_img_noon_") || filename.contains("_groomed_img_evning_")) {
|
||||
File originalFile = new File(CommonString.getImagesFolder(context) + value.getName());
|
||||
if (originalFile.isFile() && originalFile.exists())
|
||||
originalFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetServerTym(Context context, String user_name, Lorealba_Database db) {
|
||||
try {
|
||||
ArrayList<String> keysList = new ArrayList<>();
|
||||
ArrayList<String> jsonList = new ArrayList<>();
|
||||
ArrayList<String> KeyNames = new ArrayList<>();
|
||||
keysList.add("ServerTime");
|
||||
for (int i = 0; i < keysList.size(); i++) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("Downloadtype", keysList.get(i));
|
||||
jsonObject.put("Username", user_name);
|
||||
jsonObject.put("Param1", "");
|
||||
jsonObject.put("Param2", "");
|
||||
jsonList.add(jsonObject.toString());
|
||||
KeyNames.add(keysList.get(i));
|
||||
}
|
||||
|
||||
if (!jsonList.isEmpty()) {
|
||||
ProgressDialog pd = new ProgressDialog(context);
|
||||
DownloadAllDatawithRetro downloadData = new DownloadAllDatawithRetro(context, db, pd, CommonString.TAG_FROM_CURRENT);
|
||||
downloadData.listSize = jsonList.size();
|
||||
downloadData.downloadDataUniversalBa(jsonList, KeyNames, 0, CommonString.DOWNLOAD_ALL_SERVICE);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String removeFirstChar(String s) {
|
||||
String str = "";
|
||||
try {
|
||||
str = s.substring(1);
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
return str;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void call_upload(Context context) {
|
||||
if (checkNetIsAvailable(context)) {
|
||||
context.startActivity(new Intent(context, UploadKeyData.class).putExtra(CommonString.TAG_OBJECT, "1"));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkincomplete_upload_data(String visit_date, String counter_id, Lorealba_Database db, boolean previous_date) {
|
||||
boolean status = true;
|
||||
try {
|
||||
if (!db.getBaProfileListData(visit_date, counter_id, previous_date).isEmpty()) {
|
||||
status = false;
|
||||
} else if (!db.getCounterProfileListData(visit_date, counter_id, previous_date).isEmpty()) {
|
||||
status = false;
|
||||
} else if (!db.getme_quiz_from(visit_date, counter_id, previous_date).isEmpty()) {
|
||||
status = false;
|
||||
} else if (!db.getgroomingdata(counter_id, visit_date, previous_date).isEmpty()) {
|
||||
status = false;
|
||||
} else if (!db.getba_counterimgList(counter_id, visit_date, previous_date).isEmpty()) {
|
||||
status = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public static String removed_special_char(EditText common_edt) {
|
||||
String value_edt = "";
|
||||
try {
|
||||
if (common_edt.getText().toString().contains("[/;(!@#$%^&*?)\"]")) {
|
||||
value_edt = common_edt.getText().toString().trim().replaceAll("[/;(!@#$%^&*?)\"]", "");
|
||||
} else {
|
||||
value_edt = common_edt.getText().toString().trim();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return value_edt;
|
||||
}
|
||||
|
||||
public static int mod(int x, int y) {
|
||||
int result = 0;
|
||||
try {
|
||||
result = x % y;
|
||||
if (result < 0) result += y;
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getCountOfDays(String fromDate, String toDate) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
|
||||
Date createdConvertedDate = null, expireCovertedDate = null, todayWithZeroTime = null;
|
||||
try {
|
||||
createdConvertedDate = dateFormat.parse(fromDate);
|
||||
expireCovertedDate = dateFormat.parse(toDate);
|
||||
|
||||
Date today = new Date();
|
||||
|
||||
todayWithZeroTime = dateFormat.parse(dateFormat.format(today));
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
int cYear = 0, cMonth = 0, cDay = 0;
|
||||
|
||||
assert createdConvertedDate != null;
|
||||
if (createdConvertedDate.after(todayWithZeroTime)) {
|
||||
Calendar cCal = Calendar.getInstance();
|
||||
cCal.setTime(createdConvertedDate);
|
||||
cYear = cCal.get(Calendar.YEAR);
|
||||
cMonth = cCal.get(Calendar.MONTH);
|
||||
cDay = cCal.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
} else {
|
||||
Calendar cCal = Calendar.getInstance();
|
||||
assert todayWithZeroTime != null;
|
||||
cCal.setTime(todayWithZeroTime);
|
||||
cYear = cCal.get(Calendar.YEAR);
|
||||
cMonth = cCal.get(Calendar.MONTH);
|
||||
cDay = cCal.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
Calendar eCal = Calendar.getInstance();
|
||||
assert expireCovertedDate != null;
|
||||
eCal.setTime(expireCovertedDate);
|
||||
|
||||
int eYear = eCal.get(Calendar.YEAR);
|
||||
int eMonth = eCal.get(Calendar.MONTH);
|
||||
int eDay = eCal.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
Calendar date1 = Calendar.getInstance();
|
||||
Calendar date2 = Calendar.getInstance();
|
||||
|
||||
date1.clear();
|
||||
date1.set(cYear, cMonth, cDay);
|
||||
date2.clear();
|
||||
date2.set(eYear, eMonth, eDay);
|
||||
|
||||
long diff = date2.getTimeInMillis() - date1.getTimeInMillis();
|
||||
|
||||
float dayCount = (float) diff / (24 * 60 * 60 * 1000);
|
||||
|
||||
return ((int) dayCount + " Days");
|
||||
}
|
||||
|
||||
public static void hideKeyboard(Activity activity) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
//Find the currently focused view, so we can grab the correct window token from it.
|
||||
View view = activity.getCurrentFocus();
|
||||
//If no view currently has focus, create a new one, just so we can grab a window token from it
|
||||
if (view == null) {
|
||||
view = new View(activity);
|
||||
}
|
||||
if (imm.isAcceptingText()) imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
public static String capitalizeFirstLetter(String input) {
|
||||
if (input == null || input.isEmpty()) {
|
||||
return input;
|
||||
}
|
||||
return input.substring(0, 1).toUpperCase() + input.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
public static void dismissKeyboard(View view) {
|
||||
try {
|
||||
if (view != null) {
|
||||
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<ProductMaster> getFilters() {
|
||||
ArrayList<ProductMaster> listSubAxe = new ArrayList<>();
|
||||
try {
|
||||
ProductMaster obj = new ProductMaster();
|
||||
obj.setSubAxeName("Axe");
|
||||
listSubAxe.add(obj);
|
||||
|
||||
obj = new ProductMaster();
|
||||
obj.setSubAxeName("Sub Axe");
|
||||
listSubAxe.add(obj);
|
||||
|
||||
obj = new ProductMaster();
|
||||
obj.setSubAxeName("Signature");
|
||||
listSubAxe.add(obj);
|
||||
|
||||
obj = new ProductMaster();
|
||||
obj.setSubAxeName("Sub Brand");
|
||||
listSubAxe.add(obj);
|
||||
|
||||
obj = new ProductMaster();
|
||||
obj.setSubAxeName("Brand");
|
||||
listSubAxe.add(obj);
|
||||
|
||||
obj = new ProductMaster();
|
||||
obj.setSubAxeName("Product");
|
||||
listSubAxe.add(obj);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return listSubAxe;
|
||||
}
|
||||
|
||||
public static String formatDate(String inputDate) {
|
||||
// Check if the device supports java.time (API 26+)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
// Input date format (MM/dd/yyyy)
|
||||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy", Locale.ENGLISH);
|
||||
// Desired output date format (MMMM dd, yyyy)
|
||||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("MMM dd, yyyy", Locale.ENGLISH);
|
||||
|
||||
// Parse the input date string
|
||||
LocalDate date = LocalDate.parse(inputDate, inputFormatter);
|
||||
|
||||
// Return formatted date
|
||||
return date.format(outputFormatter);
|
||||
|
||||
} else {
|
||||
// For older Android versions (below API 26)
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH);
|
||||
try {
|
||||
// Parse the input date string
|
||||
Date date = inputFormat.parse(inputDate);
|
||||
// Format the date to the desired output
|
||||
assert date != null;
|
||||
return outputFormat.format(date);
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
return null; // Return null if parsing fails
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,212 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileUtils {
|
||||
//replace this with your authority
|
||||
public static final String AUTHORITY = "com.ianhanniballake.localstorage.documents";
|
||||
|
||||
private FileUtils() {
|
||||
} //private constructor to enforce Singleton pattern
|
||||
|
||||
/**
|
||||
* TAG for log messages.
|
||||
*/
|
||||
private static final boolean DEBUG = false; // Set to true to enable logging
|
||||
|
||||
|
||||
/**
|
||||
* @return Whether the URI is a local one.
|
||||
*/
|
||||
public static boolean isLocal(String url) {
|
||||
if (url != null && !url.startsWith("http://") && !url.startsWith("https://")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isLocalStorageDocument(Uri uri) {
|
||||
return AUTHORITY.equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||
* @author paulburke
|
||||
*/
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is DownloadsProvider.
|
||||
* @author paulburke
|
||||
*/
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is MediaProvider.
|
||||
* @author paulburke
|
||||
*/
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is Google Photos.
|
||||
*/
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
*
|
||||
* @param context The context.
|
||||
* @param uri The Uri to query.
|
||||
* @param selection (Optional) Filter used in the query.
|
||||
* @param selectionArgs (Optional) Selection arguments used in the query.
|
||||
* @return The value of the _data column, which is typically a file path.
|
||||
* @author paulburke
|
||||
*/
|
||||
public static String getDataColumn(Context context, Uri uri, String selection,
|
||||
String[] selectionArgs) {
|
||||
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = {
|
||||
column
|
||||
};
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
|
||||
null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
if (DEBUG)
|
||||
DatabaseUtils.dumpCursor(cursor);
|
||||
|
||||
final int column_index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(column_index);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file path from a Uri. This will get the the path for Storage Access
|
||||
* Framework Documents, as well as the _data field for the MediaStore and
|
||||
* other file-based ContentProviders.<br>
|
||||
* <br>
|
||||
* Callers should check whether the path is local before assuming it
|
||||
* represents a local file.
|
||||
*
|
||||
* @param context The context.
|
||||
* @param uri The Uri to query.
|
||||
* @author paulburke
|
||||
* @see #isLocal(String)
|
||||
* @see #getFile(Context, Uri)
|
||||
*/
|
||||
public static String getPath(final Context context, final Uri uri) {
|
||||
// DocumentProvider
|
||||
if (DocumentsContract.isDocumentUri(context, uri)) {
|
||||
// LocalStorageProvider
|
||||
if (isLocalStorageDocument(uri)) {
|
||||
// The path is the id
|
||||
return DocumentsContract.getDocumentId(uri);
|
||||
}
|
||||
// ExternalStorageProvider
|
||||
else if (isExternalStorageDocument(uri)) {
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
|
||||
// TODO handle non-primary volumes
|
||||
}
|
||||
// DownloadsProvider
|
||||
else if (isDownloadsDocument(uri)) {
|
||||
final String id = DocumentsContract.getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(
|
||||
Uri.parse("content://downloads/public_downloads"), Long.parseLong(id));
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
}
|
||||
// MediaProvider
|
||||
else if (isMediaDocument(uri)) {
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type)) {
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("video".equals(type)) {
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("audio".equals(type)) {
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[]{
|
||||
split[1]
|
||||
};
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
}
|
||||
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||
// Return the remote address
|
||||
if (isGooglePhotosUri(uri))
|
||||
return uri.getLastPathSegment();
|
||||
|
||||
return getDataColumn(context, uri, null, null);
|
||||
}
|
||||
// File
|
||||
else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Uri into File, if possible.
|
||||
*
|
||||
* @return file A local file that the Uri was pointing to, or null if the
|
||||
* Uri is unsupported or pointed to a remote resource.
|
||||
* @author paulburke
|
||||
* @see #getPath(Context, Uri)
|
||||
*/
|
||||
public static File getFile(Context context, Uri uri) {
|
||||
if (uri != null) {
|
||||
String path = getPath(context, uri);
|
||||
if (isLocal(path)) {
|
||||
return new File(path);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
|
||||
|
||||
public class HorizontalProgressBar extends View {
|
||||
// distance between neighbour dot centres
|
||||
private int mDotStep = 20;
|
||||
// actual dot radius
|
||||
private int mDotRadius = 5;
|
||||
// Bounced Dot Radiuslogin
|
||||
private int mBigDotRadius = 8;
|
||||
// to get identified in which position dot has to bounce
|
||||
private int mDotPosition;
|
||||
// specify how many dots you need in a progressbar
|
||||
private static final int MIN_COUNT = 1;
|
||||
private static final int DEF_COUNT = 10;
|
||||
private static final int MAX_COUNT = 100;
|
||||
private int mDotCount = DEF_COUNT;
|
||||
private static final int MIN_TIMEOUT = 100;
|
||||
private static final int DEF_TIMEOUT = 500;
|
||||
private static final int MAX_TIMEOUT = 3000;
|
||||
private int mTimeout = DEF_TIMEOUT;
|
||||
private int mDotColor = Color.parseColor("#fd583f");
|
||||
public HorizontalProgressBar(Context context) {
|
||||
super(context);
|
||||
initDotSize();
|
||||
}
|
||||
|
||||
|
||||
public HorizontalProgressBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initDotSize();
|
||||
applyAttrs(context, attrs);
|
||||
}
|
||||
|
||||
public HorizontalProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initDotSize();
|
||||
applyAttrs(context, attrs);
|
||||
}
|
||||
|
||||
private void initDotSize() {
|
||||
final float scale = getResources().getDisplayMetrics().density;
|
||||
mDotStep = (int)(mDotStep * scale);
|
||||
mDotRadius = (int)(mDotRadius * scale);
|
||||
mBigDotRadius = (int)(mBigDotRadius * scale);
|
||||
}
|
||||
|
||||
private void applyAttrs(Context context, AttributeSet attrs) {
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HorizontalProgressBar, 0, 0);
|
||||
try {
|
||||
mDotColor = a.getColor(R.styleable.HorizontalProgressBar_color, mDotColor);
|
||||
mDotCount = a.getInteger(R.styleable.HorizontalProgressBar_count, mDotCount);
|
||||
mDotCount = Math.min(Math.max(mDotCount, MIN_COUNT), MAX_COUNT);
|
||||
mTimeout = a.getInteger(R.styleable.HorizontalProgressBar_timeout, mTimeout);
|
||||
mTimeout = Math.min(Math.max(mTimeout, MIN_TIMEOUT), MAX_TIMEOUT);
|
||||
} finally {
|
||||
a.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
//Method to draw your customized dot on the canvas
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (isShown()) {
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(mDotColor);
|
||||
createDots(canvas, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
startAnimation();
|
||||
}
|
||||
|
||||
private void createDots(Canvas canvas, Paint paint) {
|
||||
for (int i = 0; i < mDotCount; i++ ) {
|
||||
int radius = (i == mDotPosition) ? mBigDotRadius : mDotRadius;
|
||||
canvas.drawCircle(mDotStep / 2 + (i * mDotStep), mBigDotRadius, radius, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
// MUST CALL THIS
|
||||
setMeasuredDimension(mDotStep * mDotCount, mBigDotRadius * 2);
|
||||
}
|
||||
|
||||
private void startAnimation() {
|
||||
BounceAnimation bounceAnimation = new BounceAnimation();
|
||||
bounceAnimation.setDuration(mTimeout);
|
||||
bounceAnimation.setRepeatCount(Animation.INFINITE);
|
||||
bounceAnimation.setInterpolator(new LinearInterpolator());
|
||||
bounceAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
if (++mDotPosition >= mDotCount) {
|
||||
mDotPosition = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
startAnimation(bounceAnimation);
|
||||
}
|
||||
|
||||
|
||||
private class BounceAnimation extends Animation {
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
// call invalidate to redraw your view again
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
|
||||
public class ImageConverter {
|
||||
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
|
||||
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(output);
|
||||
final int color = 0xff424242;
|
||||
final Paint paint = new Paint();
|
||||
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
final RectF rectF = new RectF(rect);
|
||||
final float roundPx = pixels;
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
paint.setColor(color);
|
||||
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
|
||||
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmap, rect, rect, paint);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class RoundImage extends Drawable {
|
||||
private final Bitmap mBitmap;
|
||||
private final Paint mPaint;
|
||||
private final RectF mRectF;
|
||||
private final int mBitmapWidth=100;
|
||||
private final int mBitmapHeight=100;
|
||||
|
||||
public RoundImage(Bitmap bitmap) {
|
||||
mBitmap = bitmap;
|
||||
mRectF = new RectF();
|
||||
mPaint = new Paint();
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setDither(true);
|
||||
final BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
|
||||
mPaint.setShader(shader);
|
||||
|
||||
/* mBitmapWidth = mBitmap.getWidth();
|
||||
mBitmapHeight = mBitmap.getHeight();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawOval(mRectF, mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
mRectF.set(bounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
if (mPaint.getAlpha() != alpha) {
|
||||
mPaint.setAlpha(alpha);
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
mPaint.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return mBitmapWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return mBitmapHeight;
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean aa) {
|
||||
mPaint.setAntiAlias(aa);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterBitmap(boolean filter) {
|
||||
mPaint.setFilterBitmap(filter);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDither(boolean dither) {
|
||||
mPaint.setDither(dither);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return mBitmap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.cpm.lorealbaautomation.constant;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* Created by desktop-04 on 5/7/16.
|
||||
*/
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public class RoundedImageView extends ImageView
|
||||
{
|
||||
private int borderWidth = 6;
|
||||
private int viewWidth;
|
||||
private int viewHeight;
|
||||
private Bitmap image;
|
||||
private Paint paint;
|
||||
private Paint paintBorder;
|
||||
private BitmapShader shader;
|
||||
|
||||
public RoundedImageView(Context context)
|
||||
{
|
||||
super(context);
|
||||
setup();
|
||||
}
|
||||
|
||||
public RoundedImageView(Context context, AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
setup();
|
||||
}
|
||||
|
||||
public RoundedImageView(Context context, AttributeSet attrs, int defStyle)
|
||||
{
|
||||
super(context, attrs, defStyle);
|
||||
setup();
|
||||
}
|
||||
|
||||
private void setup()
|
||||
{
|
||||
// init paint
|
||||
paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
paintBorder = new Paint();
|
||||
setBorderColor( Color.parseColor("#FFFFFF"));
|
||||
paintBorder.setAntiAlias(true);
|
||||
this.setLayerType(LAYER_TYPE_SOFTWARE, paintBorder);
|
||||
paintBorder.setShadowLayer(4.0f, 0.0f, 2.0f, Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
public void setBorderWidth(int borderWidth)
|
||||
{
|
||||
this.borderWidth = borderWidth;
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
public void setBorderColor(int borderColor)
|
||||
{
|
||||
if (paintBorder != null)
|
||||
paintBorder.setColor(borderColor);
|
||||
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
private void loadBitmap()
|
||||
{
|
||||
BitmapDrawable bitmapDrawable = (BitmapDrawable) this.getDrawable();
|
||||
|
||||
if (bitmapDrawable != null)
|
||||
image = bitmapDrawable.getBitmap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas)
|
||||
{
|
||||
// load the bitmap
|
||||
loadBitmap();
|
||||
|
||||
// init shader
|
||||
if (image != null)
|
||||
{
|
||||
shader = new BitmapShader(Bitmap.createScaledBitmap(image, canvas.getWidth(), canvas.getHeight(), false), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
|
||||
paint.setShader(shader);
|
||||
int circleCenter = viewWidth / 2;
|
||||
|
||||
// circleCenter is the x or y of the view's center
|
||||
// radius is the radius in pixels of the cirle to be drawn
|
||||
// paint contains the shader that will texture the shape
|
||||
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, circleCenter + borderWidth - 4.0f, paintBorder);
|
||||
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, circleCenter - 4.0f, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
||||
{
|
||||
int width = measureWidth(widthMeasureSpec);
|
||||
int height = measureHeight(heightMeasureSpec, widthMeasureSpec);
|
||||
|
||||
viewWidth = width - (borderWidth * 2);
|
||||
viewHeight = height - (borderWidth * 2);
|
||||
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
private int measureWidth(int measureSpec)
|
||||
{
|
||||
int result = 0;
|
||||
int specMode = MeasureSpec.getMode(measureSpec);
|
||||
int specSize = MeasureSpec.getSize(measureSpec);
|
||||
|
||||
if (specMode == MeasureSpec.EXACTLY)
|
||||
{
|
||||
// We were told how big to be
|
||||
result = specSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Measure the text
|
||||
result = viewWidth;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private int measureHeight(int measureSpecHeight, int measureSpecWidth)
|
||||
{
|
||||
int result = 0;
|
||||
int specMode = MeasureSpec.getMode(measureSpecHeight);
|
||||
int specSize = MeasureSpec.getSize(measureSpecHeight);
|
||||
|
||||
if (specMode == MeasureSpec.EXACTLY)
|
||||
{
|
||||
// We were told how big to be
|
||||
result = specSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Measure the text (beware: ascent is a negative number)
|
||||
result = viewHeight;
|
||||
}
|
||||
|
||||
return (result + 2);
|
||||
}
|
||||
}
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
package com.cpm.lorealbaautomation.consumeractivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.InvoiceGetterSetter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConsumerIntractionDetailActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
String counter_id, visit_date, username;
|
||||
private SharedPreferences preferences;
|
||||
ArrayList<InvoiceGetterSetter> invoice_List = new ArrayList<>();
|
||||
InvoiceGetterSetter totalsales = new InvoiceGetterSetter();
|
||||
ImageView btn_saletra_add_performa;
|
||||
TextView count_cst, total_sales, discount_value;
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
RecyclerView sale_tracking_recycle;
|
||||
boolean clicked_flag = false;
|
||||
String from = CommonString.TAG_FROM_BA;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_consumer_intraction_detail);
|
||||
from = getIntent().getStringExtra("from");
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
iduserinterface();
|
||||
String couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
TextView txt_counter_code = (TextView) findViewById(R.id.txt_counter_code);
|
||||
txt_counter_code.setText("Counter Code - " + couter_code + " / Id - " + counter_id);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
setTitle("Consumer Interaction - " + username);
|
||||
}
|
||||
|
||||
private void iduserinterface() {
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
btn_saletra_add_performa = (ImageView) findViewById(R.id.btn_saletra_add_performa);
|
||||
sale_tracking_recycle = (RecyclerView) findViewById(R.id.sale_tracking_recycle);
|
||||
count_cst = (TextView) findViewById(R.id.count_cst);
|
||||
total_sales = (TextView) findViewById(R.id.total_sales);
|
||||
discount_value = (TextView) findViewById(R.id.discount_value);
|
||||
btn_saletra_add_performa.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
invoice_List = db.getsalestrackingListusing_group(counter_id, visit_date, null,from);
|
||||
if (!invoice_List.isEmpty()) {
|
||||
sale_tracking_recycle.setAdapter(new ValueAdapter(context, invoice_List));
|
||||
sale_tracking_recycle.setLayoutManager(new LinearLayoutManager(context));
|
||||
}
|
||||
db.open();
|
||||
totalsales = db.getcst_countandtotal_sale_value(visit_date, counter_id, null,from);
|
||||
db.open();
|
||||
ArrayList<InvoiceGetterSetter> totaldiscount = db.getcst_totaldiscount(visit_date, counter_id, null,from);
|
||||
|
||||
if (totalsales.getCst_count() != null && !totalsales.getCst_count().equals("0")) {
|
||||
count_cst.setText(totalsales.getCst_count());
|
||||
total_sales.setText(totalsales.getTotal_amount());
|
||||
if (!totaldiscount.isEmpty()) {
|
||||
int total_discount = 0;
|
||||
for (int k = 0; k < totaldiscount.size(); k++) {
|
||||
total_discount = total_discount + totaldiscount.get(k).getAplyieddiscountedprice();
|
||||
}
|
||||
discount_value.setText(String.valueOf(total_discount));
|
||||
} else {
|
||||
discount_value.setText("0.0");
|
||||
}
|
||||
} else {
|
||||
count_cst.setText("0");
|
||||
total_sales.setText("0.0");
|
||||
discount_value.setText("0.0");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.btn_saletra_add_performa) {
|
||||
startActivity(new Intent(context, ConsumerUserDetailsActivity.class).putExtra(CommonString.TAG_MODE, "1").putExtra("from",from));
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
if (clicked_flag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id1) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
ConsumerIntractionDetailActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id12) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
ConsumerIntractionDetailActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (clicked_flag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
ConsumerIntractionDetailActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
ConsumerIntractionDetailActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private class ValueAdapter extends RecyclerView.Adapter<ValueAdapter.MyViewHolder> {
|
||||
LayoutInflater inflator;
|
||||
List<InvoiceGetterSetter> data;
|
||||
|
||||
public ValueAdapter(Context context, List<InvoiceGetterSetter> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.details_consumer_list, parent, false);
|
||||
return new ValueAdapter.MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
|
||||
final InvoiceGetterSetter current = data.get(position);
|
||||
if (current.isPos_sale_flag()) {
|
||||
if (!current.getStr_upload_status().isEmpty() && !current.getStr_upload_status().equalsIgnoreCase(CommonString.KEY_N)) {
|
||||
holder.pos_icon.setImageResource(R.mipmap.upload_tick);
|
||||
} else {
|
||||
holder.pos_icon.setImageResource(R.mipmap.not_upload);
|
||||
}
|
||||
holder.pos_icon.setVisibility(View.VISIBLE);
|
||||
holder.pos_icon.setId(position);
|
||||
} else {
|
||||
holder.pos_icon.setVisibility(View.VISIBLE);
|
||||
holder.pos_icon.setId(position);
|
||||
}
|
||||
|
||||
if (checkdemovalidation(current) && current.getProduct_sold_str().equalsIgnoreCase("No")) {
|
||||
holder.demo_icon.setVisibility(View.VISIBLE);
|
||||
holder.demo_icon.setId(position);
|
||||
holder.sale_icon.setVisibility(View.INVISIBLE);
|
||||
holder.sale_icon.setId(position);
|
||||
} else if (!checkdemovalidation(current) && current.getProduct_sold_str().equalsIgnoreCase("Yes")) {
|
||||
holder.demo_icon.setVisibility(View.INVISIBLE);
|
||||
holder.demo_icon.setId(position);
|
||||
holder.sale_icon.setVisibility(View.VISIBLE);
|
||||
holder.sale_icon.setId(position);
|
||||
} else if (checkdemovalidation(current) && current.getProduct_sold_str().equalsIgnoreCase("Yes")) {
|
||||
holder.demo_icon.setVisibility(View.VISIBLE);
|
||||
holder.demo_icon.setId(position);
|
||||
holder.sale_icon.setVisibility(View.VISIBLE);
|
||||
holder.sale_icon.setId(position);
|
||||
} else {
|
||||
holder.demo_icon.setVisibility(View.INVISIBLE);
|
||||
holder.demo_icon.setId(position);
|
||||
holder.sale_icon.setVisibility(View.INVISIBLE);
|
||||
holder.sale_icon.setId(position);
|
||||
}
|
||||
|
||||
holder.sale_trcking_name.setText(current.getCustomer_name() + " - Mobile No. : " + current.getMobile_no());
|
||||
holder.sale_trcking_name.setId(position);
|
||||
|
||||
holder.sales_count.setText("Count : " + current.getQuantity());
|
||||
holder.sales_count.setId(position);
|
||||
|
||||
holder.sale_total_amount.setText("Total Amount : " + current.getTotal_amount());
|
||||
holder.sale_total_amount.setId(position);
|
||||
|
||||
holder.discountedRs.setText("Discounted Rs : " + current.getAplyieddiscountedprice());
|
||||
holder.discountedRs.setId(position);
|
||||
|
||||
holder.sale_card.setOnClickListener(v -> {
|
||||
if (!current.isPos_sale_flag()) {
|
||||
db.open();
|
||||
startActivity(new Intent(context, ConsumerUserDetailsActivity.class)
|
||||
.putExtra(CommonString.TAG_OBJECT,
|
||||
db.getsalesTrackingByUserMobile(current.getReccept_count(), current.getMobile_no(),
|
||||
visit_date, counter_id, current.getUserName()))
|
||||
.putExtra(CommonString.Key_For_Pos_Enable_With_Showing_Invoice, "1")
|
||||
.putExtra(CommonString.Key_For_Consumer_Update, "1").putExtra("from",from));
|
||||
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
db.open();
|
||||
if (current.getProduct_sold_str().equalsIgnoreCase("Yes")) {
|
||||
startActivity(new Intent(context, InvoiceReportProformaActivity.class)
|
||||
.putExtra(CommonString.TAG_OBJECT, db.getsalesTrackingByUserMobile(current.getReccept_count(),
|
||||
current.getMobile_no(), visit_date, counter_id, current.getUserName()))
|
||||
.putExtra(CommonString.Key_For_Disable_POS_And_Save, "1")
|
||||
.putExtra(CommonString.Key_For_Consumer_Update, "1").putExtra("from",from));
|
||||
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, "Sales Not Found");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView sale_trcking_name, sales_count, sale_total_amount, discountedRs;
|
||||
CardView sale_card;
|
||||
ImageView pos_icon, demo_icon, sale_icon;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
sale_card = (CardView) itemView.findViewById(R.id.sale_card);
|
||||
sale_trcking_name = (TextView) itemView.findViewById(R.id.sale_trcking_name);
|
||||
sales_count = (TextView) itemView.findViewById(R.id.sales_count);
|
||||
sale_total_amount = (TextView) itemView.findViewById(R.id.sale_total_amount);
|
||||
discountedRs = (TextView) itemView.findViewById(R.id.discountedRs);
|
||||
pos_icon = (ImageView) itemView.findViewById(R.id.pos_icon);
|
||||
sale_icon = (ImageView) itemView.findViewById(R.id.sale_icon);
|
||||
demo_icon = (ImageView) itemView.findViewById(R.id.demo_icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkdemovalidation(InvoiceGetterSetter current) {
|
||||
return current.getDemo_given_str().equalsIgnoreCase("Yes") || current.getSkin_genius_str().equalsIgnoreCase("Yes") || current.getMaybelline_vto_str().equalsIgnoreCase("Yes");
|
||||
}
|
||||
|
||||
}
|
||||
+1214
File diff suppressed because it is too large
Load Diff
+248
@@ -0,0 +1,248 @@
|
||||
package com.cpm.lorealbaautomation.consumeractivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.InvoiceGetterSetter;
|
||||
import com.cpm.lorealbaautomation.printer.PrinterActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ConsumerReturnsHistoryActivity extends AppCompatActivity {
|
||||
public ArrayList<InvoiceGetterSetter> headerList = new ArrayList<>();
|
||||
String counter_Id, visit_date, username;
|
||||
private SharedPreferences preferences;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
RecyclerView recycl_history;
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_consumer_returns_history);
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
iduserinterface();
|
||||
|
||||
}
|
||||
|
||||
private void iduserinterface() {
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
editor = preferences.edit();
|
||||
counter_Id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
recycl_history = (RecyclerView) findViewById(R.id.recycl_history);
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
|
||||
setTitle("Returns History - " + username);
|
||||
|
||||
setDataToListView();
|
||||
}
|
||||
|
||||
|
||||
public void setDataToListView() {
|
||||
try {
|
||||
db.open();
|
||||
headerList = db.getsaleReturnHeaderData(visit_date, counter_Id, username, false, false, null);
|
||||
if (headerList.size() > 0) {
|
||||
Collections.reverse(headerList);
|
||||
recycl_history.setAdapter(new ValueAdapter(context, headerList));
|
||||
recycl_history.setLayoutManager(new LinearLayoutManager(context));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
FirebaseCrashlytics.getInstance().recordException(e);
|
||||
//test("Exception when fetching", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public class ValueAdapter extends RecyclerView.Adapter<ValueAdapter.MyViewHolder> {
|
||||
private LayoutInflater inflator;
|
||||
List<InvoiceGetterSetter> data;
|
||||
|
||||
|
||||
public ValueAdapter(Context context, List<InvoiceGetterSetter> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.row_returns_history, parent, false);
|
||||
return new ValueAdapter.MyViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ValueAdapter.MyViewHolder holder, final int position) {
|
||||
final InvoiceGetterSetter current = data.get(position);
|
||||
|
||||
holder.txt_name_with_mobile.setText("Consumer Name : " + current.getCustomer_name() + " Mobile No. : " + current.getMobile_no());
|
||||
holder.txt_name_with_mobile.setId(position);
|
||||
|
||||
|
||||
holder.text_bill_no.setText("Bill No. : " + current.getConsumer_return_bill_no());
|
||||
holder.text_bill_no.setId(position);
|
||||
db.open();
|
||||
////////////////////get return list from db user and bill wise
|
||||
holder.return_productList = db.getsalesReturnChildData(current.getReccept_count(), visit_date, counter_Id, username, false);
|
||||
////////////////////get replace product list from db user and bill wise
|
||||
db.open();
|
||||
holder.replace_productList = db.getsalesReturnReplaceProduct(current.getReccept_count(), visit_date, counter_Id, username, false);
|
||||
|
||||
if (holder.return_productList.size() > 0) {
|
||||
holder.sku_list_returns.setAdapter(new ReturnsSkuAdapter(context, holder.return_productList));
|
||||
holder.sku_list_returns.setLayoutManager(new LinearLayoutManager(context));
|
||||
}
|
||||
|
||||
|
||||
if (holder.replace_productList.size() > 0) {
|
||||
holder.sku_list_replace_product.setAdapter(new ReturnsSkuAdapter(context, holder.replace_productList));
|
||||
holder.sku_list_replace_product.setLayoutManager(new LinearLayoutManager(context));
|
||||
holder.rl_replace_product.setVisibility(View.VISIBLE);
|
||||
holder.rl_replace_product.setId(position);
|
||||
} else {
|
||||
holder.rl_replace_product.setVisibility(View.GONE);
|
||||
holder.rl_replace_product.setId(position);
|
||||
}
|
||||
|
||||
|
||||
holder.img_printer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(context, PrinterActivity.class).putExtra(CommonString.TAG_OBJECT, holder.return_productList).putExtra(CommonString.TAG_HEADER_OBJECT, current).putExtra(CommonString.TAG_FOR_RETURN, "1"));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txt_name_with_mobile, text_bill_no;
|
||||
RecyclerView sku_list_returns, sku_list_replace_product;
|
||||
LinearLayout rl_printer, rl_replace_product;
|
||||
ImageView img_printer;
|
||||
ArrayList<InvoiceGetterSetter> return_productList, replace_productList;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
txt_name_with_mobile = (TextView) itemView.findViewById(R.id.txt_name_with_mobile);
|
||||
text_bill_no = (TextView) itemView.findViewById(R.id.text_bill_no);
|
||||
img_printer = (ImageView) itemView.findViewById(R.id.img_printer);
|
||||
rl_printer = (LinearLayout) itemView.findViewById(R.id.rl_printer);
|
||||
sku_list_returns = (RecyclerView) itemView.findViewById(R.id.sku_list_returns);
|
||||
rl_replace_product = (LinearLayout) itemView.findViewById(R.id.rl_replace_product);
|
||||
sku_list_replace_product = (RecyclerView) itemView.findViewById(R.id.sku_list_replace_product);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ReturnsSkuAdapter extends RecyclerView.Adapter<ReturnsSkuAdapter.MyViewHolder> {
|
||||
private LayoutInflater inflator;
|
||||
List<InvoiceGetterSetter> data;
|
||||
|
||||
public ReturnsSkuAdapter(Context context, List<InvoiceGetterSetter> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.row_returns_sku, parent, false);
|
||||
return new MyViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ReturnsSkuAdapter.MyViewHolder holder, final int position) {
|
||||
final InvoiceGetterSetter current = data.get(position);
|
||||
|
||||
holder.product_name.setText("Product : " + current.getProduct());
|
||||
holder.product_name.setId(position);
|
||||
|
||||
holder.product_rate.setText("QTY - " + current.getQuantity() + " Rate - " + current.getProduct_rate());
|
||||
holder.product_rate.setId(position);
|
||||
|
||||
int total_ammount = Integer.parseInt(current.getQuantity()) * Integer.parseInt(current.getProduct_rate());
|
||||
holder.total_ammount_txt.setText("Total Amount - " + total_ammount);
|
||||
holder.total_ammount_txt.setId(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView product_name, product_rate, total_ammount_txt;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
product_name = (TextView) itemView.findViewById(R.id.txt_name_with_mobile);
|
||||
product_rate = (TextView) itemView.findViewById(R.id.text_bill_no);
|
||||
total_ammount_txt = (TextView) itemView.findViewById(R.id.total_ammount_txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
ConsumerReturnsHistoryActivity.this.finish();
|
||||
}
|
||||
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
ConsumerReturnsHistoryActivity.this.finish();
|
||||
|
||||
}
|
||||
}
|
||||
+4911
File diff suppressed because it is too large
Load Diff
+567
@@ -0,0 +1,567 @@
|
||||
package com.cpm.lorealbaautomation.consumeractivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.InvoiceGetterSetter;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||
import com.cpm.lorealbaautomation.printer.PrinterActivity;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class InvoiceReportProformaActivity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||
String CounterId, counterCode, visit_date, username, flag_for_consumer_Update = "", reciept_count = "", TransId = "", disable_pos = "", str_termCondition = "0", str_img_demo_no_sale = "";
|
||||
ArrayList<InvoiceGetterSetter> invoice_List = new ArrayList<>();
|
||||
TextView text_cus_name, text_mobile_number, text_inr_value, invoice_storename, invoice_storename_address, invoice_gst_no;
|
||||
RecyclerView drawer_layout_recycle_store;
|
||||
LinearLayout rl_pos;
|
||||
double total = 0.0;
|
||||
double off_worth_total = 0.0, worth_total = 0.0, OffSameProduct = 0.0, off_worth_additional = 0.0, value_off_worth_additional = 0.0;
|
||||
boolean pos_sale_flag = false;
|
||||
// Array of choices
|
||||
SwitchCompat switch_pos_sale;
|
||||
FloatingActionButton fab;
|
||||
ImageView img_printer;
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
ArrayList<InvoiceGetterSetter> consumerSalesHeaderList;
|
||||
HashMap<InvoiceGetterSetter, List<InvoiceGetterSetter>> listDataChild;
|
||||
JourneyPlan storeDataObject = new JourneyPlan();
|
||||
String from = "";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_invoice_report_proforma);
|
||||
from = getIntent().getStringExtra("from");
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
validateui_design();
|
||||
setTitle("Pink Slip -" + username);
|
||||
prepareListData();
|
||||
}
|
||||
|
||||
@SuppressLint({"RestrictedApi", "SetTextI18n", "CommitPrefEdits"})
|
||||
void validateui_design() {
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
SharedPreferences preferences = PrefHelper.getPrefs(context);
|
||||
CounterId = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
counterCode = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
drawer_layout_recycle_store = findViewById(R.id.drawer_layout_recycle_store);
|
||||
text_cus_name = (TextView) findViewById(R.id.text_cus_name);
|
||||
text_mobile_number = (TextView) findViewById(R.id.text_mobile_number);
|
||||
text_inr_value = (TextView) findViewById(R.id.text_inr_value);
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
img_printer = (ImageView) findViewById(R.id.img_printer);
|
||||
rl_pos = (LinearLayout) findViewById(R.id.rl_pos);
|
||||
|
||||
invoice_storename = (TextView) findViewById(R.id.invoice_storename);
|
||||
invoice_storename_address = (TextView) findViewById(R.id.invoice_storename_address);
|
||||
invoice_gst_no = (TextView) findViewById(R.id.invoice_gst_no);
|
||||
switch_pos_sale = (SwitchCompat) findViewById(R.id.switch_pos_sale);
|
||||
|
||||
switch_pos_sale.setSwitchPadding(40);
|
||||
switch_pos_sale.setOnCheckedChangeListener(this);
|
||||
db.open();
|
||||
storeDataObject = db.getspecific_storenamewith_counter_name(visit_date, CounterId, username);
|
||||
if (storeDataObject != null && storeDataObject.getStoreName() != null) {
|
||||
invoice_storename.setText("Counter Code : " + counterCode + " , Counter Name - " + storeDataObject.getCounterName());
|
||||
invoice_storename_address.setText(storeDataObject.getAddress() + " , " + storeDataObject.getCityName());
|
||||
}
|
||||
|
||||
invoice_gst_no.setText("Date : " + visit_date);
|
||||
invoice_List = (ArrayList<InvoiceGetterSetter>) getIntent().getSerializableExtra(CommonString.TAG_OBJECT);
|
||||
flag_for_consumer_Update = getIntent().getStringExtra(CommonString.Key_For_Consumer_Update);
|
||||
reciept_count = getIntent().getStringExtra(CommonString.Key_For_Reciept_Count);
|
||||
disable_pos = getIntent().getStringExtra(CommonString.Key_For_Disable_POS_And_Save);
|
||||
str_termCondition = getIntent().getStringExtra(CommonString.FLAG_FOR_TERMCONDITION);
|
||||
str_img_demo_no_sale = getIntent().getStringExtra(CommonString.KEY_IMAGE);
|
||||
TransId = CommonFunctions.getUUID(context);
|
||||
|
||||
if (invoice_List != null && !invoice_List.isEmpty()) {
|
||||
username = invoice_List.get(0).getUserName();
|
||||
text_cus_name.setText("Customer Name : " + invoice_List.get(0).getCustomer_name());
|
||||
text_mobile_number.setText("Mobile Number : " + invoice_List.get(0).getMobile_no());
|
||||
|
||||
calculate_invoice_added_data(invoice_List);
|
||||
drawer_layout_recycle_store.setAdapter(new ValueAdapter(context, invoice_List));
|
||||
drawer_layout_recycle_store.setLayoutManager(new LinearLayoutManager(context));
|
||||
text_inr_value.setText("" + total);
|
||||
}
|
||||
|
||||
img_printer.setOnClickListener(this);
|
||||
fab.setOnClickListener(this);
|
||||
setreciept_count();
|
||||
if (disable_pos != null && disable_pos.equals("1")) {
|
||||
fab.setVisibility(View.GONE);
|
||||
rl_pos.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setreciept_count() {
|
||||
try {
|
||||
for (int k = 0; k < invoice_List.size(); k++) {
|
||||
invoice_List.get(k).setUnique_code(TransId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
if (view.getId() == R.id.fab) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(R.string.parinaam).setMessage(R.string.alertsaveData);
|
||||
builder.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> new InsertAsync().execute()).setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> dialogInterface.cancel());
|
||||
builder.show();
|
||||
} else if (view.getId() == R.id.img_printer) {
|
||||
startActivity(new Intent(context, PrinterActivity.class).putExtra(CommonString.TAG_OBJECT, invoice_List));
|
||||
}
|
||||
}
|
||||
|
||||
private long calculate_data_insert_data() {
|
||||
long l = 0;
|
||||
try {
|
||||
if (flag_for_consumer_Update != null && flag_for_consumer_Update.equals("1")) {
|
||||
db.open();
|
||||
db.deleteconsumersale(visit_date, Integer.parseInt(reciept_count), username);
|
||||
db.open();
|
||||
l = db.insert_consumer_sales_data(username, visit_date, CounterId, String.valueOf(total), pos_sale_flag, TransId, str_termCondition, listDataChild, consumerSalesHeaderList, str_img_demo_no_sale, from);
|
||||
} else {
|
||||
db.open();
|
||||
l = db.insert_consumer_sales_data(username, visit_date, CounterId, String.valueOf(total), pos_sale_flag, TransId, str_termCondition, listDataChild, consumerSalesHeaderList, str_img_demo_no_sale, from);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
if (compoundButton.getId() == R.id.switch_pos_sale) {
|
||||
pos_sale_flag = isChecked;
|
||||
Log.i("switch_compat", String.valueOf(isChecked));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ValueAdapter extends RecyclerView.Adapter<ValueAdapter.MyViewHolder> {
|
||||
private final LayoutInflater inflator;
|
||||
List<InvoiceGetterSetter> data;
|
||||
|
||||
public ValueAdapter(Context context, List<InvoiceGetterSetter> data) {
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ValueAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.row_adapter_proforma_invoice, parent, false);
|
||||
return new ValueAdapter.MyViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ValueAdapter.MyViewHolder holder, final int position) {
|
||||
final InvoiceGetterSetter current = data.get(position);
|
||||
|
||||
if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("OffSameProduct")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - " + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("OffAdditionalProduct")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - " + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("ValueOffAdditionalProduct")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - " + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("OffWorth") || current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("WorthWithProduct")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - " + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("OffProduct")) {
|
||||
holder.select_promo_productRl.setVisibility(View.GONE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
holder.product.setText("Applied Promo - " + current.getPromotion_name() + " - " + current.getProduct() + " - Discounted Rs - " + current.getSkuType());
|
||||
holder.product.setId(position);
|
||||
|
||||
holder.qty.setText(current.getQuantity());
|
||||
holder.qty.setId(position);
|
||||
|
||||
holder.rate.setText(current.getProduct_rate());
|
||||
holder.rate.setId(position);
|
||||
|
||||
holder.total_amount.setText(current.getTotal_amount());
|
||||
holder.total_amount.setId(position);
|
||||
|
||||
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("Worth")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - " + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + "Discounted Rs - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("Gift")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - " + "Gift - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + "Gift - " + current.getProduct());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
|
||||
|
||||
} else if (current.isPromo_flag() && current.getPromo_type().equalsIgnoreCase("Product")) {
|
||||
holder.select_promo_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
|
||||
holder.select_productRl.setVisibility(View.GONE);
|
||||
holder.select_productRl.setId(position);
|
||||
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + " - (" + current.getProduct().toLowerCase() + ")");
|
||||
holder.txt_promo_str.setId(position);
|
||||
} else {
|
||||
holder.txt_promo_str.setText("Applied Promo - " + current.getPromotion_name() + "\n" + current.getProduct().toLowerCase());
|
||||
holder.txt_promo_str.setId(position);
|
||||
}
|
||||
} else {
|
||||
holder.select_promo_productRl.setVisibility(View.GONE);
|
||||
holder.select_promo_productRl.setId(position);
|
||||
holder.select_productRl.setVisibility(View.VISIBLE);
|
||||
holder.select_productRl.setId(position);
|
||||
if (current.getDiscount() != 0.0) {
|
||||
String string = current.getDiscount().toString();
|
||||
holder.product.setText(current.getProduct() + "\n" + string.substring(string.length() - 1) + "0% Discount - " + current.getDiscounted_value());
|
||||
|
||||
holder.product.setId(position);
|
||||
|
||||
holder.rate.setText(current.getProduct_rate());
|
||||
holder.rate.setId(position);
|
||||
|
||||
holder.total_amount.setText(String.valueOf(current.getActual_price_per_product()));
|
||||
holder.total_amount.setId(position);
|
||||
|
||||
holder.qty.setText(current.getQuantity());
|
||||
holder.qty.setId(position);
|
||||
} else {
|
||||
holder.rate.setText(current.getProduct_rate());
|
||||
holder.rate.setId(position);
|
||||
holder.total_amount.setText(current.getTotal_amount());
|
||||
holder.total_amount.setId(position);
|
||||
holder.qty.setText(current.getQuantity());
|
||||
holder.qty.setId(position);
|
||||
|
||||
if (!current.getStr_invoiceType().isEmpty() && current.getStr_invoiceType().equalsIgnoreCase("Sample") || !current.getStr_invoiceType().isEmpty() && current.getStr_invoiceType().equalsIgnoreCase("GWP")) {
|
||||
holder.product.setText(current.getProduct() + " - Type - " + current.getStr_invoiceType());
|
||||
holder.product.setId(position);
|
||||
} else {
|
||||
holder.product.setText(current.getProduct());
|
||||
holder.product.setId(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView product, qty, rate, total_amount, txt_promo_str;
|
||||
LinearLayout select_promo_productRl, select_productRl;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
product = (TextView) itemView.findViewById(R.id.product);
|
||||
qty = (TextView) itemView.findViewById(R.id.qty);
|
||||
rate = (TextView) itemView.findViewById(R.id.rate);
|
||||
total_amount = (TextView) itemView.findViewById(R.id.total_amount);
|
||||
txt_promo_str = (TextView) itemView.findViewById(R.id.txt_promo_str);
|
||||
select_promo_productRl = (LinearLayout) itemView.findViewById(R.id.select_promo_productRl);
|
||||
select_productRl = (LinearLayout) itemView.findViewById(R.id.select_productRl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
InvoiceReportProformaActivity.this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
InvoiceReportProformaActivity.this.finish();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void calculate_invoice_added_data(ArrayList<InvoiceGetterSetter> invoice_List) {
|
||||
double cCom = 0.0, total_INR_value = 0.0;
|
||||
try {
|
||||
for (int k = 0; k < invoice_List.size(); k++) {
|
||||
if (!invoice_List.get(k).isPromo_flag()) {
|
||||
if (invoice_List.get(k).getDiscount() != 0.0) {
|
||||
int quantity = Integer.parseInt(invoice_List.get(k).getQuantity());
|
||||
double amount = Double.parseDouble(invoice_List.get(k).getProduct_rate());
|
||||
amount = amount * quantity;
|
||||
invoice_List.get(k).setTotal_amount(String.valueOf(amount));
|
||||
cCom = cCom + ((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount());
|
||||
} else {
|
||||
int quantity = Integer.parseInt(invoice_List.get(k).getQuantity());
|
||||
double amount = Double.parseDouble(invoice_List.get(k).getProduct_rate());
|
||||
amount = amount * quantity;
|
||||
invoice_List.get(k).setTotal_amount(String.valueOf(amount));
|
||||
}
|
||||
|
||||
invoice_List.get(k).setStore_name(storeDataObject.getStoreName());
|
||||
invoice_List.get(k).setStore_address(storeDataObject.getAddress() + "," + storeDataObject.getCityName());
|
||||
|
||||
double amount_ofproduct = ((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount());
|
||||
amount_ofproduct = (Double.parseDouble(invoice_List.get(k).getTotal_amount())) - amount_ofproduct;
|
||||
|
||||
total_INR_value = total_INR_value + Double.parseDouble(invoice_List.get(k).getTotal_amount());
|
||||
|
||||
if (invoice_List.get(k).getDiscount() == 0.0 || invoice_List.get(k).getDiscount() == 0) {
|
||||
invoice_List.get(k).setActual_price_per_product((Double.parseDouble(invoice_List.get(k).getTotal_amount())));
|
||||
invoice_List.get(k).setDiscounted_value(0.0);
|
||||
} else {
|
||||
invoice_List.get(k).setDiscounted_value(((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount()));
|
||||
invoice_List.get(k).setActual_price_per_product((Double.parseDouble(invoice_List.get(k).getTotal_amount()) - ((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount())));
|
||||
}
|
||||
} else {
|
||||
if (invoice_List.get(k).getPromo_type().equalsIgnoreCase("OffProduct")) {
|
||||
if (invoice_List.get(k).getDiscount() != 0.0) {
|
||||
int quantity = Integer.parseInt(invoice_List.get(k).getQuantity());
|
||||
double amount = Double.parseDouble(invoice_List.get(k).getProduct_rate());
|
||||
amount = amount * quantity;
|
||||
amount = amount - Integer.parseInt(invoice_List.get(k).getSkuType());
|
||||
invoice_List.get(k).setTotal_amount(String.valueOf(amount));
|
||||
cCom = cCom + ((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount());
|
||||
} else {
|
||||
int quantity = Integer.parseInt(invoice_List.get(k).getQuantity());
|
||||
double amount = Double.parseDouble(invoice_List.get(k).getProduct_rate());
|
||||
amount = amount * quantity;
|
||||
amount = amount - Integer.parseInt(invoice_List.get(k).getSkuType());
|
||||
invoice_List.get(k).setTotal_amount(String.valueOf(amount));
|
||||
}
|
||||
|
||||
invoice_List.get(k).setStore_name(storeDataObject.getStoreName());
|
||||
invoice_List.get(k).setStore_address(storeDataObject.getAddress() + "," + storeDataObject.getCityName());
|
||||
double amount_ofproduct = ((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount());
|
||||
amount_ofproduct = (Double.parseDouble(invoice_List.get(k).getTotal_amount())) - amount_ofproduct;
|
||||
if (invoice_List.get(k).getDiscount() == 0.0 || invoice_List.get(k).getDiscount() == 0) {
|
||||
invoice_List.get(k).setActual_price_per_product((Double.parseDouble(invoice_List.get(k).getTotal_amount())));
|
||||
invoice_List.get(k).setDiscounted_value(0.0);
|
||||
} else {
|
||||
invoice_List.get(k).setDiscounted_value(((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount()));
|
||||
invoice_List.get(k).setActual_price_per_product((Double.parseDouble(invoice_List.get(k).getTotal_amount()) - ((Double.parseDouble(invoice_List.get(k).getTotal_amount())) * invoice_List.get(k).getDiscount())));
|
||||
}
|
||||
|
||||
total_INR_value = total_INR_value + Double.parseDouble(invoice_List.get(k).getTotal_amount());
|
||||
} else if (invoice_List.get(k).getPromo_type().equalsIgnoreCase("OffWorth") || invoice_List.get(k).getPromo_type().equalsIgnoreCase("WorthWithProduct")) {
|
||||
off_worth_total = off_worth_total + Double.parseDouble(invoice_List.get(k).getProduct());
|
||||
} else if (invoice_List.get(k).getPromo_type().equalsIgnoreCase("OffAdditionalProduct")) {
|
||||
off_worth_additional = off_worth_additional + Double.parseDouble(invoice_List.get(k).getProduct());
|
||||
} else if (invoice_List.get(k).getPromo_type().equalsIgnoreCase("ValueOffAdditionalProduct")) {
|
||||
value_off_worth_additional = value_off_worth_additional + Double.parseDouble(invoice_List.get(k).getProduct());
|
||||
} else if (invoice_List.get(k).getPromo_type().equalsIgnoreCase("Worth")) {
|
||||
worth_total = worth_total + Double.parseDouble(invoice_List.get(k).getProduct());
|
||||
} else if (invoice_List.get(k).getPromo_type().equalsIgnoreCase("OffSameProduct")) {
|
||||
OffSameProduct = OffSameProduct + Double.parseDouble(invoice_List.get(k).getProduct());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
total = total_INR_value - cCom;
|
||||
total = total - off_worth_total;
|
||||
total = total - value_off_worth_additional;
|
||||
total = total - worth_total;
|
||||
total = total - OffSameProduct;
|
||||
total = total - off_worth_additional;
|
||||
} catch (NumberFormatException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareListData() {
|
||||
consumerSalesHeaderList = new ArrayList<>();
|
||||
listDataChild = new HashMap<>();
|
||||
consumerSalesHeaderList.add(invoice_List.get(0));
|
||||
consumerSalesHeaderList.size();// Adding child data
|
||||
for (int i = 0; i < consumerSalesHeaderList.size(); i++) {
|
||||
listDataChild.put(consumerSalesHeaderList.get(i), invoice_List); // Header, Child data
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private class InsertAsync extends AsyncTask<Boolean, Void, Void> {
|
||||
boolean flag = false;
|
||||
Dialog dialog = null;
|
||||
long l = 0;
|
||||
ProgressBar pb;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
dialog = new Dialog(context);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
Objects.requireNonNull(dialog.getWindow()).setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
||||
dialog.setContentView(R.layout.circular_progress_bar);
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Boolean... bool) {
|
||||
l = calculate_data_insert_data();
|
||||
if (l > 0) {
|
||||
if (pos_sale_flag) {
|
||||
if (CommonFunctions.checkNetIsAvailable(context)) {
|
||||
CommonFunctions.call_upload(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
dialog.cancel();
|
||||
if (l > 0) {
|
||||
startActivity(new Intent(context, ConsumerIntractionDetailActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).putExtra("from", from));
|
||||
AlertandMessages.showToastMsg(context, "Data Saved Successfully");
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
InvoiceReportProformaActivity.this.finish();
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, "Data not Saved.Please try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,776 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.BASurveyGetterSetter;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterSurvey;
|
||||
import com.cpm.lorealbaautomation.retrofit.PostApi;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
import static com.cpm.lorealbaautomation.dailyactivity.StoreImageActivity.convertBitmap;
|
||||
|
||||
|
||||
public class BASurveyActivity extends AppCompatActivity {
|
||||
List<Integer> checkHeaderArray = new ArrayList<>();
|
||||
List<Integer> checkGroupArray = new ArrayList<>();
|
||||
boolean checkflag = true;
|
||||
SharedPreferences preferences;
|
||||
String pathforcheck = "", _path = "", str, img_str = "", counter_id = "", surveyId = "", surveyType = ""; //img_str2 = "";
|
||||
String visit_date, username;
|
||||
Lorealba_Database db;
|
||||
ArrayList<BASurveyGetterSetter> question_list, childListData;
|
||||
HashMap<BASurveyGetterSetter, ArrayList<BASurveyGetterSetter>> hashMapAnsListChildData;
|
||||
int child_position = -1;
|
||||
String error_msg = "";
|
||||
Toolbar toolbar;
|
||||
Context context;
|
||||
FloatingActionButton fab;
|
||||
ExpandableListView expandableListView;
|
||||
ExpandableListAdapter adapter;
|
||||
ArrayList<MasterSurvey> listDataHeader;
|
||||
ArrayList<BASurveyGetterSetter> listChildData;
|
||||
HashMap<MasterSurvey, ArrayList<BASurveyGetterSetter>> listDataChild;
|
||||
JourneyPlan jcp_Object = new JourneyPlan();
|
||||
ArrayList<BASurveyGetterSetter> list = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_ba_survey);
|
||||
context = this;
|
||||
//Intent data
|
||||
if (getIntent().getStringExtra("SurveyId") != null && getIntent().getStringExtra("SurveyType") != null) {
|
||||
surveyId = getIntent().getStringExtra("SurveyId");
|
||||
surveyType = getIntent().getStringExtra("SurveyType");
|
||||
}
|
||||
|
||||
preferences = PrefHelper.getPrefs(this);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (surveyType.equalsIgnoreCase("BA")) {
|
||||
setTitle("BA Survey - " + username);
|
||||
} else {
|
||||
setTitle("Counter Survey - " + visit_date);
|
||||
}
|
||||
|
||||
str = CommonString.getImagesFolder(context);
|
||||
expandableListView = (ExpandableListView) findViewById(R.id.list);
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
int lastItem = firstVisibleItem + visibleItemCount;
|
||||
if (firstVisibleItem == 0) {
|
||||
fab.show();//.setVisibility(View.VISIBLE);
|
||||
} else if (lastItem == totalItemCount) {
|
||||
fab.hide();//setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
fab.show();//setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView arg0, int arg1) {
|
||||
InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (getCurrentFocus() != null) {
|
||||
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
|
||||
getCurrentFocus().clearFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
jcp_Object = db.getBIDfromJCP(username, counter_id);
|
||||
//Header
|
||||
question_list = new ArrayList<>();
|
||||
listDataChild = new HashMap<>();
|
||||
if (surveyType.equalsIgnoreCase("BA")) {
|
||||
db.open();
|
||||
listDataHeader = db.getSurveyData("BA", surveyId);
|
||||
} else {
|
||||
db.open();
|
||||
listDataHeader = db.getSurveyData("Counter", surveyId);
|
||||
}
|
||||
|
||||
for (int i = 0; i < listDataHeader.size(); i++) {
|
||||
// Adding child data
|
||||
db.open();
|
||||
question_list = db.getSurveyWiseData(listDataHeader.get(i).getSurveyId());
|
||||
if (!question_list.isEmpty()) {
|
||||
String select = getString(R.string.title_activity_select_dropdown);
|
||||
for (int j = 0; j < question_list.size(); j++) {
|
||||
// Adding answer list data
|
||||
db.open();
|
||||
childListData = db.getSurveyAnswerData(question_list.get(j), select);
|
||||
question_list.get(j).setAnswerList(childListData);
|
||||
}
|
||||
}
|
||||
|
||||
listDataChild.put(listDataHeader.get(i), question_list);
|
||||
}
|
||||
|
||||
adapter = new ExpandableListAdapter(context, listDataHeader, listDataChild);
|
||||
expandableListView.setAdapter(adapter);
|
||||
for (int i = 0; i < adapter.getGroupCount(); i++) {
|
||||
expandableListView.expandGroup(i);
|
||||
}
|
||||
|
||||
fab.setOnClickListener(view -> {
|
||||
expandableListView.clearFocus();
|
||||
if (validateData(listDataHeader, listDataChild)) {
|
||||
if (CommonFunctions.checkNetIsAvailable(context)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(R.string.parinaam).setMessage(R.string.ba_survey_save_data_msg)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yes, (dialog, id) -> {
|
||||
db.open();
|
||||
if (db.saveBASurveyAnswerData(listDataHeader, listDataChild, counter_id, visit_date, jcp_Object, surveyType) > 0) {
|
||||
if (CommonFunctions.checkNetIsAvailable(context)) {
|
||||
new InsertAsync().execute(false);
|
||||
}
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, "Error in data saving");
|
||||
}
|
||||
}).setNegativeButton(R.string.no, (dialog, id) -> dialog.cancel());
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, CommonString.MESSAGE_INTERNET_NOT_AVALABLE);
|
||||
}
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, error_msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Dialog dialog;
|
||||
ProgressBar pb;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
class InsertAsync extends AsyncTask<Boolean, Void, Void> {
|
||||
boolean flag = false;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
dialog = new Dialog(context);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
Objects.requireNonNull(dialog.getWindow()).setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
||||
dialog.setContentView(R.layout.circular_progress_bar);
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Boolean... bool) {
|
||||
UploadStockRecursive(jcp_Object);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UploadStockRecursive(JourneyPlan jcp) {
|
||||
try {
|
||||
JSONArray topUpArray = new JSONArray();
|
||||
String key = "";
|
||||
db.open();
|
||||
if (surveyType.equalsIgnoreCase("BA")) {
|
||||
key = "BASurveyData";
|
||||
listDataHeader = db.getBASurveySavedData("BA", jcp, visit_date);
|
||||
} else {
|
||||
key = "CounterSurveyData";
|
||||
listDataHeader = db.getBASurveySavedData("Counter", jcp, visit_date);
|
||||
}
|
||||
|
||||
for (int j = 0; j < listDataHeader.size(); j++) {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("BID", jcp.getBID());
|
||||
obj.put("UserId", username);
|
||||
obj.put("CounterId", counter_id);
|
||||
obj.put("SurveyType", listDataHeader.get(j).getSurveyType());
|
||||
obj.put("SurveyId", listDataHeader.get(j).getSurveyId());
|
||||
db.open();
|
||||
listChildData = db.getChildData(surveyType, jcp, visit_date, listDataHeader.get(j).getCommon_id());
|
||||
|
||||
for (int i = 0; i < listChildData.size(); i++) {
|
||||
JSONObject obj1 = getJsonObject(jcp, i);
|
||||
topUpArray.put(obj1);
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("MID", jcp.getMID());
|
||||
jsonObject.put("Keys", key);
|
||||
jsonObject.put("JsonData", topUpArray.toString());
|
||||
jsonObject.put("UserId", username);
|
||||
|
||||
String jsonString = jsonObject.toString();
|
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).writeTimeout(CommonString.TIMEOUT,
|
||||
TimeUnit.SECONDS).connectTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).build();
|
||||
RequestBody jsonData = RequestBody.create(MediaType.parse("application/json"), jsonString);
|
||||
Retrofit adapter = new Retrofit.Builder().baseUrl(CommonString.URL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create()).build();
|
||||
PostApi api = adapter.create(PostApi.class);
|
||||
Call<ResponseBody> call = null;
|
||||
call = api.getUploadJsonDetail(jsonData);
|
||||
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
|
||||
ResponseBody responseBody = response.body();
|
||||
String data = null;
|
||||
if (responseBody != null && response.isSuccessful()) {
|
||||
try {
|
||||
assert response.body() != null;
|
||||
data = response.body().string();
|
||||
if (data.equalsIgnoreCase("")) {
|
||||
} else {
|
||||
data = data.substring(1, data.length() - 1).replace("\\", "");
|
||||
if (data.contains("Success")) {
|
||||
db.open();
|
||||
db.updateBASurveyData(surveyType, "1");
|
||||
dialog.cancel();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
dialog.cancel();
|
||||
e.fillInStackTrace();
|
||||
|
||||
}
|
||||
} else {
|
||||
dialog.cancel();
|
||||
AlertandMessages.showToastMsg(context, CommonString.MESSAGE_NO_RESPONSE_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
dialog.cancel();
|
||||
AlertandMessages.showToastMsg(context, CommonString.MESSAGE_INTERNET_NOT_AVALABLE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} catch (JSONException e) {
|
||||
dialog.cancel();
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull JSONObject getJsonObject(JourneyPlan jcp, int i) throws JSONException {
|
||||
JSONObject obj1 = new JSONObject();
|
||||
if (surveyType.equalsIgnoreCase("BA")) {
|
||||
obj1.put("BID", jcp.getBID());
|
||||
} else {
|
||||
obj1.put("MID", jcp.getMID());
|
||||
}
|
||||
obj1.put("UserId", username);
|
||||
obj1.put("CounterId", counter_id);
|
||||
obj1.put("Visit_date", visit_date);
|
||||
obj1.put("SurveyId", listChildData.get(i).getSurveyId());
|
||||
obj1.put("SurveyQuestionId", listChildData.get(i).getSurveyQuestionId());
|
||||
if (listChildData.get(i).getCorrect_answer_id().equalsIgnoreCase("0")) {
|
||||
obj1.put("Survey_Correct_Answer_Id", "0");
|
||||
} else {
|
||||
obj1.put("Survey_Correct_Answer_Id", listChildData.get(i).getCorrect_answer_id());
|
||||
}
|
||||
|
||||
obj1.put("Survey_Correct_Answer", listChildData.get(i).getSurveyAnswer());
|
||||
obj1.put("Survey_Image", listChildData.get(i).getCam_image());
|
||||
return obj1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), (dialog, id1) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
finish();
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), (dialog, id) -> finish())
|
||||
.setNegativeButton(getString(R.string.cancel), (dialog, which) -> {
|
||||
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
private class ExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
Context _context;
|
||||
ArrayList<MasterSurvey> listDataHeader; // header titles
|
||||
HashMap<MasterSurvey, ArrayList<BASurveyGetterSetter>> listDataChild;
|
||||
|
||||
public ExpandableListAdapter(Context context, ArrayList<MasterSurvey> listDataHeader, HashMap<MasterSurvey, ArrayList<BASurveyGetterSetter>> listDataChild) {
|
||||
this._context = context;
|
||||
this.listDataHeader = listDataHeader;
|
||||
this.listDataChild = listDataChild;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosititon) {
|
||||
return this.listDataChild.get(this.listDataHeader.get(groupPosition)).get(childPosititon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return childPosition;
|
||||
}
|
||||
|
||||
@SuppressLint({"NewApi", "InflateParams"})
|
||||
@Override
|
||||
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
|
||||
BASurveyGetterSetter checkList = (BASurveyGetterSetter) getChild(groupPosition, childPosition);
|
||||
ViewHolder holder = null;
|
||||
if (convertView == null) {
|
||||
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = infalInflater.inflate(R.layout.audit_question_list_item, null);
|
||||
holder = new ViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.data = checkList;
|
||||
holder.txt_question.setText(holder.data.getSurveyQuestion());
|
||||
|
||||
final ArrayList<BASurveyGetterSetter> ans_list = (holder.data).getAnswerList();
|
||||
|
||||
if (holder.data.getSurveyQuestionType().equalsIgnoreCase("List Single Choice") ||
|
||||
holder.data.getSurveyQuestionType().equalsIgnoreCase("List Multiple Choice")) {
|
||||
holder.sp_auditAnswer.setVisibility(View.VISIBLE);
|
||||
holder.edt_answer.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.edt_answer.setVisibility(View.VISIBLE);
|
||||
holder.sp_auditAnswer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
if (!ans_list.isEmpty()) {
|
||||
holder.sp_auditAnswer.setAdapter(new AnswerSpinnerAdapter(context, R.layout.custom_spinner_item, ans_list));
|
||||
}
|
||||
|
||||
final ViewHolder finalHolder = holder;
|
||||
holder.sp_auditAnswer.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position != 0) {
|
||||
BASurveyGetterSetter ans = ans_list.get(position);
|
||||
finalHolder.data.setCorrect_answer_id(ans.getSurveyAnswerId());
|
||||
finalHolder.data.setSurveyAnswer(ans.getSurveyAnswer());
|
||||
//finalHolder.data.setImageAllow(ans.getImageAllow());
|
||||
if (finalHolder.data.getImageAllow().equals("1")) {
|
||||
finalHolder.parent_cam_layout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
finalHolder.parent_cam_layout.setVisibility(View.GONE);
|
||||
if (finalHolder.data.getCam_image() != null && !finalHolder.data.getCam_image().isEmpty()) {
|
||||
if (new File(str + finalHolder.data.getCam_image()).exists()) {
|
||||
new File(str + finalHolder.data.getCam_image()).delete();
|
||||
}
|
||||
}
|
||||
finalHolder.data.setCam_image("");
|
||||
finalHolder.img_cam.setBackgroundResource(R.mipmap.camera_bsd);
|
||||
}
|
||||
} else {
|
||||
if ((finalHolder.data.getSurveyQuestionType().equalsIgnoreCase("List Single Choice") ||
|
||||
finalHolder.data.getSurveyQuestionType().equalsIgnoreCase("List Multiple Choice"))) {
|
||||
finalHolder.data.setCorrect_answer_id("0");
|
||||
finalHolder.data.setSurveyAnswer("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.img_cam.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (surveyType.equalsIgnoreCase("BA")) {
|
||||
pathforcheck = jcp_Object.getBID() + "_" + counter_id + "_BASurveyPic-" + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeHHMMSS().replace(":", "") + ".jpg";
|
||||
} else {
|
||||
pathforcheck = jcp_Object.getMID() + "_" + counter_id + "_CounterSurveyPic-" + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeHHMMSS().replace(":", "") + ".jpg";
|
||||
}
|
||||
_path = CommonString.getImagesFolder(context) + pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(context, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
child_position = childPosition;
|
||||
//startCameraActivity(0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (holder.data.getSurveyQuestionType().equalsIgnoreCase("Number")) {
|
||||
holder.edt_answer.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
} else if (holder.data.getSurveyQuestionType().equalsIgnoreCase("Decimal")) {
|
||||
holder.edt_answer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
} else {
|
||||
holder.edt_answer.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
holder.edt_answer.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (!hasFocus) {
|
||||
finalHolder.data.setSurveyAnswerId("0");
|
||||
finalHolder.data.setSurveyAnswer(((EditText) v).getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
if (ans_list.size() > 0) {
|
||||
for (int i = 0; i < ans_list.size(); i++) {
|
||||
if ((holder.data.getSurveyQuestionType().equalsIgnoreCase("List Single Choice") ||
|
||||
holder.data.getSurveyQuestionType().equalsIgnoreCase("List Multiple Choice")) &&
|
||||
ans_list.get(i).getSurveyAnswerId().equals(holder.data.getCorrect_answer_id())) {
|
||||
holder.sp_auditAnswer.setSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.data.getSurveyQuestionType().equalsIgnoreCase("Text") ||
|
||||
holder.data.getSurveyQuestionType().equalsIgnoreCase("Decimal") ||
|
||||
holder.data.getSurveyQuestionType().equalsIgnoreCase("Number")) {
|
||||
holder.edt_answer.setText(holder.data.getSurveyAnswer());
|
||||
holder.edt_answer.setId(childPosition);
|
||||
}
|
||||
|
||||
if (holder.data.getImageAllow().equalsIgnoreCase("1")) {
|
||||
finalHolder.parent_cam_layout.setVisibility(View.VISIBLE);
|
||||
holder.img_cam.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
finalHolder.parent_cam_layout.setVisibility(View.GONE);
|
||||
holder.img_cam.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!img_str.equals("")) {
|
||||
if (child_position == childPosition) {
|
||||
holder.data.setCam_image(img_str);
|
||||
img_str = "";
|
||||
child_position = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.data.getCam_image().equals("")) {
|
||||
holder.img_cam.setBackgroundResource(R.mipmap.camera_star);
|
||||
holder.img_cam.setId(childPosition);
|
||||
} else {
|
||||
holder.img_cam.setBackgroundResource(R.mipmap.camera_bsd);
|
||||
holder.img_cam.setId(childPosition);
|
||||
}
|
||||
|
||||
if (!checkflag) {
|
||||
if (checkGroupArray.contains(groupPosition) && checkHeaderArray.contains(childPosition)) {
|
||||
holder.card_view.setBackgroundColor(getResources().getColor(R.color.red));
|
||||
holder.card_view.setId(childPosition);
|
||||
} else {
|
||||
holder.card_view.setBackgroundColor(getResources().getColor(R.color.white));
|
||||
holder.card_view.setId(childPosition);
|
||||
}
|
||||
} else {
|
||||
holder.card_view.setBackgroundColor(getResources().getColor(R.color.white));
|
||||
holder.card_view.setId(childPosition);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
return this.listDataChild.get(this.listDataHeader.get(groupPosition)).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return this.listDataHeader.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return this.listDataHeader.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return groupPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = infalInflater.inflate(R.layout.item_header_expandable_window, parent, false);
|
||||
}
|
||||
final MasterSurvey headerTitle = (MasterSurvey) getGroup(groupPosition);
|
||||
|
||||
TextView lblListHeader = (TextView) convertView.findViewById(R.id.txt_header);
|
||||
CardView cardView = (CardView) convertView.findViewById(R.id.cardview_exists);
|
||||
lblListHeader.setText(headerTitle.getSurveyName());
|
||||
|
||||
cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (expandableListView.isGroupExpanded(groupPosition)) {
|
||||
expandableListView.collapseGroup(groupPosition);
|
||||
} else {
|
||||
expandableListView.expandGroup(groupPosition);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!checkflag) {
|
||||
if (checkGroupArray.contains(groupPosition)) {
|
||||
cardView.setBackgroundColor(getResources().getColor(R.color.red));
|
||||
} else {
|
||||
cardView.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
}
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final TextView txt_question;
|
||||
public final Spinner sp_auditAnswer;
|
||||
public final EditText edt_answer;
|
||||
public final ImageView img_cam;
|
||||
public final RelativeLayout parent_cam_layout;
|
||||
CardView card_view;
|
||||
BASurveyGetterSetter data;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
mView = view;
|
||||
|
||||
txt_question = (TextView) view.findViewById(R.id.txt_question);
|
||||
sp_auditAnswer = (Spinner) view.findViewById(R.id.sp_auditAnswer);
|
||||
card_view = (CardView) view.findViewById(R.id.card_view);
|
||||
edt_answer = (EditText) view.findViewById(R.id.edt_answer);
|
||||
img_cam = (ImageView) view.findViewById(R.id.img_cam);
|
||||
parent_cam_layout = (RelativeLayout) view.findViewById(R.id.parent_cam_layout);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class AnswerSpinnerAdapter extends ArrayAdapter<BASurveyGetterSetter> {
|
||||
List<BASurveyGetterSetter> list;
|
||||
Context context;
|
||||
int resourceId;
|
||||
|
||||
public AnswerSpinnerAdapter(Context context, int resourceId, ArrayList<BASurveyGetterSetter> list) {
|
||||
super(context, resourceId, list);
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@SuppressLint("ViewHolder")
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
BASurveyGetterSetter cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.tv_ans);
|
||||
txt_spinner.setText(list.get(position).getSurveyAnswer());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View _convertView, @NonNull ViewGroup parent) {
|
||||
View view = _convertView;
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
|
||||
BASurveyGetterSetter cm = list.get(position);
|
||||
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.tv_ans);
|
||||
txt_spinner.setText(cm.getSurveyAnswer());
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
boolean validateData(ArrayList<MasterSurvey> listDataHeader, HashMap<MasterSurvey, ArrayList<BASurveyGetterSetter>> listDataChild) {
|
||||
checkHeaderArray.clear();
|
||||
checkGroupArray.clear();
|
||||
loop:
|
||||
for (int j = 0; j < listDataHeader.size(); j++) {
|
||||
ArrayList<BASurveyGetterSetter> data = listDataChild.get(listDataHeader.get(j));
|
||||
for (int i = 0; i < Objects.requireNonNull(data).size(); i++) {
|
||||
if (data.get(i).getSurveyQuestionType().equalsIgnoreCase("Text") || data.get(i).getSurveyQuestionType().equalsIgnoreCase("Decimal") || data.get(i).getSurveyQuestionType().equalsIgnoreCase("Number")) {
|
||||
if (data.get(i).getSurveyAnswer() == null || data.get(i).getSurveyAnswer().equalsIgnoreCase("")) {
|
||||
error_msg = getString(R.string.pls_answer);
|
||||
checkflag = false;
|
||||
} else {
|
||||
checkflag = true;
|
||||
}
|
||||
} else {
|
||||
if (data.get(i).getCorrect_answer_id().equalsIgnoreCase("0")) {
|
||||
error_msg = getString(R.string.pls_answer_all_qns);
|
||||
checkflag = false;
|
||||
} else if (data.get(i).getImageAllow().equals("1") && data.get(i).getCam_image().equals("")) {
|
||||
error_msg = getString(R.string.click_image);
|
||||
checkflag = false;
|
||||
} else {
|
||||
checkflag = true;
|
||||
}
|
||||
}
|
||||
if (!checkflag) {
|
||||
if (!checkHeaderArray.contains(i)) {
|
||||
checkHeaderArray.add(i);
|
||||
checkGroupArray.add(j);
|
||||
}
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
return checkflag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
Log.i("MakeMachine", "resultCode: " + resultCode);
|
||||
switch (resultCode) {
|
||||
case 0:
|
||||
Log.i("MakeMachine", "User cancelled");
|
||||
break;
|
||||
case -1:
|
||||
if (pathforcheck != null && !pathforcheck.isEmpty()) {
|
||||
if (new File(CommonString.getImagesFolder(context) + pathforcheck).exists()) {
|
||||
convertBitmap(CommonString.getImagesFolder(context) + pathforcheck);
|
||||
img_str = pathforcheck;
|
||||
pathforcheck = "";
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterSurvey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BASurveyListActivity extends AppCompatActivity {
|
||||
List<Integer> checkHeaderArray = new ArrayList<>();
|
||||
boolean checkflag = true;
|
||||
private SharedPreferences preferences;
|
||||
String username, date, counter_id = "", SurveyType;
|
||||
Lorealba_Database db;
|
||||
Toolbar toolbar;
|
||||
RecyclerView BAListView;
|
||||
ArrayList<MasterSurvey> listDataHeader;
|
||||
Context _context;
|
||||
BASurveyListAdapter adapter;
|
||||
JourneyPlan jcp_Object = new JourneyPlan();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_ba_survey_list);
|
||||
_context = this;
|
||||
preferences = PrefHelper.getPrefs(this);
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
if (!CommonFunctions.isTablet(_context)) {
|
||||
toolbar.setTitleTextAppearance(_context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
BAListView = (RecyclerView) findViewById(R.id.ba_survey_list);
|
||||
|
||||
db = new Lorealba_Database(_context);
|
||||
db.open();
|
||||
jcp_Object = db.getBIDfromJCP(username, counter_id);
|
||||
//Intent data
|
||||
if (getIntent().getStringExtra("SurveyType") != null) {
|
||||
SurveyType = getIntent().getStringExtra("SurveyType");
|
||||
}
|
||||
|
||||
if (SurveyType.equalsIgnoreCase("BA")) {
|
||||
db.open();
|
||||
listDataHeader = db.getBASurveySavedData("BA", jcp_Object, date);
|
||||
} else {
|
||||
db.open();
|
||||
listDataHeader = db.getBASurveySavedData("Counter", jcp_Object, date);
|
||||
}
|
||||
|
||||
if (listDataHeader.isEmpty()) {
|
||||
if (SurveyType.equalsIgnoreCase("BA")) {
|
||||
db.open();
|
||||
listDataHeader = db.getSurveyData("BA");
|
||||
} else {
|
||||
db.open();
|
||||
listDataHeader = db.getSurveyData("Counter");
|
||||
}
|
||||
}
|
||||
|
||||
adapter = new BASurveyListAdapter(_context, listDataHeader);
|
||||
BAListView.setLayoutManager(new LinearLayoutManager(_context));
|
||||
BAListView.setAdapter(adapter);
|
||||
|
||||
if (SurveyType.equalsIgnoreCase("BA")) {
|
||||
setTitle("BA Survey List - " + username);
|
||||
} else {
|
||||
setTitle("Counter Survey List - " + date);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (getIntent().getStringExtra("SurveyType") != null) {
|
||||
SurveyType = getIntent().getStringExtra("SurveyType");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
}
|
||||
|
||||
private class BASurveyListAdapter extends RecyclerView.Adapter<BASurveyListAdapter.ViewHolder> {
|
||||
Context context;
|
||||
ArrayList<MasterSurvey> listDataHeader;
|
||||
|
||||
public BASurveyListAdapter(Context context, ArrayList<MasterSurvey> listDataHeader) {
|
||||
this.context = context;
|
||||
this.listDataHeader = listDataHeader;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BASurveyListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.content_ba_survey_list_view, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BASurveyListAdapter.ViewHolder holder, final int pos) {
|
||||
final MasterSurvey object = listDataHeader.get(pos);
|
||||
holder.surveyName.setText(object.getSurveyName().trim());
|
||||
holder.surveyName.setId(pos);
|
||||
db.open();
|
||||
if (object.getUploadStatus() == 1) {
|
||||
holder.complete_icon.setVisibility(View.VISIBLE);
|
||||
holder.complete_icon.setId(pos);
|
||||
db.open();
|
||||
} else if (db.getSurveyUploadStatus(SurveyType, object.getSurveyId().toString(), username, counter_id)) {
|
||||
holder.complete_icon.setVisibility(View.VISIBLE);
|
||||
holder.complete_icon.setId(pos);
|
||||
} else {
|
||||
holder.complete_icon.setVisibility(View.GONE);
|
||||
holder.complete_icon.setId(pos);
|
||||
}
|
||||
|
||||
holder.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
db.open();
|
||||
if (object.getUploadStatus() == 1) {
|
||||
AlertandMessages.showToastMsg(context, "Survey Already Done");
|
||||
} else if (db.getSurveyUploadStatus(SurveyType, object.getSurveyId().toString(), username, counter_id)) {
|
||||
AlertandMessages.showToastMsg(context, "Survey Already Done");
|
||||
} else {
|
||||
startActivity(new Intent(context, BASurveyActivity.class).putExtra("SurveyId", listDataHeader.get(pos).getSurveyId().toString()).putExtra("SurveyType", SurveyType));
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
BASurveyListActivity.this.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return listDataHeader.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView surveyName;
|
||||
CardView cardView;
|
||||
ImageView complete_icon;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
surveyName = (TextView) itemView.findViewById(R.id.survey_name);
|
||||
cardView = (CardView) itemView.findViewById(R.id.survey_view);
|
||||
complete_icon = (ImageView) itemView.findViewById(R.id.complete_img);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2354
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,500 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
|
||||
import com.google.android.gms.common.api.ResolvableApiException;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationSettingsRequest;
|
||||
import com.google.android.gms.location.SettingsClient;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.download.Downloader;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cpm.lorealbaautomation.constant.CommonFunctions.getCurrentTime_only;
|
||||
import static com.cpm.lorealbaautomation.constant.CommonFunctions.show_image_preview;
|
||||
import static com.cpm.lorealbaautomation.dailyactivity.StoreImageActivity.convertBitmap;
|
||||
|
||||
public class CounterImageActivity extends AppCompatActivity implements
|
||||
View.OnClickListener {
|
||||
ImageView presetup_img_one, presetup_img_two, post_setup_img_one, post_setup_img_two,/*.......*/
|
||||
counter_img_one, counter_img_two;
|
||||
String _pathforcheck, _path, counter_id, visit_date, username, user_type;
|
||||
FloatingActionButton btn_save_selfie;
|
||||
private static final int REQUEST_LOCATION = 1;
|
||||
JourneyPlan counterimg_object = new JourneyPlan();
|
||||
LinearLayout layout_for_me_counterimg, layout_for_ba_counterimg;
|
||||
SharedPreferences preferences;
|
||||
private Lorealba_Database db;
|
||||
double lat = 0.0, lon = 0.0;
|
||||
boolean update_flag = false, click_flag = true;
|
||||
AlertDialog alert;
|
||||
Context context;
|
||||
private FusedLocationProviderClient fusedLocationClient;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_counter_image);
|
||||
context = this;
|
||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
getLastLocation();
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
validateuidata();
|
||||
}
|
||||
|
||||
private void getLastLocation() {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// Request location permissions
|
||||
return;
|
||||
}
|
||||
try {
|
||||
fusedLocationClient.getLastLocation()
|
||||
.addOnSuccessListener(this, location -> {
|
||||
if (location != null) {
|
||||
lat = location.getLatitude();
|
||||
lon = location.getLongitude();
|
||||
//test("Location", "Lat: " + lat + ", Lng: " + lon);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace(); //test("Location", "Lat: " + lat + ", Lng: " + lon);}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
private void validateuidata() {
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
user_type = preferences.getString(CommonString.KEY_USER_TYPE, "");
|
||||
presetup_img_one = (ImageView) findViewById(R.id.presetup_img_one);
|
||||
presetup_img_two = (ImageView) findViewById(R.id.presetup_img_two);
|
||||
post_setup_img_one = (ImageView) findViewById(R.id.post_setup_img_one);
|
||||
post_setup_img_two = (ImageView) findViewById(R.id.post_setup_img_two);
|
||||
btn_save_selfie = (FloatingActionButton) findViewById(R.id.btn_save_selfie);
|
||||
////new changes
|
||||
layout_for_me_counterimg = (LinearLayout) findViewById(R.id.layout_for_me_counterimg);
|
||||
layout_for_ba_counterimg = (LinearLayout) findViewById(R.id.layout_for_ba_counterimg);
|
||||
counter_img_one = (ImageView) findViewById(R.id.counter_img_one);
|
||||
counter_img_two = (ImageView) findViewById(R.id.counter_img_two);
|
||||
|
||||
presetup_img_one.setOnClickListener(this);
|
||||
presetup_img_two.setOnClickListener(this);
|
||||
post_setup_img_one.setOnClickListener(this);
|
||||
post_setup_img_two.setOnClickListener(this);
|
||||
btn_save_selfie.setOnClickListener(this);
|
||||
counter_img_one.setOnClickListener(this);
|
||||
counter_img_two.setOnClickListener(this);
|
||||
setTitle("Counter Image - " + visit_date);
|
||||
db.open();
|
||||
counterimg_object = db.getinserted_counter_images(counter_id, visit_date);
|
||||
if (!user_type.isEmpty() && user_type.equalsIgnoreCase("BA") || !user_type.isEmpty() && user_type.equalsIgnoreCase("TBA")) {
|
||||
if (counterimg_object != null && !counterimg_object.getCounter_img_onefor_ba().isEmpty() || !counterimg_object.getCounter_img_two_for_ba().isEmpty()) {
|
||||
btn_save_selfie.setVisibility(View.GONE);
|
||||
update_flag = true;
|
||||
validate_ui();
|
||||
}
|
||||
layout_for_ba_counterimg.setVisibility(View.VISIBLE);
|
||||
layout_for_me_counterimg.setVisibility(View.GONE);
|
||||
} else {
|
||||
layout_for_ba_counterimg.setVisibility(View.GONE);
|
||||
layout_for_me_counterimg.setVisibility(View.VISIBLE);
|
||||
if (counterimg_object != null && !counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
update_flag = true;
|
||||
validate_ui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
if (click_flag) {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterImageActivity.this.finish();
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id12) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterImageActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id1) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (click_flag) {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterImageActivity.this.finish();
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterImageActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
if (view.getId() == R.id.counter_img_one) {
|
||||
if (!update_flag) {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_counter_img_one_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null,
|
||||
false, CommonString.CAMERA_FACE_REAR);
|
||||
} else {
|
||||
show_image_preview(context, counterimg_object.getCounter_img_onefor_ba());
|
||||
}
|
||||
} else if (view.getId() == R.id.counter_img_two) {
|
||||
if (!update_flag) {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_counter_img_two_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
} else {
|
||||
if (!counterimg_object.getCounter_img_two_for_ba().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getCounter_img_two_for_ba());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.presetup_img_one) {
|
||||
if (update_flag) {
|
||||
if (counterimg_object != null && !counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getPresetup_img_one_str());
|
||||
}
|
||||
} else {
|
||||
if (counterimg_object != null && !counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getPresetup_img_one_str());
|
||||
} else {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_presetup_counter_img_one_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.presetup_img_two) {
|
||||
if (update_flag) {
|
||||
if (counterimg_object != null && !counterimg_object.getPresetup_img_two_str().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getPresetup_img_two_str());
|
||||
}
|
||||
} else {
|
||||
if (counterimg_object != null && !counterimg_object.getPresetup_img_two_str().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getPresetup_img_two_str());
|
||||
} else {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_presetup_counter_img_two_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.post_setup_img_one) {
|
||||
if (update_flag) {
|
||||
if (counterimg_object != null && !counterimg_object.getPostsetup_img_one_str().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getPostsetup_img_one_str());
|
||||
} else {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_postsetup_counter_img_one_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
}
|
||||
|
||||
} else if (counterimg_object != null && !counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_postsetup_counter_img_one_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.post_setup_img_two) {
|
||||
if (update_flag) {
|
||||
if (counterimg_object != null && !counterimg_object.getPostsetup_img_two_str().isEmpty()) {
|
||||
show_image_preview(context, counterimg_object.getPostsetup_img_two_str());
|
||||
} else {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_possetup_counter_img_two_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
}
|
||||
} else if (counterimg_object != null && !counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
click_flag = false;
|
||||
_pathforcheck = counter_id + "_possetup_counter_img_two_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.btn_save_selfie) {
|
||||
if (validateimg_str()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(R.string.dialog_title).setMessage(R.string.title_activity_save_data).setCancelable(false)
|
||||
.setPositiveButton(android.R.string.yes, (dialog, id1) -> {
|
||||
alert.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
db.open();
|
||||
if (!user_type.isEmpty() && user_type.equalsIgnoreCase(CommonString.TAG_FROM_BA)
|
||||
|| !user_type.isEmpty() && user_type.equalsIgnoreCase(CommonString.TAG_FROM_TBA)) {
|
||||
counterimg_object.setTransId(CommonFunctions.getUUID(context));
|
||||
db.insertcounteruserdata(counter_id, username, visit_date, counterimg_object, user_type);
|
||||
//download service
|
||||
Intent intent = new Intent(context, Downloader.class);
|
||||
intent.putExtra(CommonString.KEY_BA_Counter_Image, counterimg_object);
|
||||
Downloader.enqueueWork(context, intent);
|
||||
} else {
|
||||
db.open();
|
||||
if (update_flag) {
|
||||
counterimg_object.setTransId(CommonFunctions.getUUID(context));
|
||||
db.update_CounterImage(counter_id, username, visit_date, counterimg_object);
|
||||
} else {
|
||||
counterimg_object.setTransId(CommonFunctions.getUUID(context));
|
||||
db.insertcounteruserdata(counter_id, username, visit_date, counterimg_object, user_type);
|
||||
}
|
||||
Intent intent = new Intent(context, Downloader.class);
|
||||
intent.putExtra(CommonString.KEY_Me_Counter_Image, counterimg_object);
|
||||
Downloader.enqueueWork(context, intent);
|
||||
}
|
||||
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
AlertandMessages.showToastMsg(context, "Data saved successfully.");
|
||||
CounterImageActivity.this.finish();
|
||||
}).setNegativeButton(android.R.string.cancel, (dialog, id12) -> dialog.cancel());
|
||||
|
||||
alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.i("MakeMachine", "resultCode: " + resultCode);
|
||||
switch (resultCode) {
|
||||
|
||||
case 0:
|
||||
Log.i("MakeMachine", "User cancelled");
|
||||
break;
|
||||
|
||||
case -1:
|
||||
if (_pathforcheck != null && !_pathforcheck.isEmpty()) {
|
||||
if (new File(CommonString.getImagesFolder(context) + _pathforcheck).exists()) {
|
||||
convertBitmap(CommonString.getImagesFolder(context) + _pathforcheck);
|
||||
try {
|
||||
if (_pathforcheck.contains("_presetup_counter_img_one_")) {
|
||||
presetup_img_one.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setPresetup_img_one_str(_pathforcheck);
|
||||
|
||||
} else if (_pathforcheck.contains("_presetup_counter_img_two_")) {
|
||||
presetup_img_two.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setPresetup_img_two_str(_pathforcheck);
|
||||
|
||||
} else if (_pathforcheck.contains("_postsetup_counter_img_one_")) {
|
||||
post_setup_img_one.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setPostsetup_img_one_str(_pathforcheck);
|
||||
|
||||
} else if (_pathforcheck.contains("_possetup_counter_img_two_")) {
|
||||
post_setup_img_two.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setPostsetup_img_two_str(_pathforcheck);
|
||||
} else if (_pathforcheck.contains("_counter_img_one_")) {
|
||||
counter_img_one.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setCounter_img_onefor_ba(_pathforcheck);
|
||||
} else if (_pathforcheck.contains("_counter_img_two_")) {
|
||||
counter_img_two.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setCounter_img_two_for_ba(_pathforcheck);
|
||||
}
|
||||
|
||||
} catch (OutOfMemoryError ex) {
|
||||
ex.fillInStackTrace();
|
||||
}
|
||||
|
||||
_pathforcheck = "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private void validate_ui() {
|
||||
if (!counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
presetup_img_one.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
if (!counterimg_object.getPresetup_img_two_str().isEmpty()) {
|
||||
presetup_img_two.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
if (!counterimg_object.getPostsetup_img_one_str().isEmpty()) {
|
||||
post_setup_img_one.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
if (!counterimg_object.getPostsetup_img_two_str().isEmpty()) {
|
||||
post_setup_img_two.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
if (!counterimg_object.getCounter_img_onefor_ba().isEmpty()) {
|
||||
counter_img_one.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
if (!counterimg_object.getCounter_img_two_for_ba().isEmpty()) {
|
||||
counter_img_two.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean validateimg_str() {
|
||||
boolean status = true;
|
||||
if (user_type != null && user_type.equalsIgnoreCase("BA") || user_type != null && user_type.equalsIgnoreCase("TBA")) {
|
||||
if (!counterimg_object.getCounter_img_onefor_ba().isEmpty()) {
|
||||
status = true;
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(context, "Please click Counter Images");
|
||||
status = false;
|
||||
}
|
||||
} else {
|
||||
if (!update_flag) {
|
||||
if (counterimg_object.getPresetup_img_one_str().isEmpty()) {
|
||||
AlertandMessages.showToastMsg(context, "Please click Pre Set-Up Counter Images");
|
||||
status = false;
|
||||
}
|
||||
} else if (counterimg_object.getPostsetup_img_one_str().isEmpty()) {
|
||||
AlertandMessages.showToastMsg(context, "Please click Post Set-Up Counter Images");
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
checkgpsEnableDevice();
|
||||
createLocationRequest();
|
||||
}
|
||||
|
||||
@SuppressLint("VisibleForTests")
|
||||
protected void createLocationRequest() {
|
||||
LocationRequest mLocationRequest = new LocationRequest();
|
||||
// Location updates intervals in sec
|
||||
// 5 sec
|
||||
int UPDATE_INTERVAL = 5000;
|
||||
mLocationRequest.setInterval(UPDATE_INTERVAL);
|
||||
// 1 sec
|
||||
int FATEST_INTERVAL = 1000;
|
||||
mLocationRequest.setFastestInterval(FATEST_INTERVAL);
|
||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
// 10 meters
|
||||
int DISPLACEMENT = 5;
|
||||
mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
|
||||
}
|
||||
|
||||
private void checkgpsEnableDevice() {
|
||||
if (!hasGPSDevice(context)) {
|
||||
Toast.makeText(context, "Gps not Supported", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(context)) {
|
||||
enableLocationSettings();
|
||||
} else {
|
||||
if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
hasGPSDevice(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void enableLocationSettings() {
|
||||
@SuppressLint("VisibleForTests") LocationRequest locationRequest = LocationRequest.create()
|
||||
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) // new Priority constant
|
||||
.setInterval(30 * 1000)
|
||||
.setFastestInterval(5 * 1000);
|
||||
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
|
||||
.addLocationRequest(locationRequest)
|
||||
.setAlwaysShow(true); // show dialog if GPS is off
|
||||
|
||||
SettingsClient settingsClient = LocationServices.getSettingsClient(this);
|
||||
|
||||
settingsClient.checkLocationSettings(builder.build())
|
||||
.addOnSuccessListener(locationSettingsResponse -> {
|
||||
// All location settings are satisfied. You can request location updates here.
|
||||
}).addOnFailureListener(e -> {
|
||||
if (e instanceof ResolvableApiException) {
|
||||
try {
|
||||
ResolvableApiException resolvable = (ResolvableApiException) e;
|
||||
resolvable.startResolutionForResult((Activity) context, REQUEST_LOCATION);
|
||||
} catch (IntentSender.SendIntentException sendEx) {
|
||||
// Ignore the error.
|
||||
sendEx.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean hasGPSDevice(Context context) {
|
||||
final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
if (mgr == null)
|
||||
return false;
|
||||
final List<String> providers = mgr.getAllProviders();
|
||||
if (providers == null)
|
||||
return false;
|
||||
return providers.contains(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
}
|
||||
+440
@@ -0,0 +1,440 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.download.Downloader;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.cpm.lorealbaautomation.constant.CommonFunctions.getCurrentTime;
|
||||
import static com.cpm.lorealbaautomation.dailyactivity.StoreImageActivity.convertBitmap;
|
||||
|
||||
public class CounterProfileActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
private LinearLayout lay_counter_ageing;
|
||||
private TextView edt_ageing, counter_type, countersetup_date;
|
||||
private EditText edt_width, edt_hight;
|
||||
private ImageView image1, image2, date, img_main;
|
||||
Toolbar toolbar;
|
||||
FloatingActionButton fab;
|
||||
String _pathforcheck, _path, counter_id, visit_date, username, user_type, dob, newvalueDate = "";
|
||||
ArrayList<JourneyPlan> storelist = new ArrayList<>();
|
||||
SharedPreferences preferences;
|
||||
SharedPreferences.Editor editor = null;
|
||||
private Lorealba_Database db;
|
||||
AlertDialog alert;
|
||||
Context context;
|
||||
JourneyPlan counterimg_object = new JourneyPlan();
|
||||
int mYear, mMonth, mDay;
|
||||
DatePickerDialog dpd;
|
||||
Calendar c;
|
||||
Dialog dialog1;
|
||||
WebView webview;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_counter_profile);
|
||||
context = this;
|
||||
((CounterProfileActivity) context).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
getViewId();
|
||||
getSetData();
|
||||
}
|
||||
|
||||
void getViewId() {
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
editor = preferences.edit();
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
user_type = preferences.getString(CommonString.KEY_USER_TYPE, "");
|
||||
|
||||
countersetup_date = (TextView) findViewById(R.id.storeProfile_dob);
|
||||
edt_ageing = (TextView) findViewById(R.id.edt_ageing);
|
||||
counter_type = (TextView) findViewById(R.id.counter_type);
|
||||
edt_width = (EditText) findViewById(R.id.edt_width);
|
||||
edt_hight = (EditText) findViewById(R.id.edt_hight);
|
||||
|
||||
image1 = (ImageView) findViewById(R.id.image1);
|
||||
image2 = (ImageView) findViewById(R.id.image2);
|
||||
date = (ImageView) findViewById(R.id.date);
|
||||
lay_counter_ageing = (LinearLayout) findViewById(R.id.lay_counter_ageing);
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setTitle("Counter Profile - " + visit_date);
|
||||
fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(this);
|
||||
image1.setOnClickListener(this);
|
||||
image2.setOnClickListener(this);
|
||||
date.setOnClickListener(this);
|
||||
image1.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bs));
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.i("MakeMachine", "resultCode: " + resultCode);
|
||||
switch (resultCode) {
|
||||
|
||||
case 0:
|
||||
Log.i("MakeMachine", "User cancelled");
|
||||
break;
|
||||
|
||||
case -1:
|
||||
if (_pathforcheck != null && !_pathforcheck.isEmpty()) {
|
||||
if (new File(CommonString.getImagesFolder(context) + _pathforcheck).exists()) {
|
||||
convertBitmap(CommonString.getImagesFolder(context) + _pathforcheck);
|
||||
if (_pathforcheck.contains("_cp_img_one_")) {
|
||||
image1.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setProfileImage1(_pathforcheck);
|
||||
|
||||
} else if (_pathforcheck.contains("_cp_img_two_")) {
|
||||
image2.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
counterimg_object.setProfileImage2(_pathforcheck);
|
||||
}
|
||||
|
||||
_pathforcheck = "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
private boolean validateimg_str() {
|
||||
boolean status = true;
|
||||
if (counterimg_object.getProfileImage1() == null && counterimg_object.getProfileImage2() == null) {
|
||||
AlertandMessages.showToastMsg(context, "Please Click Any Profile Imges");
|
||||
status = false;
|
||||
} else if (edt_hight.getText().toString().isEmpty()) {
|
||||
AlertandMessages.showToastMsg(context, "Please Fill Counter Dimensions Height In (Feet)");
|
||||
status = false;
|
||||
} else if (edt_width.getText().toString().isEmpty()) {
|
||||
AlertandMessages.showToastMsg(context, "Please Fill Counter Dimensions Width In (Feet)");
|
||||
status = false;
|
||||
} else if (countersetup_date.getText().toString().isEmpty()) {
|
||||
AlertandMessages.showToastMsg(context, "Please Select Counter Set Up Date");
|
||||
status = false;
|
||||
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.image1) {
|
||||
_pathforcheck = counter_id + "_cp_img_one_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null,
|
||||
false, CommonString.CAMERA_FACE_REAR);
|
||||
} else if (view.getId() == R.id.image2) {
|
||||
_pathforcheck = counter_id + "_cp_img_two_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
} else if (view.getId() == R.id.date) {
|
||||
c = Calendar.getInstance();
|
||||
mYear = c.get(Calendar.YEAR);
|
||||
mMonth = c.get(Calendar.MONTH);
|
||||
mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
// Launch Date Picker Dialog
|
||||
//mm dd yy
|
||||
dpd = new DatePickerDialog(this, (_view, year, monthOfYear, dayOfMonth) -> {
|
||||
dob = (monthOfYear + 1) + "/" + dayOfMonth + "/" + year;
|
||||
lay_counter_ageing.setVisibility(View.VISIBLE);
|
||||
Date counterAgeing_date = null, current_date = null;
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
||||
if (!dob.isEmpty()) {
|
||||
String str_monthofYears = "", str_dayofmonth = "";
|
||||
int monthofyears = monthOfYear + 1;
|
||||
if (monthofyears < 10) {
|
||||
str_monthofYears = "0" + monthofyears;
|
||||
} else {
|
||||
str_monthofYears = "" + monthofyears;
|
||||
}
|
||||
|
||||
if (dayOfMonth < 10) {
|
||||
str_dayofmonth = "0" + dayOfMonth;
|
||||
} else {
|
||||
str_dayofmonth = "" + dayOfMonth;
|
||||
}
|
||||
|
||||
newvalueDate = str_monthofYears + "/" + str_dayofmonth + "/" + year;
|
||||
countersetup_date.setText(newvalueDate);
|
||||
}
|
||||
try {
|
||||
counterAgeing_date = dateFormat.parse(newvalueDate);
|
||||
current_date = dateFormat.parse(visit_date);
|
||||
printDifference(current_date, counterAgeing_date);
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}, mYear, mMonth, mDay);
|
||||
dpd.getDatePicker().setMaxDate(System.currentTimeMillis());
|
||||
dpd.show();
|
||||
} else if (view.getId() == R.id.fab) {
|
||||
if (validateimg_str()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(R.string.dialog_title).setMessage(R.string.title_activity_save_data).setCancelable(false)
|
||||
.setPositiveButton(android.R.string.yes, (dialog, id1) -> {
|
||||
alert.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
db.open();
|
||||
counterimg_object.setSetupDate(newvalueDate);
|
||||
double counter_width = 0.0, counter_lenth = 0.0;
|
||||
String str_width = edt_width.getText().toString().trim().replaceAll("[(!@#$%^&*?)\"]", "");
|
||||
String str_lenth = edt_hight.getText().toString().trim().replaceAll("[(!@#$%^&*?)\"]", "");
|
||||
if (!str_width.isEmpty()) {
|
||||
counter_width = Double.parseDouble(str_width);
|
||||
}
|
||||
|
||||
if (!str_lenth.isEmpty()) {
|
||||
counter_lenth = Double.parseDouble(str_lenth);
|
||||
}
|
||||
|
||||
counterimg_object.setCounterwidth(counter_width);
|
||||
counterimg_object.setCounterlength(counter_lenth);
|
||||
String status = CommonString.KEY_N;
|
||||
String uuid_Id = CommonFunctions.getUUID(context);
|
||||
db.open();
|
||||
db.insertCounterProfiledata(counter_id, username, user_type, visit_date, counterimg_object, status, uuid_Id);
|
||||
|
||||
//download service
|
||||
Intent intent = new Intent(context, Downloader.class);
|
||||
intent.putExtra(CommonString.KEY_CounterProfile, counterimg_object);
|
||||
Downloader.enqueueWork(CounterProfileActivity.this, intent);
|
||||
|
||||
AlertandMessages.showToastMsg(context, "Data saved successfully.");
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterProfileActivity.this.finish();
|
||||
|
||||
}).setNegativeButton(android.R.string.cancel, (dialog, id12) -> dialog.cancel());
|
||||
|
||||
alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id1) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterProfileActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id12) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
CounterProfileActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
private void popup(final String window_image) {
|
||||
dialog1 = new Dialog(CounterProfileActivity.this);
|
||||
dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog1.setContentView(R.layout.dialog_refrence_image);
|
||||
webview = (WebView) dialog1.findViewById(R.id.webview);
|
||||
img_main = (ImageView) dialog1.findViewById(R.id.img_main);
|
||||
// dialog1.setCancelable(false);
|
||||
dialog1.setCanceledOnTouchOutside(true);
|
||||
webview.setWebViewClient(new MyWebViewClient());
|
||||
webview.getSettings().setJavaScriptEnabled(true);
|
||||
if (window_image != null) {
|
||||
webview.loadUrl(window_image);
|
||||
}
|
||||
|
||||
dialog1.show();
|
||||
}
|
||||
|
||||
private class MyWebViewClient extends WebViewClient {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
webview.setVisibility(View.VISIBLE);
|
||||
super.onPageFinished(view, url);
|
||||
view.clearCache(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint({"SetTextI18n", "UseCompatLoadingForDrawables"})
|
||||
void getSetData() {
|
||||
db.open();
|
||||
storelist = db.getStoreData(visit_date, null, counter_id);
|
||||
counterimg_object = db.getCounterProfileData(null, visit_date, counter_id, true);
|
||||
if (counterimg_object.getUserId() != null && !counterimg_object.getUserId().isEmpty()) {
|
||||
edt_hight.setText("" + counterimg_object.getCounterlength());
|
||||
edt_width.setText("" + counterimg_object.getCounterwidth());
|
||||
if (counterimg_object.getProfileImage1() != null) {
|
||||
image1.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
fab.setImageDrawable(ContextCompat.getDrawable(context, R.mipmap.edit));
|
||||
lay_counter_ageing.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
edt_ageing.setText(counterimg_object.getStoreName() + " Days");
|
||||
counterimg_object.setStoreName(counterimg_object.getStoreName());
|
||||
countersetup_date.setText(counterimg_object.getSetupDate());
|
||||
newvalueDate = counterimg_object.getSetupDate();
|
||||
if (counterimg_object.getProfileImage2() != null) {
|
||||
image2.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
if (!storelist.isEmpty()) {
|
||||
counter_type.setText(storelist.get(0).getStoreTypeName());
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!storelist.isEmpty()) {
|
||||
edt_hight.setText("" + storelist.get(0).getCounterlength());
|
||||
edt_width.setText("" + storelist.get(0).getCounterwidth());
|
||||
if (storelist.get(0).getStoreTypeName().isEmpty()) {
|
||||
} else {
|
||||
counter_type.setText(storelist.get(0).getStoreTypeName());
|
||||
}
|
||||
if (storelist.get(0).getProfileImage1().isEmpty()) {
|
||||
image1.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bs));
|
||||
} else {
|
||||
counterimg_object.setProfileImage1(storelist.get(0).getProfileImage1());
|
||||
image1.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
if (storelist.get(0).getProfileImage2().isEmpty()) {
|
||||
image2.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bs));
|
||||
} else {
|
||||
counterimg_object.setProfileImage2(storelist.get(0).getProfileImage2());
|
||||
image2.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
|
||||
//////////parshing date and counter agaiging.......
|
||||
if (!storelist.get(0).getSetupDate().isEmpty()) {
|
||||
counterimg_object.setSetupDate(storelist.get(0).getSetupDate());
|
||||
countersetup_date.setText(storelist.get(0).getSetupDate());
|
||||
Date counterAgeing_date = null, current_date = null;
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
||||
try {
|
||||
counterAgeing_date = dateFormat.parse(storelist.get(0).getSetupDate());
|
||||
current_date = dateFormat.parse(visit_date);
|
||||
printDifference(current_date, counterAgeing_date);
|
||||
lay_counter_ageing.setVisibility(View.VISIBLE);
|
||||
newvalueDate = storelist.get(0).getSetupDate();
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
} else {
|
||||
edt_ageing.setText("0 Days");
|
||||
counterimg_object.setSetupDate("");
|
||||
countersetup_date.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getDateDiff(SimpleDateFormat format, String oldDate, String newDate) {
|
||||
try {
|
||||
return TimeUnit.DAYS.convert(Objects.requireNonNull(format.parse(newDate)).getTime() - Objects.requireNonNull(format.parse(oldDate)).getTime(), TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void printDifference(Date startDate, Date endDate) {
|
||||
try {
|
||||
long different = startDate.getTime() - endDate.getTime();
|
||||
long secondsInMilli = 1000;
|
||||
long minutesInMilli = secondsInMilli * 60;
|
||||
long hoursInMilli = minutesInMilli * 60;
|
||||
long daysInMilli = hoursInMilli * 24;
|
||||
long elapsedDays = different / daysInMilli;
|
||||
different = different % daysInMilli;
|
||||
long elapsedHours = different / hoursInMilli;
|
||||
different = different % hoursInMilli;
|
||||
long elapsedMinutes = different / minutesInMilli;
|
||||
different = different % minutesInMilli;
|
||||
long elapsedSeconds = different / secondsInMilli;
|
||||
System.out.printf("%d days, %d hours, %d minutes, %d seconds%n", elapsedDays, elapsedHours, elapsedMinutes, elapsedSeconds);
|
||||
edt_ageing.setText((int) elapsedDays + " Days ");
|
||||
counterimg_object.setStoreName(String.valueOf(elapsedDays));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+101
@@ -0,0 +1,101 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
|
||||
public class DamagedCategoryActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
AlertDialog alert;
|
||||
private SharedPreferences preferences;
|
||||
CardView damaged_stock_img, returnto_distributor_damaged;
|
||||
String counter_id, visit_date, username, _pathforcheck, _path;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_damaged_category);
|
||||
context = this;
|
||||
((DamagedCategoryActivity) context).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
|
||||
returnto_distributor_damaged = (CardView) findViewById(R.id.returnto_distributor_damaged);
|
||||
damaged_stock_img = (CardView) findViewById(R.id.damaged_stock_img);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setTitle("Damaged Stock Category - " + visit_date);
|
||||
|
||||
|
||||
String couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
TextView txt_counter_code = (TextView) findViewById(R.id.txt_counter_code);
|
||||
txt_counter_code.setText("Counter Code - " + couter_code + " / Id - " + counter_id);
|
||||
damaged_stock_img.setOnClickListener(this);
|
||||
returnto_distributor_damaged.setOnClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.damaged_stock_img) {
|
||||
startActivity(new Intent(context, DamagedActivity.class).putExtra(CommonString.TAG_OBJECT, "1"));
|
||||
} else if (view.getId() == R.id.returnto_distributor_damaged) {
|
||||
startActivity(new Intent(context, DamagedActivity.class).putExtra(CommonString.TAG_OBJECT, "0"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
DamagedCategoryActivity.this.finish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
DamagedCategoryActivity.this.finish();
|
||||
|
||||
}
|
||||
}
|
||||
+1507
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,578 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.download.Downloader;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.GroomingGetterSetter;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cpm.lorealbaautomation.constant.CommonFunctions.getCurrentTime_only;
|
||||
import static com.cpm.lorealbaautomation.constant.CommonFunctions.show_image_preview;
|
||||
import static com.cpm.lorealbaautomation.dailyactivity.StoreImageActivity.convertBitmap;
|
||||
|
||||
public class GroomedActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
ImageView grooming_img_morng, grooming_img_noon, grooming_img_evning;
|
||||
TextView time_morng_txt, time_noon_txt, time_evning_txt;
|
||||
CardView cardview_evening, card_noon, card_morning;
|
||||
FloatingActionButton btn_save;
|
||||
TextView txt_login_tym;
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
AlertDialog alert;
|
||||
String counter_id, visit_date, username, _pathforcheck, _path, loginTym = "";
|
||||
SimpleDateFormat simpleDateFormat;
|
||||
boolean update_flag = false, clicked_flag = false;
|
||||
GroomingGetterSetter groomedObject = new GroomingGetterSetter();
|
||||
boolean click_camera = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_groomed);
|
||||
context = this;
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
validateuidata();
|
||||
validateinserted_data();
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void validateuidata() {
|
||||
SharedPreferences preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
grooming_img_morng = (ImageView) findViewById(R.id.grooming_img_morng);
|
||||
grooming_img_noon = (ImageView) findViewById(R.id.grooming_img_noon);
|
||||
grooming_img_evning = (ImageView) findViewById(R.id.grooming_img_evning);
|
||||
btn_save = (FloatingActionButton) findViewById(R.id.btn_save);
|
||||
txt_login_tym = (TextView) findViewById(R.id.txt_login_tym);
|
||||
|
||||
cardview_evening = (CardView) findViewById(R.id.cardview_evening);
|
||||
card_noon = (CardView) findViewById(R.id.card_noon);
|
||||
card_morning = (CardView) findViewById(R.id.card_morning);
|
||||
|
||||
///for timer
|
||||
time_morng_txt = (TextView) findViewById(R.id.time_morng_txt);
|
||||
time_noon_txt = (TextView) findViewById(R.id.time_noon_txt);
|
||||
time_evning_txt = (TextView) findViewById(R.id.time_evning_txt);
|
||||
setTitle("Grooming Image -" + username);
|
||||
|
||||
grooming_img_morng.setOnClickListener(this);
|
||||
grooming_img_noon.setOnClickListener(this);
|
||||
grooming_img_evning.setOnClickListener(this);
|
||||
|
||||
btn_save.setOnClickListener(this);
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
if (loginTym != null && !loginTym.isEmpty()) {
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
if (loginTym != null) {
|
||||
txt_login_tym.setText("Login Time - " + loginTym);
|
||||
} else {
|
||||
txt_login_tym.setText("Login Time - " + CommonFunctions.getCurrentTime_only());
|
||||
}
|
||||
} else {
|
||||
txt_login_tym.setText("Login Time - " + CommonFunctions.getCurrentTime_only());
|
||||
}
|
||||
add_time_for_showat_text();
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void add_time_for_showat_text() {
|
||||
try {
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
if (loginTym != null && !loginTym.isEmpty()) {
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
if (loginTym != null && !loginTym.isEmpty()) {
|
||||
time_morng_txt.setText("Before " + addtime_str(loginTym, 45, 0));
|
||||
}
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
if (loginTym != null && !loginTym.isEmpty()) {
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
if (loginTym != null && !loginTym.isEmpty())
|
||||
time_noon_txt.setText("Between " + addtime_str(loginTym, 0, 03) + " - " + addtime_str(loginTym, 10, 03));
|
||||
}
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
if (loginTym != null && !loginTym.isEmpty()) {
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
if (loginTym != null && !loginTym.isEmpty())
|
||||
time_evning_txt.setText("Between " + addtime_str(loginTym, 0, 06) + " - " + addtime_str(loginTym, 10, 06));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
if (clicked_flag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id1) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
GroomedActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id12) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
GroomedActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (clicked_flag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(CommonString.ONBACK_ALERT_MESSAGE).setCancelable(false).setPositiveButton("Ok",
|
||||
(dialog, id) -> {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
GroomedActivity.this.finish();
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
GroomedActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
if (view.getId() == R.id.grooming_img_morng) {
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = null;
|
||||
////for morning tym after Added 45 minutes
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
if (loginTym != null && !loginTym.isEmpty()) {
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
assert loginTym != null && !loginTym.isEmpty();
|
||||
String morngTym = addtime_str(loginTym, 59, 2);
|
||||
assert !morngTym.isEmpty();
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(morngTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
assert date2 != null;
|
||||
if (date2.before(date1)) {
|
||||
if (groomedObject.getMorning_groom_img_str().equals("")) {
|
||||
clicked_flag = true;
|
||||
_pathforcheck = counter_id + "_groomed_img_mrng_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
} else {
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_FRONT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!groomedObject.getMorning_groom_img_str().isEmpty()) {
|
||||
show_image_preview(context, groomedObject.getMorning_groom_img_str());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (NumberFormatException | ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
} else if (view.getId() == R.id.grooming_img_noon) {
|
||||
try {
|
||||
////for nooo tym after adding 03:10
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
String noonTym = addtime_str(loginTym, 0, 03);
|
||||
String endNoonTym = addtime_str(loginTym, 59, 05);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(noonTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
Date date3 = simpleDateFormat.parse(endNoonTym);
|
||||
assert date2 != null;
|
||||
if (date2.after(date1) && date2.before(date3)) {
|
||||
if (groomedObject.getNoon_groom_img_str().equals("")) {
|
||||
clicked_flag = true;
|
||||
_pathforcheck = counter_id + "_groomed_img_noon_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
} else {
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_FRONT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!groomedObject.getNoon_groom_img_str().equals("")) {
|
||||
show_image_preview(context, groomedObject.getNoon_groom_img_str());
|
||||
}
|
||||
} catch (NumberFormatException | ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
} else if (view.getId() == R.id.grooming_img_evning) {
|
||||
try {
|
||||
////for evenning tym after adding 03:10
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
String evngTym = addtime_str(loginTym, 0, 06);
|
||||
String EndevngTym = addtime_str(loginTym, 59, 8);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(evngTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
Date date3 = simpleDateFormat.parse(EndevngTym);
|
||||
assert date2 != null;
|
||||
if (date2.after(date1) && date2.before(date3)) {
|
||||
if (groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
clicked_flag = true;
|
||||
_pathforcheck = counter_id + "_groomed_img_evning_" + visit_date.replace("/", "") + "_" + getCurrentTime_only().replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
if (CommonFunctions.isTablet(context)) {
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_REAR);
|
||||
} else {
|
||||
CommonFunctions.startAnncaCameraActivity(this, _path, null, false, CommonString.CAMERA_FACE_FRONT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
show_image_preview(context, groomedObject.getEvenning_groom_img_str());
|
||||
}
|
||||
} catch (NumberFormatException | ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
} else if (view.getId() == R.id.btn_save) {
|
||||
if (validategroomedimg() && click_camera) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(R.string.dialog_title).setMessage(R.string.title_activity_save_data).setCancelable(false).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
alert.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
db.open();
|
||||
if (update_flag) {
|
||||
db.open();
|
||||
db.update_Groomed_images(counter_id, username, visit_date, groomedObject, CommonFunctions.getUUID(context));
|
||||
} else {
|
||||
db.open();
|
||||
db.inseetgroomingdata(counter_id, username, visit_date, groomedObject);
|
||||
|
||||
}
|
||||
//download service
|
||||
Intent intent = new Intent(context, Downloader.class);
|
||||
intent.putExtra(CommonString.KEY_Groomed_Image, groomedObject);
|
||||
Downloader.enqueueWork(context, intent);
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
AlertandMessages.showToastMsg(context, "Data saved successfully.");
|
||||
GroomedActivity.this.finish();
|
||||
}
|
||||
}).setNegativeButton(android.R.string.cancel, (dialog, id1) -> dialog.cancel());
|
||||
|
||||
alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.i("MakeMachine", "resultCode: " + resultCode);
|
||||
switch (resultCode) {
|
||||
|
||||
case 0:
|
||||
Log.i("MakeMachine", "User cancelled");
|
||||
break;
|
||||
|
||||
case -1:
|
||||
if (_pathforcheck != null && !_pathforcheck.equals("")) {
|
||||
if (new File(CommonString.getImagesFolder(context) + _pathforcheck).exists()) {
|
||||
try {
|
||||
convertBitmap(CommonString.getImagesFolder(context) + _pathforcheck);
|
||||
if (_pathforcheck.contains("_groomed_img_mrng_")) {
|
||||
grooming_img_morng.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
groomedObject.setMorning_groom_img_str(_pathforcheck);
|
||||
groomedObject.setMorning_groom_time_str(getCurrentTime_only());
|
||||
click_camera = true;
|
||||
} else if (_pathforcheck.contains("_groomed_img_noon_")) {
|
||||
grooming_img_noon.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
groomedObject.setNoon_groom_img_str(_pathforcheck);
|
||||
groomedObject.setNoon_groom_time_str(getCurrentTime_only());
|
||||
click_camera = true;
|
||||
} else if (_pathforcheck.contains("_groomed_img_evning_")) {
|
||||
grooming_img_evning.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
groomedObject.setEvenning_groom_img_str(_pathforcheck);
|
||||
groomedObject.setEvenning_groom_time_str(getCurrentTime_only());
|
||||
click_camera = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.fillInStackTrace();
|
||||
|
||||
AlertandMessages.showToastMsg(context, "Error");
|
||||
}
|
||||
|
||||
_pathforcheck = "";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
|
||||
private boolean validategroomedimg() {
|
||||
boolean status = true;
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = null;
|
||||
////for morning tym after Added 45 minutes
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
String morngTym = addtime_str(loginTym, 59, 2);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(morngTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
|
||||
////for nooo tym after adding 03:10
|
||||
String noonTym = addtime_str(loginTym, 0, 03);
|
||||
String endNoonTym = addtime_str(loginTym, 59, 05);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date noondate1 = simpleDateFormat.parse(noonTym);
|
||||
Date noondate2 = simpleDateFormat.parse(getTime());
|
||||
Date noondate3 = simpleDateFormat.parse(endNoonTym);
|
||||
|
||||
String evngTym = addtime_str(loginTym, 0, 06);
|
||||
String EndevngTym = addtime_str(loginTym, 59, 8);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date evngdate1 = simpleDateFormat.parse(evngTym);
|
||||
Date evngdate2 = simpleDateFormat.parse(getTime());
|
||||
Date evngdate3 = simpleDateFormat.parse(EndevngTym);
|
||||
|
||||
assert date2 != null;
|
||||
if (date2.before(date1)) {
|
||||
if (groomedObject.getMorning_groom_img_str().equals("")) {
|
||||
AlertandMessages.showToastMsg(context, "Please Capture Full Grooming Image Before " + addtime_str(loginTym, 45, 0));
|
||||
status = false;
|
||||
}
|
||||
} else {
|
||||
assert noondate2 != null;
|
||||
if (noondate2.after(noondate1) && noondate2.before(noondate3)) {
|
||||
if (groomedObject.getNoon_groom_img_str().equals("")) {
|
||||
AlertandMessages.showToastMsg(context, "Please Capture Full Grooming Image Between " + addtime_str(loginTym, 0, 3) + " - " + addtime_str(loginTym, 59, 5));
|
||||
status = false;
|
||||
}
|
||||
} else {
|
||||
assert evngdate2 != null;
|
||||
if (evngdate2.after(evngdate1) && evngdate2.before(evngdate3)) {
|
||||
if (groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
AlertandMessages.showToastMsg(context, "Please Capture Full Grooming Image Between " + addtime_str(loginTym, 0, 6) + " - " + addtime_str(loginTym, 59, 8));
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private void validateinserted_data() {
|
||||
db.open();
|
||||
groomedObject = db.getinserted_groomingdata(counter_id, username, visit_date);
|
||||
if (!groomedObject.getMorning_groom_img_str().equals("") || !groomedObject.getNoon_groom_img_str().equals("") || !groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
update_flag = true;
|
||||
if (!groomedObject.getMorning_groom_img_str().equals("")) {
|
||||
grooming_img_morng.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
if (!groomedObject.getNoon_groom_img_str().equals("")) {
|
||||
grooming_img_noon.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
if (!groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
grooming_img_evning.setImageDrawable(getResources().getDrawable(R.mipmap.camera_bsd));
|
||||
}
|
||||
|
||||
}
|
||||
/////for disable
|
||||
groomingimg_morng();
|
||||
groomedNoonImg();
|
||||
groomedeveningimg();
|
||||
}
|
||||
|
||||
|
||||
private String addtime_str(String str, int minuts, int hours) {
|
||||
SimpleDateFormat displayFormat = null;
|
||||
SimpleDateFormat parseFormat = null;
|
||||
Calendar calendar = null;
|
||||
Date date = null;
|
||||
try {
|
||||
parseFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
displayFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
date = parseFormat.parse(str);
|
||||
calendar = Calendar.getInstance();
|
||||
assert date != null;
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.HOUR, hours);
|
||||
calendar.add(Calendar.MINUTE, minuts);
|
||||
//test(displayFormat.format(calendar.getTime()));
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
assert calendar != null;
|
||||
return displayFormat.format(calendar.getTime());
|
||||
}
|
||||
|
||||
private String getTime() {
|
||||
Calendar currnetDateTime = Calendar.getInstance();
|
||||
SimpleDateFormat df = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
return df.format(currnetDateTime.getTime());
|
||||
}
|
||||
|
||||
private void groomingimg_morng() {
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = null;
|
||||
////for morning tym after Added 45 minutes
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
String morngTym = addtime_str(loginTym, 59, 2);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(morngTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
assert date2 != null;
|
||||
if (date2.before(date1)) {
|
||||
|
||||
} else {
|
||||
if (groomedObject.getMorning_groom_img_str().equals("")) {
|
||||
card_morning.setCardBackgroundColor(getResources().getColor(R.color.light_red));
|
||||
grooming_img_morng.setImageResource(R.mipmap.red_camera_icon);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void groomedNoonImg() {
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = null;
|
||||
////for nooo tym after adding 03:10
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
String noonTym = addtime_str(loginTym, 0, 03);
|
||||
String endNoonTym = addtime_str(loginTym, 59, 05);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(noonTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
Date date3 = simpleDateFormat.parse(endNoonTym);
|
||||
assert date2 != null;
|
||||
if (date2.after(date1) && date2.before(date3)) {
|
||||
|
||||
} else if (date2.before(date1) && date2.before(date3)) {
|
||||
if (groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
card_noon.setCardBackgroundColor(getResources().getColor(R.color.gray));
|
||||
grooming_img_noon.setImageResource(R.mipmap.camera);
|
||||
}
|
||||
} else {
|
||||
if (groomedObject.getNoon_groom_img_str().equals("")) {
|
||||
card_noon.setCardBackgroundColor(getResources().getColor(R.color.light_red));
|
||||
grooming_img_noon.setImageResource(R.mipmap.red_camera_icon);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
} catch (NumberFormatException e) {
|
||||
e.fillInStackTrace();
|
||||
} catch (Resources.NotFoundException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void groomedeveningimg() {
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = null;
|
||||
////for evenning tym after adding 03:10
|
||||
db.open();
|
||||
loginTym = db.get_baLoginTym(visit_date, username).getUserLoginTym();
|
||||
loginTym = CommonFunctions.setTimeFormat(loginTym);
|
||||
String evngTym = addtime_str(loginTym, 0, 06);
|
||||
String EndevngTym = addtime_str(loginTym, 59, 8);
|
||||
simpleDateFormat = new SimpleDateFormat("hh:mm:ss a", Locale.ENGLISH);
|
||||
Date date1 = simpleDateFormat.parse(evngTym);
|
||||
Date date2 = simpleDateFormat.parse(getTime());
|
||||
Date date3 = simpleDateFormat.parse(EndevngTym);
|
||||
|
||||
assert date2 != null;
|
||||
if (date2.after(date1) && date2.before(date3)) {
|
||||
|
||||
} else if (date2.before(date1) && date2.before(date3)) {
|
||||
if (groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
cardview_evening.setCardBackgroundColor(getResources().getColor(R.color.gray));
|
||||
grooming_img_evning.setImageResource(R.mipmap.camera);
|
||||
}
|
||||
} else {
|
||||
if (groomedObject.getEvenning_groom_img_str().equals("")) {
|
||||
cardview_evening.setCardBackgroundColor(getResources().getColor(R.color.light_red));
|
||||
grooming_img_evning.setImageResource(R.mipmap.red_camera_icon);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.TCounterInvoice;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class InWardStockActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
Lorealba_Database db;
|
||||
Context context;
|
||||
SharedPreferences preferences;
|
||||
String counter_id, visit_date, username;
|
||||
ArrayList<TCounterInvoice> counterInvoiceList = new ArrayList<>();
|
||||
RecyclerView invoiceListView;
|
||||
ValueAdapter adapter;
|
||||
FloatingActionButton addBtn;
|
||||
public ArrayList<TCounterInvoice> manualInwardStockList = new ArrayList<>();
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_in_ward_stock);
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
validateUIData();
|
||||
db.open();
|
||||
addBtn.setVisibility(db.getHideManualInwordCount()? View.GONE : View.VISIBLE);
|
||||
String couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
TextView txt_counter_code = (TextView) findViewById(R.id.txt_counter_code);
|
||||
txt_counter_code.setText("Counter Code - " + couter_code + " / Id - " + counter_id);
|
||||
}
|
||||
|
||||
private void validateUIData() {
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
invoiceListView = (RecyclerView) findViewById(R.id.invoice_list);
|
||||
addBtn = (FloatingActionButton) findViewById(R.id.add_btn);
|
||||
addBtn.setOnClickListener(this::onClick);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
setTitle("InWard Stock - " + visit_date);
|
||||
invoiceListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
db.open();
|
||||
manualInwardStockList = db.getManualInwardStockData(counter_id, visit_date);
|
||||
counterInvoiceList = db.getInwardStockData(counter_id, visit_date);
|
||||
if (!counterInvoiceList.isEmpty()) {
|
||||
if (!manualInwardStockList.isEmpty()) {
|
||||
if (!manualInwardStockList.get(0).getNo_ofLine().equals("0")) {
|
||||
counterInvoiceList.addAll(manualInwardStockList);
|
||||
}
|
||||
}
|
||||
adapter = new ValueAdapter(counterInvoiceList, context);
|
||||
invoiceListView.setAdapter(adapter);
|
||||
invoiceListView.setLayoutManager(new LinearLayoutManager(context));
|
||||
} else {
|
||||
adapter = new ValueAdapter(manualInwardStockList, context);
|
||||
invoiceListView.setAdapter(adapter);
|
||||
invoiceListView.setLayoutManager(new LinearLayoutManager(context));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.add_btn) {
|
||||
Intent intent = new Intent(context, ManualInWardStockActivity.class);
|
||||
intent.putExtra(CommonString.KEY_VALUE, "add");
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private class ValueAdapter extends RecyclerView.Adapter<ValueAdapter.ViewHolder> {
|
||||
ArrayList<TCounterInvoice> counterInvoiceList;
|
||||
LayoutInflater inflator;
|
||||
Context context;
|
||||
|
||||
public ValueAdapter(ArrayList<TCounterInvoice> counterInvoiceList, Context context) {
|
||||
this.counterInvoiceList = counterInvoiceList;
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.invoice_detail_layout, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ViewHolder viewHolder, final int pos) {
|
||||
TCounterInvoice object = counterInvoiceList.get(pos);
|
||||
viewHolder.invoiceNumber.setText(object.getInvoiceNo());
|
||||
viewHolder.invoiceNumber.setId(pos);
|
||||
viewHolder.invoiceDate.setText(object.getInvoiceDate());
|
||||
viewHolder.invoiceDate.setId(pos);
|
||||
viewHolder.invoiceType.setText(object.getInvoiceType());
|
||||
viewHolder.invoiceType.setId(pos);
|
||||
viewHolder.noOfLine.setText(object.getNo_ofLine());
|
||||
viewHolder.noOfLine.setId(pos);
|
||||
viewHolder.approvedLine.setText(object.getApproved_line());
|
||||
viewHolder.approvedLine.setId(pos);
|
||||
viewHolder.invoiceAmount.setText(object.getFinalAmount());
|
||||
viewHolder.invoiceAmount.setId(pos);
|
||||
if (object.getSource().isEmpty()) {
|
||||
viewHolder.inwardStockView.setCardBackgroundColor(getResources().getColor(R.color.light_blue));
|
||||
viewHolder.inwardStockView.setId(pos);
|
||||
} else {
|
||||
viewHolder.inwardStockView.setCardBackgroundColor(getResources().getColor(R.color.light_green));
|
||||
viewHolder.inwardStockView.setId(pos);
|
||||
}
|
||||
|
||||
if (object.getSource().isEmpty() || object.getSource().equalsIgnoreCase("DMS")) {
|
||||
viewHolder.layout_background.setBackgroundColor(getResources().getColor(R.color.grey_dark_background));
|
||||
viewHolder.layout_background.setId(pos);
|
||||
} else {
|
||||
viewHolder.layout_background.setBackgroundColor(getResources().getColor(R.color.dark_light_gray));
|
||||
viewHolder.layout_background.setId(pos);
|
||||
}
|
||||
|
||||
///for DMS Approved or not
|
||||
if (!object.getNo_ofLine().equalsIgnoreCase(object.getApproved_line()) && (object.getSource().equalsIgnoreCase("DMS")
|
||||
|| object.getSource().isEmpty())) {
|
||||
viewHolder.draftImg.setVisibility(View.VISIBLE);
|
||||
viewHolder.draftImg.setBackgroundResource(R.drawable.incomplete_icon);
|
||||
viewHolder.draftImg.setId(pos);
|
||||
} else {
|
||||
viewHolder.draftImg.setVisibility(View.VISIBLE);
|
||||
viewHolder.draftImg.setBackgroundResource(R.drawable.complete_icon);
|
||||
viewHolder.draftImg.setId(pos);
|
||||
}
|
||||
|
||||
////for Manual Draft and compelete....
|
||||
if (object.getInvoiceStatus() && object.getSource().equalsIgnoreCase("Manual")) {
|
||||
viewHolder.draftImg.setVisibility(View.VISIBLE);
|
||||
viewHolder.draftImg.setBackgroundResource(R.drawable.complete_icon);
|
||||
viewHolder.draftImg.setId(pos);
|
||||
} else {
|
||||
if (counterInvoiceList.get(pos).getSource().equalsIgnoreCase("Manual")) {
|
||||
viewHolder.draftImg.setVisibility(View.VISIBLE);
|
||||
viewHolder.draftImg.setBackgroundResource(R.mipmap.saved_draft);
|
||||
viewHolder.draftImg.setId(pos);
|
||||
}
|
||||
}
|
||||
|
||||
viewHolder.inwardStockView.setOnClickListener(view -> {
|
||||
Intent intent;
|
||||
if (object.getSource().isEmpty() || object.getSource().equalsIgnoreCase("DMS")) {
|
||||
intent = new Intent(context, InwardStockDetailsActivity.class);
|
||||
intent.putExtra(CommonString.TAG_OBJECT, object);
|
||||
} else {
|
||||
intent = new Intent(context, ManualInWardStockActivity.class);
|
||||
intent.putExtra(CommonString.TAG_OBJECT, object);
|
||||
intent.putExtra(CommonString.KEY_VALUE, "edit");
|
||||
}
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return counterInvoiceList.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView invoiceNumber, invoiceDate, invoiceType, noOfLine, approvedLine, invoiceAmount;
|
||||
LinearLayout layout_background;
|
||||
CardView inwardStockView;
|
||||
ImageView draftImg;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
invoiceDate = (TextView) itemView.findViewById(R.id.date_txt);
|
||||
draftImg = (ImageView) itemView.findViewById(R.id.draft_image);
|
||||
noOfLine = (TextView) itemView.findViewById(R.id.no_of_lines_txt);
|
||||
invoiceType = (TextView) itemView.findViewById(R.id.invoice_type_txt);
|
||||
approvedLine = (TextView) itemView.findViewById(R.id.approved_line_txt);
|
||||
invoiceAmount = (TextView) itemView.findViewById(R.id.invoice_amount_txt);
|
||||
inwardStockView = (CardView) itemView.findViewById(R.id.inward_stock_view);
|
||||
invoiceNumber = (TextView) itemView.findViewById(R.id.invoice_number_txt);
|
||||
layout_background = (LinearLayout) itemView.findViewById(R.id.layout_background);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
||||
+1615
File diff suppressed because it is too large
Load Diff
+1720
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,170 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MEMEAuditQuestion;
|
||||
import com.cpm.lorealbaautomation.makeupexpert.MEQuizActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MeQuizListActivity extends AppCompatActivity {
|
||||
List<Integer> checkHeaderArray = new ArrayList<>();
|
||||
boolean checkflag = true;
|
||||
private SharedPreferences preferences;
|
||||
String username, date, counter_id = "";
|
||||
Lorealba_Database db;
|
||||
Toolbar toolbar;
|
||||
RecyclerView me_quiz_list;
|
||||
ArrayList<MEMEAuditQuestion> listDataHeader = new ArrayList<>();
|
||||
Context _context;
|
||||
MEQuizListAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_me_quiz_list);
|
||||
_context = this;
|
||||
preferences = PrefHelper.getPrefs(this);
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
if (!CommonFunctions.isTablet(_context)) {
|
||||
toolbar.setTitleTextAppearance(_context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
setTitle("ME Quiz List - " + username);
|
||||
me_quiz_list = (RecyclerView) findViewById(R.id.me_quiz_list);
|
||||
db = new Lorealba_Database(_context);
|
||||
db.open();
|
||||
|
||||
listDataHeader = db.getMeQuiz();
|
||||
if (listDataHeader.size()>0){
|
||||
|
||||
me_quiz_list.setAdapter(new MEQuizListAdapter(_context,listDataHeader));
|
||||
me_quiz_list.setLayoutManager(new LinearLayoutManager(_context));
|
||||
}
|
||||
}
|
||||
|
||||
private class MEQuizListAdapter extends RecyclerView.Adapter<MEQuizListAdapter.ViewHolder> {
|
||||
Context context;
|
||||
ArrayList<MEMEAuditQuestion> listDataHeader;
|
||||
|
||||
public MEQuizListAdapter(Context context, ArrayList<MEMEAuditQuestion> listDataHeader) {
|
||||
this.context = context;
|
||||
this.listDataHeader = listDataHeader;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MEQuizListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.content_ba_survey_list_view, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MEQuizListAdapter.ViewHolder holder, final int pos) {
|
||||
final MEMEAuditQuestion object = listDataHeader.get(pos);
|
||||
|
||||
holder.quiz_name.setText(object.getQuizName().trim() + " ID - " + object.getQuizId().toString());
|
||||
holder.quiz_name.setId(pos);
|
||||
db.open();
|
||||
if (db.getme_quiz(username, date, counter_id, object.getQuizId().toString()).size() > 0) {
|
||||
holder.complete_icon.setVisibility(View.VISIBLE);
|
||||
holder.complete_icon.setId(pos);
|
||||
db.open();
|
||||
} else if (db.getMeQuizUploadStatus(object.getQuizId().toString(), username,counter_id)) {
|
||||
holder.complete_icon.setVisibility(View.VISIBLE);
|
||||
holder.complete_icon.setId(pos);
|
||||
} else {
|
||||
holder.complete_icon.setVisibility(View.GONE);
|
||||
holder.complete_icon.setId(pos);
|
||||
}
|
||||
|
||||
holder.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
db.open();
|
||||
if (db.getme_quiz(username, date, counter_id, object.getQuizId().toString()).size() > 0) {
|
||||
AlertandMessages.showToastMsg(context, "ME Quiz Already Done");
|
||||
db.open();
|
||||
} else if (db.getMeQuizUploadStatus(object.getQuizId().toString(), username,counter_id)) {
|
||||
AlertandMessages.showToastMsg(context, "ME Quiz Already Done");
|
||||
} else {
|
||||
startActivity(new Intent(context, MEQuizActivity.class).putExtra(CommonString.TAG_OBJECT, object));
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
MeQuizListActivity.this.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return listDataHeader.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView quiz_name;
|
||||
CardView cardView;
|
||||
ImageView complete_icon;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
quiz_name = (TextView) itemView.findViewById(R.id.survey_name);
|
||||
cardView = (CardView) itemView.findViewById(R.id.survey_view);
|
||||
complete_icon = (ImageView) itemView.findViewById(R.id.complete_img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
MeQuizListActivity.this.finish();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
MeQuizListActivity.this.finish();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.NotificationData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapter.ViewHolder> {
|
||||
|
||||
ArrayList<NotificationData> notificationList = new ArrayList<>();
|
||||
|
||||
public NotificationAdapter(ArrayList<NotificationData> notificationList) {
|
||||
this.notificationList = notificationList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.notification_list, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
|
||||
|
||||
viewHolder.title_txt.setText(notificationList.get(position).getTitle());
|
||||
viewHolder.body_txt.setText(notificationList.get(position).getBody());
|
||||
viewHolder.path_txt.setText(notificationList.get(position).getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return notificationList.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView title_txt,path_txt,body_txt;
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title_txt = (TextView)itemView.findViewById(R.id.title_txt);
|
||||
body_txt = (TextView)itemView.findViewById(R.id.body_txt);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
|
||||
public class NotificationDetailActivity extends AppCompatActivity {
|
||||
String visit_date, username, counter_id, userType, title, body, path, type, keyId;
|
||||
private SharedPreferences preferences = null;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
TextView tv_title_text, tv_message;
|
||||
Lorealba_Database db;
|
||||
VideoView videoView;
|
||||
CardView card_text;
|
||||
ImageView imgview;
|
||||
Context context;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_notification_detail);
|
||||
context = this;
|
||||
preferences = PrefHelper.getPrefs(context);
|
||||
counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, "");
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
userType = preferences.getString(CommonString.KEY_USER_TYPE, "");
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (!CommonFunctions.isTablet(this)) {
|
||||
toolbar.setTitleTextAppearance(this, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
setTitle("Details");
|
||||
db = new Lorealba_Database(this);
|
||||
|
||||
type = getIntent().getStringExtra("type");
|
||||
title = getIntent().getStringExtra("Title");
|
||||
body = getIntent().getStringExtra("Body");
|
||||
path = getIntent().getStringExtra("Path");
|
||||
|
||||
keyId = getIntent().getStringExtra("KEY_ID");
|
||||
db.open();
|
||||
db.updateNotificationDetails("1", keyId);
|
||||
db.open();
|
||||
db.insertnotification_users(username,visit_date, counter_id,keyId);
|
||||
|
||||
tv_title_text = (TextView) findViewById(R.id.tv_title);
|
||||
tv_message = (TextView) findViewById(R.id.tv_message);
|
||||
card_text = (CardView) findViewById(R.id.parent_text_msg);
|
||||
|
||||
|
||||
imgview = (ImageView) findViewById(R.id.img_notification);
|
||||
videoView = (VideoView) findViewById(R.id.video_view);
|
||||
tv_title_text.setText(title);
|
||||
tv_message.setText(body);
|
||||
|
||||
if (type != null && type.equalsIgnoreCase("Image")) {
|
||||
imgview.setVisibility(View.VISIBLE);
|
||||
|
||||
Glide.with(this).load(path)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.into(imgview);
|
||||
|
||||
} else if (type != null && type.equalsIgnoreCase("Video")) {
|
||||
videoView.setVisibility(View.VISIBLE);
|
||||
videoView.setVideoPath(path);
|
||||
videoView.start();
|
||||
} else {
|
||||
if (path != null) {
|
||||
imgview.setVisibility(View.VISIBLE);
|
||||
|
||||
Glide.with(this)
|
||||
.load(path)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.into(imgview);
|
||||
} else {
|
||||
imgview.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent resultIntent = new Intent();
|
||||
// TODO Add extras or a data URI to this intent as appropriate.
|
||||
resultIntent.putExtra("some_key", "String data");
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
}
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
package com.cpm.lorealbaautomation.dailyactivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.NotificationData;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.NotificationsGetterSetter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class NotificationsActivity extends AppCompatActivity {
|
||||
NotificationsGetterSetter object = null;
|
||||
Context context;
|
||||
Lorealba_Database db;
|
||||
RecyclerView notification_view;
|
||||
NotificationAdapter mAdapter;
|
||||
ArrayList<NotificationData> notificationList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_notifications);
|
||||
context = this;
|
||||
db = new Lorealba_Database(context);
|
||||
db.open();
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (!CommonFunctions.isTablet(context)) {
|
||||
toolbar.setTitleTextAppearance(context, R.style.changestext_sizefor_mobile);
|
||||
}
|
||||
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setTitle("Notifications");
|
||||
notification_view = (RecyclerView) findViewById(R.id.notification_view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
createNotificationView();
|
||||
}
|
||||
|
||||
private void createNotificationView() {
|
||||
db.open();
|
||||
notificationList = db.getNotificationList();
|
||||
if (notificationList.size() > 0) {
|
||||
mAdapter = new NotificationAdapter(notificationList);
|
||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
notification_view.setLayoutManager(mLayoutManager);
|
||||
notification_view.setAdapter(mAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapter.ViewHolder> {
|
||||
|
||||
ArrayList<NotificationData> notificationList = new ArrayList<>();
|
||||
|
||||
public NotificationAdapter(ArrayList<NotificationData> notificationList) {
|
||||
this.notificationList = notificationList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public NotificationAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.notification_list, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull NotificationAdapter.ViewHolder viewHolder, final int position) {
|
||||
|
||||
viewHolder.title_txt.setText(notificationList.get(position).getTitle());
|
||||
viewHolder.body_txt.setText(notificationList.get(position).getBody());
|
||||
viewHolder.title_date.setText(notificationList.get(position).getVisited_date());
|
||||
|
||||
if(notificationList.get(position).getRead_status().equalsIgnoreCase("0")){
|
||||
viewHolder.notificationView.setCardBackgroundColor(getResources().getColor(R.color.white));
|
||||
viewHolder.title_txt.setTextColor(getResources().getColor(R.color.blue));
|
||||
}else{
|
||||
viewHolder.notificationView.setCardBackgroundColor(getResources().getColor(R.color.gray));
|
||||
viewHolder.title_txt.setTextColor(getResources().getColor(R.color.black));
|
||||
}
|
||||
|
||||
if (notificationList.get(position).getType() != null) {
|
||||
viewHolder.icon_image.setVisibility(View.VISIBLE);
|
||||
if (notificationList.get(position).getType().equalsIgnoreCase("image")){
|
||||
viewHolder.icon_image.setBackgroundResource(R.mipmap.image);
|
||||
}else if(notificationList.get(position).getType().equalsIgnoreCase("video")) {
|
||||
viewHolder.icon_image.setBackgroundResource(R.mipmap.video);
|
||||
} else{
|
||||
viewHolder.icon_image.setBackgroundResource(R.mipmap.text);
|
||||
}
|
||||
}else {
|
||||
viewHolder.icon_image.setBackgroundResource(R.mipmap.text);
|
||||
}
|
||||
|
||||
viewHolder.notificationView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
db.open();
|
||||
//db.updateNotificationDetails("1",notificationList.get(position).getId());
|
||||
Intent in = new Intent(getApplicationContext(), NotificationDetailActivity.class);
|
||||
in.putExtra("type", notificationList.get(position).getType());
|
||||
in.putExtra("Title", notificationList.get(position).getTitle());
|
||||
in.putExtra("Date", notificationList.get(position).getVisited_date());
|
||||
in.putExtra("Body", notificationList.get(position).getBody());
|
||||
in.putExtra("Path", notificationList.get(position).getPath());
|
||||
in.putExtra("KEY_ID", notificationList.get(position).getId());
|
||||
startActivity(in);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return notificationList.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView title_txt, body_txt,title_date;
|
||||
ImageView icon_image;
|
||||
CardView notificationView;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title_txt = (TextView) itemView.findViewById(R.id.title_txt);
|
||||
title_date = (TextView) itemView.findViewById(R.id.title_date);
|
||||
icon_image =(ImageView)itemView.findViewById(R.id.icon_image);
|
||||
body_txt = (TextView) itemView.findViewById(R.id.body_txt);
|
||||
notificationView = (CardView) itemView.findViewById(R.id.card_notification_view);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == android.R.id.home) {
|
||||
// NavUtils.navigateUpFromSameTask(this);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
/* AlertDialog.Builder builder = new AlertDialog.Builder(NotificationsActivity.this);
|
||||
builder.setMessage(CommonString.ONBACK_ALERT_MESSAGE)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user