Inital commit
This commit is contained in:
@@ -0,0 +1,476 @@
|
||||
<?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="cpm.com.gskmtorange">
|
||||
<!-- To auto-complete the email text field in the login form with the user's emails -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" /> <!-- Devices running Android 13 (API level 33) or higher -->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<!--
|
||||
To handle the reselection within the app on devices running Android 14
|
||||
or higher if your app targets Android 14 (API level 34) or higher.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
||||
<uses-permission android:name="com.android.providers.media.MediaProvider" />
|
||||
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_CAMERA" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera.any"
|
||||
android:required="true" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera.autofocus"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:supportsRtl="false"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="android:supportsRtl">
|
||||
<activity
|
||||
android:name=".Paralleldots.PdJavaImageActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".dailyentry.PDimageActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.StockEntryActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.VisitTypeStatusActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="Ad hoc - Visit Type"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.OrderStatusDetailActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.OrderConfirmActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.OrderTakingActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.NewStockDataActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_new_stock_data"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.CounterfeitIndicatorWebActivity"
|
||||
android:label="@string/title_activity_counterfeit_indicator_web"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.StockPricingActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_stock_pricing"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".pharma_stores.PharmaActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_paharma"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.StockActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/stock"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.CounterfeitProductsActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_counterfeit_products"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".password.MPinActivity"
|
||||
android:label="@string/title_activity_mpin"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".password.ChangePasswordActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_change_password"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".SplashScreenActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_login"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/main_menu_activity_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".autoupdate.AutoUpdateActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".SelectLanguageActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_select_language"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".download.DownloadActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".GeoTag.GeoTagStoreList"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_list"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.StoreListActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_list"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.StoreimageActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_image"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".GeoTag.GeoTagActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_geotag"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<!--
|
||||
<meta-data
|
||||
android:name="com.google.android.maps.v2.API_KEY"
|
||||
android:value="AIzaSyD02po19go2JMhXJeAnKDiZSiNloPsWqzI" />
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
-->
|
||||
<activity
|
||||
android:name=".dailyentry.T2PComplianceActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" /> <!-- Gagan Start Declaration -->
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.CategoryListActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.CategoryWisePerformanceActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.DailyDataMenuActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.MSL_AvailabilityActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.Stock_FacingActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.PromoComplianceActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.StoreWisePerformanceActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" /> <!-- Gagan End Declaration -->
|
||||
<activity
|
||||
android:name=".dailyentry.NonWorkingReason"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_Non_Work"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.AdditionalVisibility"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_Additional_visibility"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".upload.UploadActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_upload"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.SettingsActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.CheckoutActivity"
|
||||
android:label="@string/title_activity_checkout"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.ServiceActivity"
|
||||
android:label="@string/title_activity_service"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".upload.PreviousDataUploadActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_upload"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".dailyentry.T2pBrand_Avaibility"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_t2p_brand__avaibility"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.StockFacing_PlanogramTrackerActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_stock_facing__planogram_tracker"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.CategoryPicture"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_category_picture"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.StoreCheckoutImageActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_checkout_image"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".gsk_dailyentry.MSL_Availability_StockFacingActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.FutureJCPActivity"
|
||||
android:label=""
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.CreateSelfActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_create_self"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.NoCameraActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_create_self"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.PlanogramPDFActivity"
|
||||
android:label="@string/category_performance_PLANOGRAM"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.StockDataActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_stock_data"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.AuditActivity"
|
||||
android:label="@string/audit"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
<service
|
||||
android:name=".service.FCMNotificationService"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".dailyentry.POGQuestionsActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_pogquestions"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<!--
|
||||
The API key for Google Maps-based APIs is defined as a string resource.
|
||||
(See the file "res/values/google_maps_api.xml").
|
||||
Note that the API key is linked to the encryption key used to sign the APK.
|
||||
You need a different API key for each encryption key, including the release key that is used to
|
||||
sign the APK for publishing.
|
||||
You can define the keys for the debug and release targets in src/debug/ and src/release/.
|
||||
-->
|
||||
<!--
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
|
||||
<activity
|
||||
android:name=".storeinmap.StoreListMapActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_list_map"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".storeinmap.StoreListRouteActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_list_route"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".storeinmap.StoreRouteActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_store_route"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.MessageActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_message"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.ConversationActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_conversation"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.CoachingVisitActivity"
|
||||
android:label="@string/title_activity_coaching_visit"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.CoachingVisitStoreActivity"
|
||||
android:label="@string/title_activity_coaching_visit_store"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.DeliveryCallActivity"
|
||||
android:label="@string/delivery_call"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.DeliveryCallAddStoreActivity"
|
||||
android:label="@string/delivery_call"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".dailyentry.AdditionalPromoSKUwiseActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/title_activity_additional_promo_skuwise"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".dailyentry.CompetitionPromoActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden"
|
||||
android:label="@string/competition_promotion"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
@@ -0,0 +1,46 @@
|
||||
package cpm.com.gskmtorange;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AppUtils {
|
||||
public static File getInternalDirectory(Context context, String folderName) {
|
||||
File dir = context.getExternalFilesDir("");
|
||||
File file = new File(dir, folderName);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public static File getFile(Context context, String fileName, String folderName) {
|
||||
File dir = getInternalDirectory(context, folderName);
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
return dir;
|
||||
} else {
|
||||
return new File(dir, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveByteArrayToFile(byte[] byteArray, String fileName) throws IOException {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(fileName)) {
|
||||
fileOutputStream.write(byteArray);
|
||||
}
|
||||
}
|
||||
public static void clearMyFiles(Context activity, String folderName) {
|
||||
File[] files = getInternalDirectory(activity, folderName).listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static File getExterDir(Context context) {
|
||||
return context.getExternalFilesDir("");
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,266 @@
|
||||
package cpm.com.gskmtorange.GeoTag;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
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.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.download.DownloadActivity;
|
||||
|
||||
/**
|
||||
* Created by ashishc on 27-12-2016.
|
||||
*/
|
||||
|
||||
public class GeoTagStoreList extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private SharedPreferences preferences;
|
||||
ArrayList<StoreBean> storelist = new ArrayList<StoreBean>();
|
||||
String date, visit_status;
|
||||
GSKOrangeDB db;
|
||||
// ListView list;
|
||||
ValueAdapter adapter;
|
||||
RecyclerView recyclerView;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
LinearLayout parent_linear, nodata_linear;
|
||||
LinearLayout linearlay;
|
||||
FloatingActionButton fab;
|
||||
Toolbar toolbar;
|
||||
|
||||
private Context context;
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.geotagstorelistfab);
|
||||
//list = (ListView) findViewById(R.id.list_id);
|
||||
|
||||
recyclerView = (RecyclerView) findViewById(R.id.drawer_layout_recycle);
|
||||
linearlay = (LinearLayout) findViewById(R.id.no_data_lay);
|
||||
// nodata_linear = (LinearLayout) findViewById(R.id.no_data_lay);
|
||||
//parent_linear = (LinearLayout) findViewById(R.id.parent_linear);
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
context = this;
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
visit_status = preferences.getString(CommonString.KEY_STOREVISITED_STATUS, "");
|
||||
|
||||
db = new GSKOrangeDB(GeoTagStoreList.this);
|
||||
db.open();
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent in = new Intent(context, DownloadActivity.class);
|
||||
startActivity(in);
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
storelist = db.getStoreData(date, CommonString.KEY_JOURNEY_PLAN);
|
||||
|
||||
if (storelist.size() > 0) {
|
||||
adapter = new ValueAdapter(context, storelist);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
} else {
|
||||
recyclerView.setVisibility(View.INVISIBLE);
|
||||
linearlay.setVisibility(View.VISIBLE);
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@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() {
|
||||
// TODO Auto-generated method stub
|
||||
/* Intent intent = new Intent(GeoTagStoreList.this, MainActivity.class);
|
||||
|
||||
startActivity(intent);*/
|
||||
GeoTagStoreList.this.finish();
|
||||
}
|
||||
|
||||
|
||||
public class ValueAdapter extends RecyclerView.Adapter<ValueAdapter.MyViewHolder> {
|
||||
|
||||
private LayoutInflater inflator;
|
||||
|
||||
List<StoreBean> data = Collections.emptyList();
|
||||
|
||||
public ValueAdapter(Context context, List<StoreBean> data) {
|
||||
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) {
|
||||
View view = inflator.inflate(R.layout.geotagstorelist, parent, false);
|
||||
|
||||
MyViewHolder holder = new MyViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ValueAdapter.MyViewHolder viewHolder, final int position) {
|
||||
final StoreBean current = data.get(position);
|
||||
//viewHolder.txt.setText(current.txt);
|
||||
|
||||
viewHolder.txt.setText(current.getSTORE_NAME());
|
||||
viewHolder.txt_storeAddress.setText(current.getADDRESS());
|
||||
|
||||
if (current.getGEO_TAG().equalsIgnoreCase("Y")) {
|
||||
viewHolder.imageview.setVisibility(View.VISIBLE);
|
||||
viewHolder.imageview.setBackgroundResource(R.mipmap.geopin);
|
||||
} else if (current.getGEO_TAG().equalsIgnoreCase("D")) {
|
||||
viewHolder.imageview.setVisibility(View.VISIBLE);
|
||||
viewHolder.imageview.setBackgroundResource(R.mipmap.exclamation);
|
||||
} else if (current.getGEO_TAG().equalsIgnoreCase("U")) {
|
||||
viewHolder.imageview.setVisibility(View.VISIBLE);
|
||||
viewHolder.imageview.setBackgroundResource(R.mipmap.tick);
|
||||
} else if (current.getGEO_TAG().equalsIgnoreCase("P")) {
|
||||
viewHolder.imageview.setVisibility(View.VISIBLE);
|
||||
viewHolder.imageview.setBackgroundResource(R.mipmap.exclamation);
|
||||
} else {
|
||||
viewHolder.imageview.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
viewHolder.relativelayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (current.getGEO_TAG().equalsIgnoreCase("Y")) {
|
||||
Snackbar.make(v, R.string.title_geo_tag_activity_geo_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
} else if (current.getGEO_TAG().equalsIgnoreCase("D")) {
|
||||
Snackbar.make(v, R.string.title_geo_tag_activity_geo_data, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
|
||||
} else if (current.getGEO_TAG().equalsIgnoreCase("U")) {
|
||||
Snackbar.make(v, R.string.title_geo_tag_activity_upload_data, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
|
||||
} else if (current.getGEO_TAG().equalsIgnoreCase("P")) {
|
||||
Snackbar.make(v, R.string.title_geo_tag_activity_geo_data, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
|
||||
} else {
|
||||
// PUT IN PREFERENCES
|
||||
editor = preferences.edit();
|
||||
editor.putString(CommonString.KEY_STORE_ID, current.getSTORE_ID());
|
||||
editor.putString(CommonString.KEY_STORE_NAME, current.getSTORE_NAME());
|
||||
editor.putString(CommonString.KEY_VISIT_DATE, current.getVISIT_DATE());
|
||||
editor.commit();
|
||||
|
||||
Intent in = new Intent(GeoTagStoreList.this, GeoTagActivity.class);
|
||||
startActivity(in);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txt, txt_storeAddress;
|
||||
ImageView icon;
|
||||
RelativeLayout relativelayout;
|
||||
ImageView imageview;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
txt = (TextView) itemView.findViewById(R.id.geolistviewxml_storename);
|
||||
relativelayout = (RelativeLayout) itemView.findViewById(R.id.relativelayout);
|
||||
imageview = (ImageView) itemView.findViewById(R.id.imageView1);
|
||||
txt_storeAddress = (TextView) itemView.findViewById(R.id.txt_storeAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*public List<StoreBean> getdata() {
|
||||
List<StoreBean> data = new ArrayList<>();
|
||||
|
||||
storelist = db.getStoreData(date);
|
||||
|
||||
StoreBean storelistdata = new StoreBean();
|
||||
|
||||
for (int i = 0; i < storelist.size(); i++) {
|
||||
storelistdata.setSTORE_NAME(storelist.get(0).getSTORE_NAME());
|
||||
|
||||
data.add(storelistdata);
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getString(R.string.title_activity_store_geotag));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
public class AdditionalDialogGetterSetter {
|
||||
public String Display_id,display,brand_id,brand, trg_quantity, image1, image2, category_id,
|
||||
image3, BEFORE_QTY, camera1, camera2, camera3, AFTER_QTY, store_id, stock_count, question_id, question, answer, type,
|
||||
KEY_ID, unique_id,image_url, sku_id,quantity, process_id, sku_name, stock_flag;
|
||||
|
||||
public String getCOMMON_ID() {
|
||||
return COMMON_ID;
|
||||
}
|
||||
|
||||
public void setCOMMON_ID(String COMMON_ID) {
|
||||
this.COMMON_ID = COMMON_ID;
|
||||
}
|
||||
|
||||
String COMMON_ID;
|
||||
|
||||
public String getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(String categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
String categoryId;
|
||||
|
||||
public String getStock_flag() {
|
||||
return stock_flag;
|
||||
}
|
||||
|
||||
public void setStock_flag(String stock_flag) {
|
||||
this.stock_flag = stock_flag;
|
||||
}
|
||||
|
||||
public String getSku_name() {
|
||||
return sku_name;
|
||||
}
|
||||
|
||||
public void setSku_name(String sku_name) {
|
||||
this.sku_name = sku_name;
|
||||
}
|
||||
|
||||
public String getProcess_id() {
|
||||
return process_id;
|
||||
}
|
||||
|
||||
public void setProcess_id(String process_id) {
|
||||
this.process_id = process_id;
|
||||
}
|
||||
|
||||
public String getSku_id() {
|
||||
return sku_id;
|
||||
}
|
||||
|
||||
public void setSku_id(String sku_id) {
|
||||
this.sku_id = sku_id;
|
||||
}
|
||||
|
||||
public String getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(String quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getImage_url() {
|
||||
return image_url;
|
||||
}
|
||||
|
||||
public void setImage_url(String image_url) {
|
||||
this.image_url = image_url;
|
||||
}
|
||||
|
||||
public String getUnique_id() {
|
||||
return unique_id;
|
||||
}
|
||||
|
||||
public void setUnique_id(String unique_id) {
|
||||
this.unique_id = unique_id;
|
||||
}
|
||||
|
||||
public String getKEY_ID() {
|
||||
return KEY_ID;
|
||||
}
|
||||
|
||||
public void setKEY_ID(String kEY_ID) {
|
||||
KEY_ID = kEY_ID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCategory_id() {
|
||||
return category_id;
|
||||
}
|
||||
|
||||
public void setCategory_id(String category_id) {
|
||||
this.category_id = category_id;
|
||||
}
|
||||
|
||||
public String getQuestion_id() {
|
||||
return question_id;
|
||||
}
|
||||
|
||||
public void setQuestion_id(String question_id) {
|
||||
this.question_id = question_id;
|
||||
}
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(String question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
public String getStock_count() {
|
||||
return stock_count;
|
||||
}
|
||||
|
||||
public void setStock_count(String stock_count) {
|
||||
this.stock_count = stock_count;
|
||||
}
|
||||
|
||||
public String getStore_id() {
|
||||
return store_id;
|
||||
}
|
||||
|
||||
public void setStore_id(String store_id) {
|
||||
this.store_id = store_id;
|
||||
}
|
||||
|
||||
public String getCamera1() {
|
||||
return camera1;
|
||||
}
|
||||
|
||||
public void setCamera1(String camera1) {
|
||||
this.camera1 = camera1;
|
||||
}
|
||||
|
||||
public String getCamera2() {
|
||||
return camera2;
|
||||
}
|
||||
|
||||
public void setCamera2(String camera2) {
|
||||
this.camera2 = camera2;
|
||||
}
|
||||
|
||||
public String getCamera3() {
|
||||
return camera3;
|
||||
}
|
||||
|
||||
public void setCamera3(String camera3) {
|
||||
this.camera3 = camera3;
|
||||
}
|
||||
|
||||
public String getDisplay_id() {
|
||||
return Display_id;
|
||||
}
|
||||
|
||||
public void setDisplay_id(String display_id) {
|
||||
Display_id = display_id;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getBrand_id() {
|
||||
return brand_id;
|
||||
}
|
||||
|
||||
public void setBrand_id(String brand_id) {
|
||||
this.brand_id = brand_id;
|
||||
}
|
||||
|
||||
public String getBrand() {
|
||||
return brand;
|
||||
}
|
||||
|
||||
public void setBrand(String brand) {
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
public String getTrg_quantity() {
|
||||
return trg_quantity;
|
||||
}
|
||||
|
||||
public void setTrg_quantity(String trg_quantity) {
|
||||
this.trg_quantity = trg_quantity;
|
||||
}
|
||||
|
||||
public String getImage1() {
|
||||
return image1;
|
||||
}
|
||||
|
||||
public void setImage1(String image1) {
|
||||
this.image1 = image1;
|
||||
}
|
||||
|
||||
public String getImage2() {
|
||||
return image2;
|
||||
}
|
||||
|
||||
public void setImage2(String image2) {
|
||||
this.image2 = image2;
|
||||
}
|
||||
|
||||
public String getImage3() {
|
||||
return image3;
|
||||
}
|
||||
|
||||
public void setImage3(String image3) {
|
||||
this.image3 = image3;
|
||||
}
|
||||
|
||||
public String getBEFORE_QTY() {
|
||||
return BEFORE_QTY;
|
||||
}
|
||||
|
||||
public void setBEFORE_QTY(String bEFORE_QTY) {
|
||||
BEFORE_QTY = bEFORE_QTY;
|
||||
}
|
||||
|
||||
public String getAFTER_QTY() {
|
||||
return AFTER_QTY;
|
||||
}
|
||||
|
||||
public void setAFTER_QTY(String aFTER_QTY) {
|
||||
AFTER_QTY = aFTER_QTY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by ashishc on 09-01-2017.
|
||||
*/
|
||||
|
||||
public class AddittionalGetterSetter {
|
||||
|
||||
|
||||
public String getBrand() {
|
||||
return Brand;
|
||||
}
|
||||
|
||||
public void setBrand(String brand) {
|
||||
Brand = brand;
|
||||
}
|
||||
|
||||
public String getBrand_id() {
|
||||
return Brand_id;
|
||||
}
|
||||
|
||||
public void setBrand_id(String brand_id) {
|
||||
Brand_id = brand_id;
|
||||
}
|
||||
|
||||
public String getSku() {
|
||||
return Sku;
|
||||
}
|
||||
|
||||
public void setSku(String sku) {
|
||||
Sku = sku;
|
||||
}
|
||||
|
||||
public String getSku_id() {
|
||||
return Sku_id;
|
||||
}
|
||||
|
||||
public void setSku_id(String sku_id) {
|
||||
Sku_id = sku_id;
|
||||
}
|
||||
|
||||
public String getStore_id() {
|
||||
return Store_id;
|
||||
}
|
||||
|
||||
public void setStore_id(String store_id) {
|
||||
Store_id = store_id;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return Image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
Image = image;
|
||||
}
|
||||
|
||||
String Brand,Brand_id,Sku,Sku_id,Store_id,Image="";
|
||||
|
||||
|
||||
String Image2="";
|
||||
|
||||
public String getImage3() {
|
||||
return Image3;
|
||||
}
|
||||
|
||||
public void setImage3(String image3) {
|
||||
Image3 = image3;
|
||||
}
|
||||
|
||||
public String getImage2() {
|
||||
return Image2;
|
||||
}
|
||||
|
||||
public void setImage2(String image2) {
|
||||
Image2 = image2;
|
||||
}
|
||||
|
||||
String Image3="";
|
||||
|
||||
public String getKey_id() {
|
||||
return key_id;
|
||||
}
|
||||
|
||||
public void setKey_id(String key_id) {
|
||||
this.key_id = key_id;
|
||||
}
|
||||
|
||||
String key_id;
|
||||
|
||||
public String getBtn_toogle() {
|
||||
return btn_toogle;
|
||||
}
|
||||
|
||||
public void setBtn_toogle(String btn_toogle) {
|
||||
this.btn_toogle = btn_toogle;
|
||||
}
|
||||
|
||||
String btn_toogle;
|
||||
|
||||
public String getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(String categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
String categoryId;
|
||||
|
||||
ArrayList<AdditionalDialogGetterSetter> skuDialogList = new ArrayList<>();
|
||||
|
||||
public ArrayList<AdditionalDialogGetterSetter> getSkuDialogList() {
|
||||
return skuDialogList;
|
||||
}
|
||||
|
||||
public void setSkuDialogList(ArrayList<AdditionalDialogGetterSetter> skuDialogList) {
|
||||
this.skuDialogList = skuDialogList;
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by ashishc on 07-02-2017.
|
||||
*/
|
||||
|
||||
public class BrandAvabilityGetterSetter {
|
||||
|
||||
String BRAND_ID;
|
||||
String BRAND;
|
||||
String keyAccount_id;
|
||||
String class_id;
|
||||
String categoryId;
|
||||
|
||||
public String getStore_id() {
|
||||
return store_id;
|
||||
}
|
||||
|
||||
public void setStore_id(String store_id) {
|
||||
this.store_id = store_id;
|
||||
}
|
||||
|
||||
String store_id;
|
||||
|
||||
public String getStoreType_id() {
|
||||
return storeType_id;
|
||||
}
|
||||
|
||||
public void setStoreType_id(String storeType_id) {
|
||||
this.storeType_id = storeType_id;
|
||||
}
|
||||
|
||||
public String getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(String categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getClass_id() {
|
||||
return class_id;
|
||||
}
|
||||
|
||||
public void setClass_id(String class_id) {
|
||||
this.class_id = class_id;
|
||||
}
|
||||
|
||||
public String getKeyAccount_id() {
|
||||
return keyAccount_id;
|
||||
}
|
||||
|
||||
public void setKeyAccount_id(String keyAccount_id) {
|
||||
this.keyAccount_id = keyAccount_id;
|
||||
}
|
||||
|
||||
String storeType_id;
|
||||
|
||||
|
||||
public String getBRAND() {
|
||||
return BRAND;
|
||||
}
|
||||
|
||||
public void setBRAND(String BRAND) {
|
||||
this.BRAND = BRAND;
|
||||
}
|
||||
|
||||
public String getBRAND_ID() {
|
||||
return BRAND_ID;
|
||||
}
|
||||
|
||||
public void setBRAND_ID(String BRAND_ID) {
|
||||
this.BRAND_ID = BRAND_ID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri;
|
||||
|
||||
/**
|
||||
* Created by ashishc on 20-02-2017.
|
||||
*/
|
||||
|
||||
public class CategoryPictureGetterSetter {
|
||||
String subCatCode = "", CategoryImage1 = "", CategoryImage2 = "", CategoryImage3 = "", CategoryImage4 = "", image_allow = "0",categoryId,COMMON_ID,KEY_ID;
|
||||
|
||||
public String getSubCatCode() {
|
||||
return subCatCode;
|
||||
}
|
||||
|
||||
public void setSubCatCode(String subCatCode) {
|
||||
this.subCatCode = subCatCode;
|
||||
}
|
||||
|
||||
public String getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(String categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getCOMMON_ID() {
|
||||
return COMMON_ID;
|
||||
}
|
||||
|
||||
public void setCOMMON_ID(String COMMON_ID) {
|
||||
this.COMMON_ID = COMMON_ID;
|
||||
}
|
||||
|
||||
public String getKEY_ID() {
|
||||
return KEY_ID;
|
||||
}
|
||||
|
||||
public void setKEY_ID(String KEY_ID) {
|
||||
this.KEY_ID = KEY_ID;
|
||||
}
|
||||
|
||||
public String getCamera_allow() {
|
||||
return camera_allow;
|
||||
}
|
||||
|
||||
public void setCamera_allow(String camera_allow) {
|
||||
this.camera_allow = camera_allow;
|
||||
}
|
||||
|
||||
public String getClass_id() {
|
||||
return class_id;
|
||||
}
|
||||
|
||||
public void setClass_id(String class_id) {
|
||||
this.class_id = class_id;
|
||||
}
|
||||
|
||||
public String getStore_type_id() {
|
||||
return store_type_id;
|
||||
}
|
||||
|
||||
public void setStore_type_id(String store_type_id) {
|
||||
this.store_type_id = store_type_id;
|
||||
}
|
||||
|
||||
public String getKey_account_id() {
|
||||
return key_account_id;
|
||||
}
|
||||
|
||||
public void setKey_account_id(String key_account_id) {
|
||||
this.key_account_id = key_account_id;
|
||||
}
|
||||
|
||||
String camera_allow, class_id, store_type_id, key_account_id;
|
||||
|
||||
|
||||
public String getStore_ID() {
|
||||
return Store_ID;
|
||||
}
|
||||
|
||||
public void setStore_ID(String store_ID) {
|
||||
Store_ID = store_ID;
|
||||
}
|
||||
|
||||
String Store_ID;
|
||||
|
||||
String SubCategoryCamera1;
|
||||
|
||||
String SUB_CATEGORY_ID;
|
||||
|
||||
public String getSUB_CATEGORY() {
|
||||
return SUB_CATEGORY;
|
||||
}
|
||||
|
||||
public void setSUB_CATEGORY(String SUB_CATEGORY) {
|
||||
this.SUB_CATEGORY = SUB_CATEGORY;
|
||||
}
|
||||
|
||||
public String getSUB_CATEGORY_ID() {
|
||||
return SUB_CATEGORY_ID;
|
||||
}
|
||||
|
||||
public void setSUB_CATEGORY_ID(String SUB_CATEGORY_ID) {
|
||||
this.SUB_CATEGORY_ID = SUB_CATEGORY_ID;
|
||||
}
|
||||
|
||||
String SUB_CATEGORY;
|
||||
|
||||
|
||||
public String getSubCategoryCamera1() {
|
||||
return SubCategoryCamera1;
|
||||
}
|
||||
|
||||
public void setSubCategoryCamera1(String subCategoryCamera1) {
|
||||
SubCategoryCamera1 = subCategoryCamera1;
|
||||
}
|
||||
|
||||
public String getSubCategoryCamera2() {
|
||||
return SubCategoryCamera2;
|
||||
}
|
||||
|
||||
public void setSubCategoryCamera2(String subCategoryCamera2) {
|
||||
SubCategoryCamera2 = subCategoryCamera2;
|
||||
}
|
||||
|
||||
String SubCategoryCamera2;
|
||||
|
||||
public String getCategoryImage2() {
|
||||
return CategoryImage2;
|
||||
}
|
||||
|
||||
public void setCategoryImage2(String categoryImage2) {
|
||||
CategoryImage2 = categoryImage2;
|
||||
}
|
||||
|
||||
public String getCategoryImage1() {
|
||||
return CategoryImage1;
|
||||
}
|
||||
|
||||
public void setCategoryImage1(String categoryImage1) {
|
||||
CategoryImage1 = categoryImage1;
|
||||
}
|
||||
|
||||
public String getCategoryImage3() {
|
||||
return CategoryImage3;
|
||||
}
|
||||
|
||||
public void setCategoryImage3(String categoryImage3) {
|
||||
CategoryImage3 = categoryImage3;
|
||||
}
|
||||
|
||||
public String getCategoryImage4() {
|
||||
return CategoryImage4;
|
||||
}
|
||||
|
||||
public void setCategoryImage4(String categoryImage4) {
|
||||
CategoryImage4 = categoryImage4;
|
||||
}
|
||||
|
||||
|
||||
public String getImage_allow() {
|
||||
return image_allow;
|
||||
}
|
||||
|
||||
public void setImage_allow(String image_allow) {
|
||||
this.image_allow = image_allow;
|
||||
}
|
||||
|
||||
public ArrayList<ImageUri> getImageUris() {
|
||||
return imageUris;
|
||||
}
|
||||
|
||||
public void setImageUris(ArrayList<ImageUri> imageUris) {
|
||||
this.imageUris = imageUris;
|
||||
}
|
||||
|
||||
ArrayList<ImageUri> imageUris = new ArrayList<>();
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
public class ChatMessageGetterSetter {
|
||||
|
||||
String REC_ID, CHAT_ID, MESSAGE, MESSAGEDATE , SENDERID, SENDER, RECEIVERID, RECEIVER, COMMENTDATE, COMMENT, STOREID, ORDERID, SENDER_USERID;
|
||||
|
||||
public String getREC_ID() {
|
||||
return REC_ID;
|
||||
}
|
||||
|
||||
public void setREC_ID(String REC_ID) {
|
||||
this.REC_ID = REC_ID;
|
||||
}
|
||||
|
||||
public String getCHAT_ID() {
|
||||
return CHAT_ID;
|
||||
}
|
||||
|
||||
public void setCHAT_ID(String CHAT_ID) {
|
||||
this.CHAT_ID = CHAT_ID;
|
||||
}
|
||||
|
||||
public String getMESSAGE() {
|
||||
return MESSAGE;
|
||||
}
|
||||
|
||||
public void setMESSAGE(String MESSAGE) {
|
||||
this.MESSAGE = MESSAGE;
|
||||
}
|
||||
|
||||
public String getMESSAGEDATE() {
|
||||
return MESSAGEDATE;
|
||||
}
|
||||
|
||||
public void setMESSAGEDATE(String MESSAGEDATE) {
|
||||
this.MESSAGEDATE = MESSAGEDATE;
|
||||
}
|
||||
|
||||
public String getSENDERID() {
|
||||
return SENDERID;
|
||||
}
|
||||
|
||||
public void setSENDERID(String SENDERID) {
|
||||
this.SENDERID = SENDERID;
|
||||
}
|
||||
|
||||
public String getSENDER() {
|
||||
return SENDER;
|
||||
}
|
||||
|
||||
public void setSENDER(String SENDER) {
|
||||
this.SENDER = SENDER;
|
||||
}
|
||||
|
||||
public String getRECEIVERID() {
|
||||
return RECEIVERID;
|
||||
}
|
||||
|
||||
public void setRECEIVERID(String RECEIVERID) {
|
||||
this.RECEIVERID = RECEIVERID;
|
||||
}
|
||||
|
||||
public String getRECEIVER() {
|
||||
return RECEIVER;
|
||||
}
|
||||
|
||||
public void setRECEIVER(String RECEIVER) {
|
||||
this.RECEIVER = RECEIVER;
|
||||
}
|
||||
|
||||
public String getCOMMENTDATE() {
|
||||
return COMMENTDATE;
|
||||
}
|
||||
|
||||
public void setCOMMENTDATE(String COMMENTDATE) {
|
||||
this.COMMENTDATE = COMMENTDATE;
|
||||
}
|
||||
|
||||
public String getCOMMENT() {
|
||||
return COMMENT;
|
||||
}
|
||||
|
||||
public void setCOMMENT(String COMMENT) {
|
||||
this.COMMENT = COMMENT;
|
||||
}
|
||||
|
||||
public String getSTOREID() {
|
||||
return STOREID;
|
||||
}
|
||||
|
||||
public void setSTOREID(String STOREID) {
|
||||
this.STOREID = STOREID;
|
||||
}
|
||||
|
||||
public String getORDERID() {
|
||||
return ORDERID;
|
||||
}
|
||||
|
||||
public void setORDERID(String ORDERID) {
|
||||
this.ORDERID = ORDERID;
|
||||
}
|
||||
|
||||
public String getSENDER_USERID() {
|
||||
return SENDER_USERID;
|
||||
}
|
||||
|
||||
public void setSENDER_USERID(String SENDER_USERID) {
|
||||
this.SENDER_USERID = SENDER_USERID;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
public class CoachingVisitGetterSetter {
|
||||
|
||||
String emp_id, img_path = "";
|
||||
boolean exists;
|
||||
|
||||
public String getEmp_id() {
|
||||
return emp_id;
|
||||
}
|
||||
|
||||
public void setEmp_id(String emp_id) {
|
||||
this.emp_id = emp_id;
|
||||
}
|
||||
|
||||
public String getImg_path() {
|
||||
return img_path;
|
||||
}
|
||||
|
||||
public void setImg_path(String img_path) {
|
||||
this.img_path = img_path;
|
||||
}
|
||||
|
||||
public boolean isExists() {
|
||||
return exists;
|
||||
}
|
||||
|
||||
public void setExists(boolean exists) {
|
||||
this.exists = exists;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
public class CoverageBean {
|
||||
protected int MID;
|
||||
protected String process_id;
|
||||
|
||||
public String flag_from;
|
||||
|
||||
public String getGEO_TAG() {
|
||||
return GEO_TAG;
|
||||
}
|
||||
|
||||
public void setGEO_TAG(String GEO_TAG) {
|
||||
this.GEO_TAG = GEO_TAG;
|
||||
}
|
||||
|
||||
protected String GEO_TAG;
|
||||
|
||||
public String getProcess_id() {
|
||||
return process_id;
|
||||
}
|
||||
|
||||
public void setProcess_id(String process_id) {
|
||||
this.process_id = process_id;
|
||||
}
|
||||
|
||||
protected String storeId;
|
||||
protected String storename;
|
||||
|
||||
public String getStorename() {
|
||||
return storename;
|
||||
}
|
||||
|
||||
public void setStorename(String storename) {
|
||||
this.storename = storename;
|
||||
}
|
||||
|
||||
protected String Remark;
|
||||
|
||||
public String getRemark() {
|
||||
return Remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
Remark = remark;
|
||||
}
|
||||
|
||||
protected String userId;
|
||||
protected String app_version;
|
||||
protected String image_allow;
|
||||
|
||||
public String getImage_allow() {
|
||||
return image_allow;
|
||||
}
|
||||
|
||||
public void setImage_allow(String image_allow) {
|
||||
this.image_allow = image_allow;
|
||||
}
|
||||
|
||||
public String getApp_version() {
|
||||
return app_version;
|
||||
}
|
||||
|
||||
public void setApp_version(String app_version) {
|
||||
this.app_version = app_version;
|
||||
}
|
||||
|
||||
protected String inTime;
|
||||
|
||||
protected String outTime;
|
||||
|
||||
protected String visitDate;
|
||||
|
||||
protected String keycontactId;
|
||||
|
||||
protected String isdDeploy;
|
||||
|
||||
protected String uploadStatus;
|
||||
|
||||
private String latitude;
|
||||
|
||||
private String longitude;
|
||||
|
||||
private String reasonid = "";
|
||||
|
||||
private String sub_reasonId = "";
|
||||
|
||||
public String getSub_reasonId() {
|
||||
return sub_reasonId;
|
||||
}
|
||||
|
||||
public void setSub_reasonId(String sub_reasonId) {
|
||||
this.sub_reasonId = sub_reasonId;
|
||||
}
|
||||
|
||||
private String reason = "";
|
||||
|
||||
private String status = "N";
|
||||
|
||||
private String image = "";
|
||||
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getMID() {
|
||||
return MID;
|
||||
}
|
||||
|
||||
public void setMID(int mID) {
|
||||
MID = mID;
|
||||
}
|
||||
|
||||
public String getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(String storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getInTime() {
|
||||
return inTime;
|
||||
}
|
||||
|
||||
public void setInTime(String inTime) {
|
||||
this.inTime = inTime;
|
||||
}
|
||||
|
||||
public String getOutTime() {
|
||||
return outTime;
|
||||
}
|
||||
|
||||
public void setOutTime(String outTime) {
|
||||
this.outTime = outTime;
|
||||
}
|
||||
|
||||
public String getVisitDate() {
|
||||
return visitDate;
|
||||
}
|
||||
|
||||
public void setVisitDate(String visitDate) {
|
||||
this.visitDate = visitDate;
|
||||
}
|
||||
|
||||
public String getKeycontactId() {
|
||||
return keycontactId;
|
||||
}
|
||||
|
||||
public void setKeycontactId(String keycontactId) {
|
||||
this.keycontactId = keycontactId;
|
||||
}
|
||||
|
||||
public String getIsdDeploy() {
|
||||
return isdDeploy;
|
||||
}
|
||||
|
||||
public void setIsdDeploy(String isdDeploy) {
|
||||
this.isdDeploy = isdDeploy;
|
||||
}
|
||||
|
||||
public String getUploadStatus() {
|
||||
return uploadStatus;
|
||||
}
|
||||
|
||||
public void setUploadStatus(String uploadStatus) {
|
||||
this.uploadStatus = uploadStatus;
|
||||
}
|
||||
|
||||
public String getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(String latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(String longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getReasonid() {
|
||||
return reasonid;
|
||||
}
|
||||
|
||||
public void setReasonid(String reasonid) {
|
||||
this.reasonid = reasonid;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
String CheckOut_Image = "";
|
||||
|
||||
|
||||
public String getCheckOut_Image() {
|
||||
return CheckOut_Image;
|
||||
}
|
||||
|
||||
public void setCheckOut_Image(String checkOut_Image) {
|
||||
CheckOut_Image = checkOut_Image;
|
||||
}
|
||||
|
||||
public String getFlag_from() {
|
||||
return flag_from;
|
||||
}
|
||||
|
||||
public void setFlag_from(String flag_from) {
|
||||
this.flag_from = flag_from;
|
||||
}
|
||||
|
||||
String keyAccountId;
|
||||
String classId;
|
||||
|
||||
public String getKeyAccountId() {
|
||||
return keyAccountId;
|
||||
}
|
||||
|
||||
public void setKeyAccountId(String keyAccountId) {
|
||||
this.keyAccountId = keyAccountId;
|
||||
}
|
||||
|
||||
public String getClassId() {
|
||||
return classId;
|
||||
}
|
||||
|
||||
public void setClassId(String classId) {
|
||||
this.classId = classId;
|
||||
}
|
||||
|
||||
public String getStoreTypeId() {
|
||||
return storeTypeId;
|
||||
}
|
||||
|
||||
public void setStoreTypeId(String storeTypeId) {
|
||||
this.storeTypeId = storeTypeId;
|
||||
}
|
||||
|
||||
String storeTypeId;
|
||||
|
||||
public String getMappingStk() {
|
||||
return mappingStk;
|
||||
}
|
||||
|
||||
public void setMappingStk(String mappingStk) {
|
||||
this.mappingStk = mappingStk;
|
||||
}
|
||||
|
||||
String mappingStk="";
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
public class GeotaggingBeans {
|
||||
|
||||
|
||||
|
||||
public String storeid;
|
||||
public String url1;
|
||||
public String url2;
|
||||
public String status;
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String url3;
|
||||
public double Latitude ;
|
||||
public double Longitude;
|
||||
|
||||
public String getStoreid() {
|
||||
return storeid;
|
||||
}
|
||||
public void setStoreid(String storeid) {
|
||||
this.storeid = storeid;
|
||||
}
|
||||
public double getLatitude() {
|
||||
return Latitude;
|
||||
}
|
||||
public void setLatitude(double d) {
|
||||
Latitude = d;
|
||||
}
|
||||
public double getLongitude() {
|
||||
return Longitude;
|
||||
}
|
||||
public void setLongitude(double d) {
|
||||
Longitude = d;
|
||||
}
|
||||
|
||||
|
||||
public void setUrl1(String url1)
|
||||
{
|
||||
|
||||
this.url1=url1;
|
||||
}
|
||||
|
||||
public String getUrl1()
|
||||
{
|
||||
|
||||
return url1;
|
||||
}
|
||||
|
||||
public void setUrl2(String url2)
|
||||
{
|
||||
|
||||
this.url2=url2;
|
||||
}
|
||||
|
||||
public String getUrl2()
|
||||
{
|
||||
|
||||
return url2;
|
||||
}
|
||||
|
||||
public void setUrl3(String url3)
|
||||
{
|
||||
|
||||
this.url3=url3;
|
||||
}
|
||||
|
||||
public String getUrl3()
|
||||
{
|
||||
|
||||
return url3;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OrderReceivedStatus implements Serializable {
|
||||
//TextView sys_gen_poTV,storepoTV,podateTV,lineItemTV,statusTV;
|
||||
String sys_gen_po="";
|
||||
String storepo="";
|
||||
String podate="";
|
||||
String lineItem="";
|
||||
String status="";
|
||||
int SKU_ID;
|
||||
int ORDERQTY;
|
||||
int CATEGORY_ID;
|
||||
int POID;
|
||||
|
||||
public int getPOID() {
|
||||
return POID;
|
||||
}
|
||||
|
||||
public void setPOID(int POID) {
|
||||
this.POID = POID;
|
||||
}
|
||||
|
||||
|
||||
public int getStoreid() {
|
||||
return Storeid;
|
||||
}
|
||||
|
||||
public void setStoreid(int storeid) {
|
||||
Storeid = storeid;
|
||||
}
|
||||
|
||||
int Storeid;
|
||||
|
||||
public int getSKU_ID() {
|
||||
return SKU_ID;
|
||||
}
|
||||
|
||||
public void setSKU_ID(int SKU_ID) {
|
||||
this.SKU_ID = SKU_ID;
|
||||
}
|
||||
|
||||
public int getORDERQTY() {
|
||||
return ORDERQTY;
|
||||
}
|
||||
|
||||
public void setORDERQTY(int ORDERQTY) {
|
||||
this.ORDERQTY = ORDERQTY;
|
||||
}
|
||||
|
||||
public int getCATEGORY_ID() {
|
||||
return CATEGORY_ID;
|
||||
}
|
||||
|
||||
public void setCATEGORY_ID(int CATEGORY_ID) {
|
||||
this.CATEGORY_ID = CATEGORY_ID;
|
||||
}
|
||||
|
||||
|
||||
public String getSys_gen_po() {
|
||||
return sys_gen_po;
|
||||
}
|
||||
|
||||
public void setSys_gen_po(String sys_gen_po) {
|
||||
this.sys_gen_po = sys_gen_po;
|
||||
}
|
||||
|
||||
public String getStorepo() {
|
||||
return storepo;
|
||||
}
|
||||
|
||||
public void setStorepo(String storepo) {
|
||||
this.storepo = storepo;
|
||||
}
|
||||
|
||||
public String getPodate() {
|
||||
return podate;
|
||||
}
|
||||
|
||||
public void setPodate(String podate) {
|
||||
this.podate = podate;
|
||||
}
|
||||
|
||||
public String getLineItem() {
|
||||
return lineItem;
|
||||
}
|
||||
|
||||
public void setLineItem(String lineItem) {
|
||||
this.lineItem = lineItem;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package cpm.com.gskmtorange.GetterSetter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by ashishc on 29-12-2016.
|
||||
*/
|
||||
|
||||
public class StoreBean implements Serializable{
|
||||
|
||||
String STORE_ID;
|
||||
String EMP_ID;
|
||||
String KEYACCOUNT;
|
||||
String STORE_NAME;
|
||||
String ADDRESS;
|
||||
String CITY;
|
||||
String STORETYPE;
|
||||
String CLASSIFICATION;
|
||||
String KEYACCOUNT_ID;
|
||||
String STORETYPE_ID;
|
||||
String CLASS_ID;
|
||||
String VISIT_DATE;
|
||||
String CAMERA_ALLOW;
|
||||
String UPLOAD_STATUS;
|
||||
String LATITUDE;
|
||||
String LONGITUDE;
|
||||
String POG_TYPE_ID;
|
||||
|
||||
public String getFACING_HIDE() {
|
||||
return FACING_HIDE;
|
||||
}
|
||||
|
||||
public void setFACING_HIDE(String FACING_HIDE) {
|
||||
this.FACING_HIDE = FACING_HIDE;
|
||||
}
|
||||
|
||||
String FACING_HIDE;
|
||||
|
||||
public String getSTORE_ID() {
|
||||
return STORE_ID;
|
||||
}
|
||||
|
||||
public void setSTORE_ID(String STORE_ID) {
|
||||
this.STORE_ID = STORE_ID;
|
||||
}
|
||||
|
||||
public String getEMP_ID() {
|
||||
return EMP_ID;
|
||||
}
|
||||
|
||||
public void setEMP_ID(String EMP_ID) {
|
||||
this.EMP_ID = EMP_ID;
|
||||
}
|
||||
|
||||
public String getKEYACCOUNT() {
|
||||
return KEYACCOUNT;
|
||||
}
|
||||
|
||||
public void setKEYACCOUNT(String KEYACCOUNT) {
|
||||
this.KEYACCOUNT = KEYACCOUNT;
|
||||
}
|
||||
|
||||
public String getSTORE_NAME() {
|
||||
return STORE_NAME;
|
||||
}
|
||||
|
||||
public void setSTORE_NAME(String STORE_NAME) {
|
||||
this.STORE_NAME = STORE_NAME;
|
||||
}
|
||||
|
||||
public String getADDRESS() {
|
||||
return ADDRESS;
|
||||
}
|
||||
|
||||
public void setADDRESS(String ADDRESS) {
|
||||
this.ADDRESS = ADDRESS;
|
||||
}
|
||||
|
||||
public String getCITY() {
|
||||
return CITY;
|
||||
}
|
||||
|
||||
public void setCITY(String CITY) {
|
||||
this.CITY = CITY;
|
||||
}
|
||||
|
||||
public String getSTORETYPE() {
|
||||
return STORETYPE;
|
||||
}
|
||||
|
||||
public void setSTORETYPE(String STORETYPE) {
|
||||
this.STORETYPE = STORETYPE;
|
||||
}
|
||||
|
||||
public String getCLASSIFICATION() {
|
||||
return CLASSIFICATION;
|
||||
}
|
||||
|
||||
public void setCLASSIFICATION(String CLASSIFICATION) {
|
||||
this.CLASSIFICATION = CLASSIFICATION;
|
||||
}
|
||||
|
||||
public String getKEYACCOUNT_ID() {
|
||||
return KEYACCOUNT_ID;
|
||||
}
|
||||
|
||||
public void setKEYACCOUNT_ID(String KEYACCOUNT_ID) {
|
||||
this.KEYACCOUNT_ID = KEYACCOUNT_ID;
|
||||
}
|
||||
|
||||
public String getSTORETYPE_ID() {
|
||||
return STORETYPE_ID;
|
||||
}
|
||||
|
||||
public void setSTORETYPE_ID(String STORETYPE_ID) {
|
||||
this.STORETYPE_ID = STORETYPE_ID;
|
||||
}
|
||||
|
||||
public String getCLASS_ID() {
|
||||
return CLASS_ID;
|
||||
}
|
||||
|
||||
public void setCLASS_ID(String CLASS_ID) {
|
||||
this.CLASS_ID = CLASS_ID;
|
||||
}
|
||||
|
||||
public String getVISIT_DATE() {
|
||||
return VISIT_DATE;
|
||||
}
|
||||
|
||||
public void setVISIT_DATE(String VISIT_DATE) {
|
||||
this.VISIT_DATE = VISIT_DATE;
|
||||
}
|
||||
|
||||
public String getCAMERA_ALLOW() {
|
||||
return CAMERA_ALLOW;
|
||||
}
|
||||
|
||||
public void setCAMERA_ALLOW(String CAMERA_ALLOW) {
|
||||
this.CAMERA_ALLOW = CAMERA_ALLOW;
|
||||
}
|
||||
|
||||
public String getUPLOAD_STATUS() {
|
||||
return UPLOAD_STATUS;
|
||||
}
|
||||
|
||||
public void setUPLOAD_STATUS(String UPLOAD_STATUS) {
|
||||
this.UPLOAD_STATUS = UPLOAD_STATUS;
|
||||
}
|
||||
|
||||
public String getCHECKOUT_STATUS() {
|
||||
return CHECKOUT_STATUS;
|
||||
}
|
||||
|
||||
public void setCHECKOUT_STATUS(String CHECKOUT_STATUS) {
|
||||
this.CHECKOUT_STATUS = CHECKOUT_STATUS;
|
||||
}
|
||||
|
||||
public String getGEO_TAG() {
|
||||
return GEO_TAG;
|
||||
}
|
||||
|
||||
public void setGEO_TAG(String GEO_TAG) {
|
||||
this.GEO_TAG = GEO_TAG;
|
||||
}
|
||||
|
||||
String CHECKOUT_STATUS;
|
||||
String GEO_TAG ;
|
||||
|
||||
|
||||
public String getLATITUDE() {
|
||||
return LATITUDE;
|
||||
}
|
||||
|
||||
public void setLATITUDE(String LATITUDE) {
|
||||
this.LATITUDE = LATITUDE;
|
||||
}
|
||||
|
||||
public String getLONGITUDE() {
|
||||
return LONGITUDE;
|
||||
}
|
||||
|
||||
public void setLONGITUDE(String LONGITUDE) {
|
||||
this.LONGITUDE = LONGITUDE;
|
||||
}
|
||||
|
||||
public String getPOG_TYPE_ID() {
|
||||
return POG_TYPE_ID;
|
||||
}
|
||||
|
||||
public void setPOG_TYPE_ID(String POG_TYPE_ID) {
|
||||
this.POG_TYPE_ID = POG_TYPE_ID;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,494 @@
|
||||
package cpm.com.gskmtorange;
|
||||
|
||||
import android.Manifest;
|
||||
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.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GeoTag.GeoTagStoreList;
|
||||
import cpm.com.gskmtorange.GetterSetter.CoverageBean;
|
||||
import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.dailyentry.CounterfeitIndicatorWebActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.DeliveryCallActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.FutureJCPActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.PlanogramPDFActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.ServiceActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.SettingsActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.StoreListActivity;
|
||||
import cpm.com.gskmtorange.download.DownloadActivity;
|
||||
import cpm.com.gskmtorange.password.ChangePasswordActivity;
|
||||
import cpm.com.gskmtorange.pharma_stores.PharmaActivity;
|
||||
import cpm.com.gskmtorange.pharma_stores.PharmaActivityFragment;
|
||||
import cpm.com.gskmtorange.upload.PreviousDataUploadActivity;
|
||||
import cpm.com.gskmtorange.upload.UploadActivity;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationMasterGetterSetter;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
private Context context;
|
||||
WebView webView;
|
||||
ImageView imageView;
|
||||
String date;
|
||||
private SharedPreferences preferences = null;
|
||||
GSKOrangeDB db;
|
||||
String user_name, country_id;
|
||||
ArrayList<StoreBean> storelist = new ArrayList<StoreBean>();
|
||||
View headerView;
|
||||
ArrayList<CoverageBean> coverageList;
|
||||
String error_msg;
|
||||
Toolbar toolbar;
|
||||
NavigationView navigationView;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
context = this;
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
imageView = (ImageView) findViewById(R.id.img_main);
|
||||
webView = (WebView) findViewById(R.id.webview);
|
||||
String url = preferences.getString(CommonString.KEY_NOTICE_BOARD_LINK, "");
|
||||
user_name = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, null);
|
||||
db = new GSKOrangeDB(MainActivity.this);
|
||||
webView.setWebViewClient(new MyWebViewClient());
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
if (!url.isEmpty()) {
|
||||
webView.loadUrl(url);
|
||||
}
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.setDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
headerView = LayoutInflater.from(this).inflate(R.layout.nav_header_main, navigationView, false);
|
||||
TextView tv_username = (TextView) headerView.findViewById(R.id.nav_user_name);
|
||||
//tv_usertype = (TextView) headerView.findViewById(R.id.nav_user_type);
|
||||
ImageView img_change_password = (ImageView) headerView.findViewById(R.id.img_change_password);
|
||||
tv_username.setText(user_name);
|
||||
//tv_usertype.setText(user_type);
|
||||
|
||||
img_change_password.setOnClickListener(v -> {
|
||||
Intent in = new Intent(context, ChangePasswordActivity.class);
|
||||
startActivity(in);
|
||||
});
|
||||
|
||||
navigationView.addHeaderView(headerView);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getString(R.string.main_menu_activity_name));
|
||||
db.open();
|
||||
//usk
|
||||
navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
// get menu from navigationView
|
||||
Menu menu = navigationView.getMenu();
|
||||
// find MenuItem you want to change
|
||||
MenuItem nav_route_plan = menu.findItem(R.id.nav_route_plan);
|
||||
nav_route_plan.setTitle(getResources().getString(R.string.menu_daily_route_plan));
|
||||
MenuItem nav_route_plan1 = menu.findItem(R.id.nav_download);
|
||||
nav_route_plan1.setTitle(getResources().getString(R.string.menu_daily_download));
|
||||
MenuItem nav_route_plan2 = menu.findItem(R.id.nav_upload);
|
||||
nav_route_plan2.setTitle(getResources().getString(R.string.menu_upload_data));
|
||||
MenuItem nav_route_plan3 = menu.findItem(R.id.nav_geotag);
|
||||
nav_route_plan3.setTitle(getResources().getString(R.string.menu_geotag));
|
||||
MenuItem nav_route_plan4 = menu.findItem(R.id.nav_deviation);
|
||||
nav_route_plan4.setTitle(getResources().getString(R.string.menu_deviation_data));
|
||||
MenuItem nav_route_plan5 = menu.findItem(R.id.nav_delivery_call);
|
||||
nav_route_plan5.setTitle(getResources().getString(R.string.delivery_call));
|
||||
MenuItem nav_route_plan6 = menu.findItem(R.id.nav_future_jcp);
|
||||
nav_route_plan6.setTitle(getResources().getString(R.string.future_route_plan));
|
||||
MenuItem nav_route_plan7 = menu.findItem(R.id.nav_planogram);
|
||||
nav_route_plan7.setTitle(getResources().getString(R.string.category_performance_PLANOGRAM));
|
||||
MenuItem nav_route_plan8 = menu.findItem(R.id.nav_pharmacy_stores);
|
||||
nav_route_plan8.setTitle(getResources().getString(R.string.pharma_stores));
|
||||
MenuItem nav_route_plan9 = menu.findItem(R.id.nav_additional_stores);
|
||||
nav_route_plan9.setTitle(getResources().getString(R.string.additional_stores));
|
||||
MenuItem nav_route_plan10 = menu.findItem(R.id.nav_additional_adhoc_stores);
|
||||
nav_route_plan10.setTitle(getResources().getString(R.string.additional_adhoc_stores));
|
||||
MenuItem nav_route_plan11 = menu.findItem(R.id.nav_counterfeit_indicator);
|
||||
nav_route_plan11.setTitle(getResources().getString(R.string.title_activity_counterfeit_indicator_web));
|
||||
MenuItem nav_route_plan12 = menu.findItem(R.id.nav_exit);
|
||||
nav_route_plan12.setTitle(getResources().getString(R.string.menu_exit));
|
||||
MenuItem nav_route_plan13 = menu.findItem(R.id.nav_setting);
|
||||
nav_route_plan13.setTitle(getResources().getString(R.string.menu_setting));
|
||||
MenuItem nav_route_plan14 = menu.findItem(R.id.nav_services);
|
||||
nav_route_plan14.setTitle(getResources().getString(R.string.menu_services));
|
||||
//Enable disable According to Configuration
|
||||
ArrayList<ConfigurationMasterGetterSetter> configurationData = db.getConfigurationMasterData(country_id);
|
||||
if (!configurationData.isEmpty()) {
|
||||
for (int i = 0; i < configurationData.size(); i++) {
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("ADHOC REPORTING") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
Menu nav_Menu = navigationView.getMenu();
|
||||
nav_Menu.findItem(R.id.nav_deviation).setVisible(true);
|
||||
}
|
||||
//temp remove it
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("PDF ALLOW") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
Menu nav_Menu = navigationView.getMenu();
|
||||
nav_Menu.findItem(R.id.nav_planogram).setVisible(true);
|
||||
}
|
||||
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("DELIVERY CALLS") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
Menu nav_Menu = navigationView.getMenu();
|
||||
nav_Menu.findItem(R.id.nav_delivery_call).setVisible(true);
|
||||
}
|
||||
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("ADDITIONAL STORE") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
Menu nav_Menu = navigationView.getMenu();
|
||||
nav_Menu.findItem(R.id.nav_additional_stores).setVisible(true);
|
||||
}
|
||||
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("PHARMA STORE") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
Menu nav_Menu = navigationView.getMenu();
|
||||
nav_Menu.findItem(R.id.nav_pharmacy_stores).setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("COUNTERFEIT INDICATORS") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
Menu nav_Menu = navigationView.getMenu();
|
||||
nav_Menu.findItem(R.id.nav_counterfeit_indicator).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
db.open();
|
||||
coverageList = db.getCoverageData(date, null);
|
||||
storelist = db.getStoreData(date, CommonString.KEY_JOURNEY_PLAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
// super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
// Handle navigation view item clicks here.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.nav_route_plan) {
|
||||
Intent in_jcp = new Intent(this, StoreListActivity.class);
|
||||
in_jcp.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_JCP);
|
||||
startActivity(in_jcp);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (id == R.id.nav_download) {
|
||||
downloadMethod();
|
||||
} else if (id == R.id.nav_upload) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
||||
builder.setTitle(getResources().getString(R.string.dialog_title));
|
||||
builder.setMessage(getResources().getString(R.string.want_to_upload)).setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.ok), (dialog, id1) -> {
|
||||
db.open();
|
||||
if (checkNetIsAvailable()) {
|
||||
if (db.getSKUMasterData(null).isEmpty()) {
|
||||
Snackbar.make(webView, R.string.title_store_list_download_data, Snackbar.LENGTH_SHORT)
|
||||
.setAction("Action", null).show();
|
||||
} else {
|
||||
if (coverageList.isEmpty()) {
|
||||
Snackbar.make(webView, R.string.no_data_for_upload, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
} else {
|
||||
if (isStoreCheckedIn() && isValid()) {
|
||||
Intent i = new Intent(getBaseContext(), UploadActivity.class);
|
||||
startActivity(i);
|
||||
} else {
|
||||
Snackbar.make(webView, error_msg, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(webView, getResources().getString(R.string.nonetwork), Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
}
|
||||
}).setNegativeButton(getResources().getString(R.string.cancel), (dialog, which) -> dialog.dismiss());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
} else if (id == R.id.nav_geotag) {
|
||||
if (!storelist.isEmpty()) {
|
||||
Intent startDownload = new Intent(this, GeoTagStoreList.class);
|
||||
startActivity(startDownload);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
Snackbar.make(headerView, R.string.title_store_list_download_data, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
}
|
||||
|
||||
} else if (id == R.id.nav_exit) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
||||
builder.setTitle(getResources().getString(R.string.dialog_title));
|
||||
builder.setMessage(getResources().getString(R.string.want_to_exit)).setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.ok), (dialog, id12) -> {
|
||||
ActivityCompat.finishAffinity(MainActivity.this);
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}).setNegativeButton(getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
} else if (id == R.id.nav_setting) {
|
||||
Intent startDownload = new Intent(this, SettingsActivity.class);
|
||||
startActivity(startDownload);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (id == R.id.nav_services) {
|
||||
Intent startservice = new Intent(this, ServiceActivity.class);
|
||||
startActivity(startservice);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (id == R.id.nav_future_jcp) {
|
||||
Intent startDownload = new Intent(this, FutureJCPActivity.class);
|
||||
startActivity(startDownload);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (id == R.id.nav_planogram) {
|
||||
if (checkNetIsAvailable()) {
|
||||
Intent planogram_pdf = new Intent(this, PlanogramPDFActivity.class);
|
||||
startActivity(planogram_pdf);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
Snackbar.make(webView, getResources().getString(R.string.nonetwork), Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
}
|
||||
|
||||
} else if (id == R.id.nav_deviation) {
|
||||
db.open();
|
||||
if (db.getSKUMasterData(null).isEmpty()) {
|
||||
Snackbar.make(webView, R.string.title_store_list_download_data, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
} else {
|
||||
Intent in = new Intent(this, StoreListActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_DEVIATION);
|
||||
startActivity(in);
|
||||
}
|
||||
} else if (id == R.id.nav_delivery_call) {
|
||||
Intent in = new Intent(this, DeliveryCallActivity.class);
|
||||
startActivity(in);
|
||||
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (id == R.id.nav_pharmacy_stores) {
|
||||
Intent in = new Intent(this, StoreListActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_PHARMA);
|
||||
startActivity(in);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else if (id == R.id.nav_additional_stores) {
|
||||
db.open();
|
||||
if (db.getSKUMasterData(null).isEmpty()) {
|
||||
Snackbar.make(webView, R.string.title_store_list_download_data, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
} else {
|
||||
Intent in = new Intent(this, StoreListActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_ADDITIONAL);
|
||||
startActivity(in);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
} else if (id == R.id.nav_additional_adhoc_stores) {
|
||||
db.open();
|
||||
if (db.getSKUMasterData(null).isEmpty()) {
|
||||
Snackbar.make(webView, R.string.title_store_list_download_data, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
} else {
|
||||
Intent in = new Intent(this, StoreListActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_FLAG, CommonString.FROM_ADDITIONAL_ADHOC);
|
||||
startActivity(in);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
} else if (id == R.id.nav_counterfeit_indicator) {
|
||||
Intent intent = new Intent(this, CounterfeitIndicatorWebActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
|
||||
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) {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean checkNetIsAvailable() {
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
boolean isConnected = activeNetwork != null &&
|
||||
activeNetwork.isConnectedOrConnecting();
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
public boolean isStoreCheckedIn() {
|
||||
|
||||
boolean result_flag = true;
|
||||
for (int i = 0; i < coverageList.size(); i++) {
|
||||
|
||||
String status = coverageList.get(i).getStatus();
|
||||
if (status.equals(CommonString.KEY_INVALID) || status.equals(CommonString.KEY_VALID)) {
|
||||
result_flag = false;
|
||||
error_msg = getResources().getString(R.string.title_store_list_checkout_current);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result_flag;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
boolean flag = false;
|
||||
String storestatus = "";
|
||||
for (int i = 0; i < coverageList.size(); i++) {
|
||||
|
||||
StoreBean store_data = db.getSpecificStoreData(date, coverageList.get(i).getStoreId(), coverageList.get(i).getFlag_from());
|
||||
|
||||
storestatus = store_data.getUPLOAD_STATUS();
|
||||
String coverage_status = store_data.getCHECKOUT_STATUS();
|
||||
|
||||
if (!storestatus.equalsIgnoreCase(CommonString.KEY_U) && !storestatus.equalsIgnoreCase(CommonString.KEY_UN)) {
|
||||
if ((coverage_status.equalsIgnoreCase(CommonString.KEY_Y) || storestatus.equalsIgnoreCase(CommonString.KEY_P) ||
|
||||
storestatus.equalsIgnoreCase(CommonString.STORE_STATUS_LEAVE))) {
|
||||
flag = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
error_msg = getResources().getString(R.string.no_data_for_upload);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public boolean isPreviousValid(String visit_date) {
|
||||
boolean isvalid = false;
|
||||
ArrayList<CoverageBean> coverage_list = db.getPreviousCoverageData(visit_date, null);
|
||||
for (int i = 0; i < coverage_list.size(); i++) {
|
||||
StoreBean storeData = db.getSpecificStoreData(coverage_list.get(i).getVisitDate(), coverage_list.get(i).getStoreId(), coverage_list.get(i).getFlag_from());
|
||||
if (storeData.getSTORE_ID() != null) {
|
||||
|
||||
if (!storeData.getUPLOAD_STATUS().equals(CommonString.KEY_U) && !storeData.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_UN) && (storeData.getCHECKOUT_STATUS().equals(CommonString.KEY_Y) ||
|
||||
storeData.getCHECKOUT_STATUS().equals(CommonString.KEY_L) || storeData.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_P))) {
|
||||
isvalid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isvalid;
|
||||
}
|
||||
|
||||
//for download
|
||||
public void downloadMethod() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
||||
builder.setTitle(getResources().getString(R.string.dialog_title));
|
||||
builder.setMessage(getResources().getString(R.string.want_to_download)).setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.ok), (dialog, id) -> {
|
||||
if (checkNetIsAvailable()) {
|
||||
boolean previousflag = false;
|
||||
if (db.isPreviousCoverageDataFilled(date)) {
|
||||
if (isPreviousValid(date)) {
|
||||
previousflag = true;
|
||||
} else {
|
||||
db.deletePreviousCoverageData(date);
|
||||
}
|
||||
}
|
||||
|
||||
if (previousflag) {
|
||||
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
|
||||
builder1.setTitle("Parinaam");
|
||||
builder1.setMessage(getResources().getString(R.string.previous_data_upload)).setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.ok), (dialog1, id1) -> {
|
||||
Intent in = new Intent(context, PreviousDataUploadActivity.class);
|
||||
startActivity(in);
|
||||
//finish();
|
||||
});
|
||||
AlertDialog alert = builder1.create();
|
||||
alert.show();
|
||||
|
||||
} else {
|
||||
Intent in = new Intent(context, DownloadActivity.class);
|
||||
startActivity(in);
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(webView, getResources().getString(R.string.nonetwork), Snackbar.LENGTH_SHORT).setAction("Action", null).show();
|
||||
}
|
||||
}).setNegativeButton(getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package cpm.com.gskmtorange;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
public class MovableFloatingActionButton extends FloatingActionButton implements View.OnTouchListener {
|
||||
|
||||
private final static float CLICK_DRAG_TOLERANCE = 10; // Often, there will be a slight, unintentional, drag when the user taps the FAB, so we need to account for this.
|
||||
|
||||
private float downRawX, downRawY;
|
||||
private float dX, dY;
|
||||
|
||||
public MovableFloatingActionButton(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public MovableFloatingActionButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public MovableFloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setOnTouchListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent){
|
||||
|
||||
int action = motionEvent.getAction();
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
|
||||
downRawX = motionEvent.getRawX();
|
||||
downRawY = motionEvent.getRawY();
|
||||
dX = view.getX() - downRawX;
|
||||
dY = view.getY() - downRawY;
|
||||
|
||||
return true; // Consumed
|
||||
|
||||
}
|
||||
else if (action == MotionEvent.ACTION_MOVE) {
|
||||
|
||||
int viewWidth = view.getWidth();
|
||||
int viewHeight = view.getHeight();
|
||||
|
||||
View viewParent = (View)view.getParent();
|
||||
int parentWidth = viewParent.getWidth();
|
||||
int parentHeight = viewParent.getHeight();
|
||||
|
||||
float newX = motionEvent.getRawX() + dX;
|
||||
newX = Math.max(0, newX); // Don't allow the FAB past the left hand side of the parent
|
||||
newX = Math.min(parentWidth - viewWidth, newX); // Don't allow the FAB past the right hand side of the parent
|
||||
|
||||
float newY = motionEvent.getRawY() + dY;
|
||||
newY = Math.max(0, newY); // Don't allow the FAB past the top of the parent
|
||||
newY = Math.min(parentHeight - viewHeight, newY); // Don't allow the FAB past the bottom of the parent
|
||||
|
||||
view.animate()
|
||||
.x(newX)
|
||||
.y(newY)
|
||||
.setDuration(0)
|
||||
.start();
|
||||
|
||||
return true; // Consumed
|
||||
|
||||
}
|
||||
else if (action == MotionEvent.ACTION_UP) {
|
||||
|
||||
float upRawX = motionEvent.getRawX();
|
||||
float upRawY = motionEvent.getRawY();
|
||||
|
||||
float upDX = upRawX - downRawX;
|
||||
float upDY = upRawY - downRawY;
|
||||
|
||||
if (Math.abs(upDX) < CLICK_DRAG_TOLERANCE && Math.abs(upDY) < CLICK_DRAG_TOLERANCE) { // A click
|
||||
return performClick();
|
||||
}
|
||||
else { // A drag
|
||||
return true; // Consumed
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cpm.com.gskmtorange.Paralleldots;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
|
||||
public class PdJavaImageActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_pd_java_image);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package cpm.com.gskmtorange;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.password.MPinActivity;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.LoginGetterSetter;
|
||||
|
||||
public class SelectLanguageActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
Button btn_lang_1, btn_lang_2;
|
||||
private Context context;
|
||||
private SharedPreferences preferences = null;
|
||||
private SharedPreferences.Editor editor = null;
|
||||
LoginGetterSetter login_data;
|
||||
ArrayList<String> language, culture_id;
|
||||
boolean selected_flag = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_select_language);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
editor = preferences.edit();
|
||||
btn_lang_1 = (Button) findViewById(R.id.btn_language_one);
|
||||
btn_lang_2 = (Button) findViewById(R.id.btn_language_two);
|
||||
login_data = (LoginGetterSetter) getIntent().getSerializableExtra(CommonString.KEY_LOGIN_DATA);
|
||||
language = login_data.getCULTURE_NAME();
|
||||
culture_id = login_data.getCULTURE_ID();
|
||||
setDataFromSharedPreferences(login_data);
|
||||
if (language.size() > 1) {
|
||||
btn_lang_1.setText(language.get(0));
|
||||
btn_lang_2.setText(language.get(1));
|
||||
btn_lang_1.setOnClickListener(this);
|
||||
btn_lang_2.setOnClickListener(this);
|
||||
}
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (selected_flag) {
|
||||
/* Intent intent = new Intent(getBaseContext(),
|
||||
MainActivity.class);
|
||||
intent.putExtra(CommonString.KEY_LOGIN_DATA, login_data);
|
||||
startActivity(intent);
|
||||
finish();*/
|
||||
|
||||
Intent in = new Intent(context, MPinActivity.class);
|
||||
in.putExtra(CommonString.IS_PASSWORD_CHECK, false);
|
||||
startActivity(in);
|
||||
finish();
|
||||
|
||||
} else {
|
||||
Snackbar.make(view, getString(R.string.select_language), Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
|
||||
switch (id) {
|
||||
case R.id.btn_language_one:
|
||||
selected_flag = true;
|
||||
CommonFunctions.updateLangResources(context, language.get(0));
|
||||
btn_lang_1.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
||||
btn_lang_1.setTextColor(getResources().getColor(R.color.white));
|
||||
btn_lang_2.setTextColor(getResources().getColor(R.color.black));
|
||||
btn_lang_2.setBackgroundColor(getResources().getColor(R.color.grey_background));
|
||||
editor.putString(CommonString.KEY_LANGUAGE, language.get(0));
|
||||
editor.putString(CommonString.KEY_CULTURE_ID, culture_id.get(0));
|
||||
editor.putString(CommonString.KEY_NOTICE_BOARD_LINK, login_data.getNOTICE_URL().get(0));
|
||||
editor.commit();
|
||||
break;
|
||||
|
||||
case R.id.btn_language_two:
|
||||
selected_flag = true;
|
||||
CommonFunctions.updateLangResources(context, language.get(1));
|
||||
btn_lang_1.setBackgroundColor(getResources().getColor(R.color.grey_background));
|
||||
btn_lang_1.setTextColor(getResources().getColor(R.color.black));
|
||||
btn_lang_2.setTextColor(getResources().getColor(R.color.white));
|
||||
btn_lang_2.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
||||
editor.putString(CommonString.KEY_LANGUAGE, language.get(1));
|
||||
editor.putString(CommonString.KEY_CULTURE_ID, culture_id.get(1));
|
||||
editor.putString(CommonString.KEY_NOTICE_BOARD_LINK, login_data.getNOTICE_URL().get(1));
|
||||
editor.commit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setDataFromSharedPreferences(LoginGetterSetter lgs) {
|
||||
Gson gson = new Gson();
|
||||
String jsonCurProduct = gson.toJson(lgs);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString(CommonString.KEY_LOOGIN_PREF, jsonCurProduct);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package cpm.com.gskmtorange;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.password.MPinActivity;
|
||||
|
||||
public class SplashScreenActivity extends AppCompatActivity {
|
||||
|
||||
private static int SPLASH_TIME_OUT = 3000;
|
||||
LinearLayout linearLayout;
|
||||
private Context context;
|
||||
private SharedPreferences preferences = null;
|
||||
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Window window = getWindow();
|
||||
window.setFormat(PixelFormat.RGBA_8888);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_splash_main_layout);
|
||||
|
||||
linearLayout = findViewById(R.id.lin_lay);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
context = this;
|
||||
//StartAnimations();
|
||||
|
||||
sendToLogin();
|
||||
|
||||
/* File f = new File(CommonString.getImagesFolder(context)_OLD);
|
||||
if(f!=null){
|
||||
File file[] = f.listFiles();
|
||||
if(file!=null){
|
||||
|
||||
for (int i=0;i<file.length;i++){
|
||||
Date lastModDate = new Date(file[0].lastModified());
|
||||
String day = lastModDate.toString();
|
||||
|
||||
*//*SimpleDateFormat spf= new SimpleDateFormat("MM/dd/yyyy");
|
||||
date = spf.format(newDate);
|
||||
System.out.println(date);*//*
|
||||
}
|
||||
*//* if(file.length>0){
|
||||
UploadImageWithRetrofit.uploadedFiles = 0;
|
||||
UploadImageWithRetrofit.totalFiles = file.length;
|
||||
UploadImageWithRetrofit uploadImg = new UploadImageWithRetrofit( SplashScreenActivity.this);
|
||||
uploadImg.UploadImageRecursive(SplashScreenActivity.this);
|
||||
}
|
||||
else {
|
||||
sendToLogin();
|
||||
}*//*
|
||||
}else {
|
||||
sendToLogin();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
sendToLogin();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
/* private void StartAnimations() {
|
||||
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
|
||||
anim.reset();
|
||||
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
|
||||
l.clearAnimation();
|
||||
l.startAnimation(anim);
|
||||
|
||||
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
|
||||
anim.reset();
|
||||
ImageView iv = (ImageView) findViewById(R.id.logo);
|
||||
iv.clearAnimation();
|
||||
iv.startAnimation(anim);
|
||||
|
||||
}*/
|
||||
|
||||
public void sendToLogin() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
|
||||
/*
|
||||
* Showing splash screen with a timer. This will be useful when you
|
||||
* want to show case your app logo / company
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//after Mpin
|
||||
String mpin = preferences.getString(CommonString.MPIN, null);
|
||||
if (mpin != null) {
|
||||
Intent in = new Intent(context, MPinActivity.class);
|
||||
in.putExtra(CommonString.IS_PASSWORD_CHECK, true);
|
||||
startActivity(in);
|
||||
finish();
|
||||
} else {
|
||||
Intent i = new Intent(context, LoginActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
}, SPLASH_TIME_OUT);
|
||||
}
|
||||
|
||||
public static String getCalculatedDate(String date, String dateFormat, int days) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat s = new SimpleDateFormat(dateFormat);
|
||||
cal.add(Calendar.DAY_OF_YEAR, days);
|
||||
try {
|
||||
return s.format(new Date(s.parse(date).getTime()));
|
||||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
Log.e("TAG", "Error in Parsing Date : " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package cpm.com.gskmtorange.adapter;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.listener.DragListener;
|
||||
import cpm.com.gskmtorange.listener.Listener;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.NoCameraDataGetterSetter;
|
||||
|
||||
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListViewHolder>
|
||||
implements View.OnTouchListener {
|
||||
|
||||
private List<NoCameraDataGetterSetter> list;
|
||||
private Listener listener;
|
||||
|
||||
public ListAdapter(List<NoCameraDataGetterSetter> list, Listener listener) {
|
||||
this.list = list;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(
|
||||
parent.getContext()).inflate(R.layout.brand_item_top_item, parent, false);
|
||||
return new ListViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ListViewHolder holder, int position) {
|
||||
holder.text.setText(list.get(position).getSKUGROUP_NAME());
|
||||
holder.linear_parent.setTag(position);
|
||||
holder.linear_parent.setOnTouchListener(this);
|
||||
holder.linear_parent.setOnDragListener(new DragListener(listener));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
ClipData data = ClipData.newPlainText("", "");
|
||||
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
v.startDragAndDrop(data, shadowBuilder, v, 0);
|
||||
} else {
|
||||
v.startDrag(data, shadowBuilder, v, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<NoCameraDataGetterSetter> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
void updateList(List<NoCameraDataGetterSetter> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public DragListener getDragInstance() {
|
||||
if (listener != null) {
|
||||
return new DragListener(listener);
|
||||
} else {
|
||||
Log.e("ListAdapter", "Listener wasn't initialized!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class ListViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView text;
|
||||
LinearLayout linear_parent;
|
||||
|
||||
ListViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
text = (TextView) itemView.findViewById(R.id.tv_brand);
|
||||
linear_parent = (LinearLayout) itemView.findViewById(R.id.linear_parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package cpm.com.gskmtorange.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.listener.DragListener;
|
||||
import cpm.com.gskmtorange.listener.Listener;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.NoCameraDataGetterSetter;
|
||||
|
||||
/**
|
||||
* Created by yadavendras on 17-10-2017.
|
||||
*/
|
||||
|
||||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
|
||||
|
||||
private LayoutInflater inflator;
|
||||
|
||||
List<NoCameraDataGetterSetter> data = Collections.emptyList();
|
||||
private Listener listener;
|
||||
RecyclerView rec;
|
||||
|
||||
public MyAdapter(Context context, List<NoCameraDataGetterSetter> data, Listener listener, RecyclerView rec) {
|
||||
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
this.listener = listener;
|
||||
this.rec = rec;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = inflator.inflate(R.layout.brand_item, parent, false);
|
||||
|
||||
MyAdapter.MyViewHolder holder = new MyAdapter.MyViewHolder(view);
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MyViewHolder holder, final int position) {
|
||||
|
||||
final NoCameraDataGetterSetter current = data.get(position);
|
||||
|
||||
if(current.getSKUGROUP_ID()!=null){
|
||||
if(current.getSKUGROUP_ID().equals("-1")){
|
||||
holder.parent_card.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.parent_card.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams lprams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
|
||||
int width;
|
||||
if(current.isVertical()){
|
||||
width = current.getFacing()* CommonString.UNIT_VERTICAL;
|
||||
}
|
||||
else {
|
||||
width = current.getFacing()* CommonString.UNIT_HORIZONTAL;
|
||||
}
|
||||
|
||||
lprams.width = width;
|
||||
lprams.setMargins(2,0,0,0);
|
||||
holder.parent_card.setLayoutParams(lprams);
|
||||
}
|
||||
|
||||
final String name = current.getSKUGROUP_NAME();
|
||||
|
||||
holder.name.setText(name);
|
||||
holder.tv_facing.setText(current.getFacing()+"");
|
||||
|
||||
holder.linear_parent.setTag(position);
|
||||
//holder.linear_parent.getLayoutParams().width = 100;
|
||||
//holder.linear_parent.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
holder.linear_parent.setOnDragListener(new DragListener(listener));
|
||||
|
||||
holder.linear_parent.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
//Blank item cannot be edited or deleted
|
||||
if(!current.getSKUGROUP_ID().equals("-1")){
|
||||
listener.deleteItem(view, position, rec,current);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public DragListener getDragInstance() {
|
||||
if (listener != null) {
|
||||
return new DragListener(listener);
|
||||
} else {
|
||||
Log.e("ListAdapter", "Listener wasn't initialized!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
public List<NoCameraDataGetterSetter> getList() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void updateList(List<NoCameraDataGetterSetter> list) {
|
||||
this.data = list;
|
||||
}
|
||||
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView name;
|
||||
TextView tv_facing;
|
||||
LinearLayout linear_parent;
|
||||
CardView parent_card;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
name = (TextView) itemView.findViewById(R.id.tv_brand);
|
||||
tv_facing = (TextView) itemView.findViewById(R.id.tv_facing);
|
||||
linear_parent = (LinearLayout) itemView.findViewById(R.id.linear_parent);
|
||||
parent_card = (CardView) itemView.findViewById(R.id.parent_card);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cpm.com.gskmtorange.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import cpm.com.gskmtorange.R
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri
|
||||
import cpm.com.gskmtorange.constant.CommonUtils.imgPreviewwithError
|
||||
|
||||
class SavedImagesAdapter(private val context: Context, private val images: List<ImageUri>) :
|
||||
RecyclerView.Adapter<SavedImagesAdapter.SavedImageViewHolder>() {
|
||||
|
||||
class SavedImageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val imageView: ShapeableImageView = view.findViewById(R.id.imageView)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SavedImageViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_image, parent, false)
|
||||
return SavedImageViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SavedImageViewHolder, position: Int) {
|
||||
imgPreviewwithError(
|
||||
context = context,
|
||||
url = images[position].uri,
|
||||
imgView = holder.imageView,
|
||||
R.drawable.pdr
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = images.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cpm.com.gskmtorange.adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri
|
||||
import cpm.com.gskmtorange.databinding.ItemSubcategoryPdBinding
|
||||
|
||||
class SubCatPdAdapter(
|
||||
val category: String?,
|
||||
var context: Context,
|
||||
private var subcates: ArrayList<CategoryPictureGetterSetter>?,
|
||||
private val btnlistener: BtnClickListener,
|
||||
) : RecyclerView.Adapter<SubCatPdAdapter.CustomViewHolder>() {
|
||||
class CustomViewHolder(view: View) : RecyclerView.ViewHolder(view)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = CustomViewHolder(
|
||||
ItemSubcategoryPdBinding.inflate(LayoutInflater.from(context), parent, false).root
|
||||
)
|
||||
|
||||
@SuppressLint(
|
||||
"NotifyDataSetChanged", "ClickableViewAccessibility",
|
||||
"UseCompatLoadingForDrawables", "SetTextI18n"
|
||||
)
|
||||
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
|
||||
ItemSubcategoryPdBinding.bind(holder.itemView).apply {
|
||||
val subcat = subcates!![position]
|
||||
tvSubCategory.text = "$category - ${subcat.suB_CATEGORY}"
|
||||
imgStartSession.setOnClickListener {
|
||||
btnlistener.onStartSessionClick(_pos = position, data = subcat)
|
||||
}
|
||||
|
||||
val savedImagesAdapter =
|
||||
SavedImagesAdapter(context = context, images = subcat.imageUris)
|
||||
imgRecycler.adapter = savedImagesAdapter
|
||||
imgRecycler.setLayoutManager(GridLayoutManager(context, 3))
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return subcates!!.size
|
||||
}
|
||||
|
||||
interface BtnClickListener {
|
||||
fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun addsubCatItems(langList: ArrayList<CategoryPictureGetterSetter>?) {
|
||||
subcates = langList
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun updateItem(position: Int, uris: List<ImageUri>) {
|
||||
subcates!![position].imageUris = (subcates!![position].imageUris
|
||||
?: ArrayList()).apply { addAll(uris as ArrayList<ImageUri>) }
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package cpm.com.gskmtorange.adapter.data
|
||||
|
||||
data class ImageUri(val uri: String, val modify_uri: String)
|
||||
@@ -0,0 +1,306 @@
|
||||
package cpm.com.gskmtorange.autoupdate;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
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;
|
||||
import java.util.Locale;
|
||||
|
||||
import cpm.com.gskmtorange.LoginActivity;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
|
||||
public class AutoUpdateActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
String versionCode;
|
||||
int length;
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
private Data data;
|
||||
String path = "", p, s;
|
||||
ProgressBar progressBar;
|
||||
private boolean status;
|
||||
private SharedPreferences preferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
Intent intent = getIntent();
|
||||
context = this;
|
||||
path = intent.getStringExtra(CommonString.KEY_PATH);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getString(R.string.new_update_available))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(AutoUpdateActivity.this);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
|
||||
/*new File(
|
||||
"/data/data/com.cpm.gsk_mt/databases/GTMT_DATABASE")
|
||||
.delete();*/
|
||||
|
||||
new DownloadTask(AutoUpdateActivity.this).execute();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
|
||||
alert.show();
|
||||
|
||||
}
|
||||
|
||||
private class DownloadTask extends AsyncTask<Void, Data, String> {
|
||||
|
||||
private Context context;
|
||||
|
||||
DownloadTask(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
|
||||
super.onPreExecute();
|
||||
|
||||
dialog = new Dialog(context);
|
||||
dialog.setContentView(R.layout.custom_layout);
|
||||
dialog.setTitle("Download");
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
|
||||
try {
|
||||
data = new Data();
|
||||
data.name = "Downloading Application";
|
||||
publishProgress(data);
|
||||
|
||||
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.setDoOutput(true);
|
||||
c.getResponseCode();
|
||||
c.connect();
|
||||
length = c.getContentLength();
|
||||
|
||||
String size = new DecimalFormat("##.##")
|
||||
.format((double) ((double) length / 1024) / 1024)
|
||||
+ " MB";
|
||||
Log.e("appsize",size);
|
||||
|
||||
/*String PATH = Environment.getExternalStorageDirectory()
|
||||
+ "/download/";*/
|
||||
String PATH = CommonString.getApkFolder(context);
|
||||
File file = new File(PATH);
|
||||
// file.mkdirs();
|
||||
File outputFile = new File(file, "app.apk");
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
|
||||
InputStream is = c.getInputStream();
|
||||
|
||||
int bytes = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
int len1 = 0;
|
||||
|
||||
while ((len1 = is.read(buffer)) != -1) {
|
||||
|
||||
bytes = (bytes + len1);
|
||||
|
||||
s = new DecimalFormat("##.##")
|
||||
.format((double) ((double) (bytes / 1024)) / 1024);
|
||||
|
||||
p = s.length() == 3 ? s + "0" : s;
|
||||
|
||||
p = p + " MB";
|
||||
data.value = (int) ((double) (((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 e) {
|
||||
// TODO Auto-generated catch block
|
||||
/* final AlertMessage message = new AlertMessage(
|
||||
AutoUpdateActivity.this,
|
||||
AlertMessage.MESSAGE_EXCEPTION, "download", e);*/
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
showAlert(CommonString.MESSAGE_EXCEPTION);
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
|
||||
/* final AlertMessage message = new AlertMessage(
|
||||
AutoUpdateActivity.this,
|
||||
AlertMessage.MESSAGE_EXCEPTION, "download", e);*/
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
showAlert(CommonString.MESSAGE_EXCEPTION);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (IOException e) {
|
||||
/* final AlertMessage message = new AlertMessage(
|
||||
AutoUpdateActivity.this,
|
||||
AlertMessage.MESSAGE_SOCKETEXCEPTION, "update", e);*/
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
showAlert(CommonString.MESSAGE_SOCKETEXCEPTION);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
/* final AlertMessage message = new AlertMessage(
|
||||
AutoUpdateActivity.this,
|
||||
AlertMessage.MESSAGE_EXCEPTION, "download", e);*/
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
showAlert(CommonString.MESSAGE_EXCEPTION);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@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.equals(CommonString.KEY_SUCCESS)) {
|
||||
|
||||
/* File toInstall = new File(Environment.getExternalStorageDirectory()
|
||||
+ "/download/"
|
||||
+ "app.apk");*/
|
||||
File toInstall = new File(CommonString.getApkFolder(context) + "app.apk");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Uri apkUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", toInstall);
|
||||
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
intent.setData(apkUri);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Uri apkUri = Uri.fromFile(toInstall);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
AutoUpdateActivity.this.finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Data {
|
||||
int value;
|
||||
String name;
|
||||
}
|
||||
|
||||
public void showAlert(String str) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(AutoUpdateActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
/* Intent i = new Intent(activity, StorelistActivity.class);
|
||||
activity.startActivity(i);
|
||||
activity.finish();*/
|
||||
finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
package cpm.com.gskmtorange.blurlockview;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
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 androidx.core.content.ContextCompat;
|
||||
|
||||
import cpm.com.gskmtorange.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,871 @@
|
||||
package cpm.com.gskmtorange.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 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 androidx.core.content.ContextCompat;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.blurlockview.Directions.HideType;
|
||||
import cpm.com.gskmtorange.blurlockview.Directions.ShowType;
|
||||
import cpm.com.gskmtorange.blurlockview.Eases.EaseType;
|
||||
|
||||
/**
|
||||
* 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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.blurlockview.Eases;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Weiping on 2016/3/3.
|
||||
*/
|
||||
|
||||
public class EaseInOutCubic extends CubicBezier {
|
||||
|
||||
public EaseInOutCubic() {
|
||||
init(0.645, 0.045, 0.355, 1);
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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 cpm.com.gskmtorange.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.printStackTrace();
|
||||
throw new Error("CubicBezier init error.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cpm.com.gskmtorange.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 cpm.com.gskmtorange.blurlockview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import cpm.com.gskmtorange.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 cpm.com.gskmtorange.blurlockview;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import cpm.com.gskmtorange.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 cpm.com.gskmtorange.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,196 @@
|
||||
package cpm.com.gskmtorange.blurlockview;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
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 androidx.core.content.ContextCompat;
|
||||
|
||||
import cpm.com.gskmtorange.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cpm.com.gskmtorange.comparators;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
|
||||
public class StatusCompare implements Comparator<StoreBean> {
|
||||
|
||||
@Override
|
||||
public int compare(StoreBean o1, StoreBean o2) {
|
||||
return o1.getUPLOAD_STATUS().compareTo(o2.getUPLOAD_STATUS());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package cpm.com.gskmtorange.constant;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.interfaces.DialogCallbackListener;
|
||||
|
||||
/**
|
||||
* Created by yadavendras on 13-11-2017.
|
||||
*/
|
||||
|
||||
public class CommonFunctions {
|
||||
public static boolean updateLangResources(Context context, String language) {
|
||||
String lang;
|
||||
if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ENGLISH)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ENGLISH;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_KSA)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_TURKISH)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_TURKISH;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_UAE)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_UAE_ARABIC;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_OMAN)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_OMAN;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_EGYPT)) {
|
||||
lang = CommonString.KEY_RETURN_LANGUAGE_EGYPT;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_JORDAN)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_KUWAIT)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_BAHRAIN)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_OMAN)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_QATAR)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_LIBIYA)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else if (language.equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_LEBANON)) {
|
||||
lang = CommonString.KEY_RETURE_LANGUAGE_ARABIC_KSA;
|
||||
} else {
|
||||
lang = CommonString.KEY_RETURN_LANGUAGE_DEFAULT;
|
||||
}
|
||||
Locale locale = new Locale(lang);
|
||||
Locale.setDefault(locale);
|
||||
Resources resources = context.getResources();
|
||||
Configuration configuration = resources.getConfiguration();
|
||||
configuration.locale = locale;
|
||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getCurrentTimeWithLanguage(Context context) {
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
Calendar m_cal = Calendar.getInstance();
|
||||
String cdate = formatter.format(m_cal.getTime());
|
||||
//SharedPreferences preferences = preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_KSA)
|
||||
////aDDED NEW COUNTRY FOR TIME BY JP
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_KUWAIT)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_BAHRAIN)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_OMAN)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_QATAR)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_LEBANON)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_LIBIYA)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_UAE)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_JORDAN)
|
||||
|| preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_EGYPT)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
}
|
||||
return cdate;
|
||||
}
|
||||
|
||||
private static String arabicToenglish(String number) {
|
||||
char[] chars = new char[number.length()];
|
||||
for (int i = 0; i < number.length(); i++) {
|
||||
char ch = number.charAt(i);
|
||||
if (ch >= 0x0660 && ch <= 0x0669)
|
||||
ch -= 0x0660 - '0';
|
||||
else if (ch >= 0x06f0 && ch <= 0x06F9)
|
||||
ch -= 0x06f0 - '0';
|
||||
chars[i] = ch;
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
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
|
||||
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 void showAlertDialog(final Context context, String msg) {
|
||||
final DialogCallbackListener[] mListener = new DialogCallbackListener[1];
|
||||
try {
|
||||
// Instantiate the NoticeDialogListener so we can send events to the host
|
||||
mListener[0] = (DialogCallbackListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
Activity activity = (Activity) context;
|
||||
// The activity doesn't implement the interface, throw exception
|
||||
throw new ClassCastException(activity.getClass() + " must implement DialogCallbackListener");
|
||||
}
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||
alertDialogBuilder.setTitle(context.getResources().getString(R.string.dialog_title));
|
||||
// set dialog message
|
||||
alertDialogBuilder.setMessage(msg)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(context.getResources().getString(R.string.yes), (dialog, id) -> {
|
||||
mListener[0].onSelect(true);
|
||||
dialog.cancel();
|
||||
}).setNegativeButton(context.getResources().getString(R.string.no), (dialog, id) -> {
|
||||
// if this button is clicked, just close
|
||||
// the dialog box and do nothing
|
||||
mListener[0].onSelect(false);
|
||||
dialog.cancel();
|
||||
});
|
||||
// create alert dialog
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
// show it
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
public static void savefile(Uri sourceuri, String _path) {
|
||||
String sourceFilename = sourceuri.getPath();
|
||||
BufferedInputStream bis = null;
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(sourceFilename));
|
||||
bos = new BufferedOutputStream(new FileOutputStream(_path, false));
|
||||
byte[] buf = new byte[1024];
|
||||
bis.read(buf);
|
||||
do {
|
||||
bos.write(buf);
|
||||
} while (bis.read(buf) != -1);
|
||||
} catch (IOException e) {
|
||||
e.fillInStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bis != null) bis.close();
|
||||
if (bos != null) bos.close();
|
||||
} catch (IOException e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
package cpm.com.gskmtorange.constant
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.Patterns
|
||||
import android.widget.ImageView
|
||||
import androidx.swiperefreshlayout.widget.CircularProgressDrawable
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.sj.camera_lib_android.utils.CameraSDK.init
|
||||
import java.io.File
|
||||
|
||||
object CommonUtils {
|
||||
fun initializePDSDK(context: Context?, _userId: String?) {
|
||||
if (context != null) {
|
||||
if (_userId != null) {
|
||||
init(context, CommonString.PD_PROJECT_iD, _userId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun imgPreviewwithError(context: Context, url: String, imgView: ImageView, resId: Int) {
|
||||
val circularProgressDrawable = CircularProgressDrawable(context).apply {
|
||||
strokeWidth = 5f
|
||||
centerRadius = 30f
|
||||
start()
|
||||
}
|
||||
val options: RequestOptions =
|
||||
RequestOptions().centerCrop().placeholder(circularProgressDrawable).error(resId)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL).priority(Priority.HIGH)
|
||||
|
||||
Glide.with(context).load(url).apply(options).into(imgView)
|
||||
}
|
||||
|
||||
fun isValidUrl(url: String): Boolean {
|
||||
return Patterns.WEB_URL.matcher(url).matches()
|
||||
}
|
||||
|
||||
fun deleteSpecificImage(context: Context,filePath: String?) {
|
||||
val file = File(context.filesDir, "")
|
||||
if (!filePath.isNullOrEmpty()) {
|
||||
val file = File(filePath)
|
||||
if (file.exists()) {
|
||||
val directory = file.parent // Get the directory path
|
||||
val imageName = file.name // Get the image file name
|
||||
println("Directory: $directory")
|
||||
println("Image Name: $imageName")
|
||||
if (file.delete()) {
|
||||
println("File deleted successfully: $filePath")
|
||||
} else {
|
||||
println("Failed to delete file: $filePath")
|
||||
}
|
||||
} else {
|
||||
println("File does not exist: $filePath")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteImage(context: Context, filePath: String) {
|
||||
val uri = Uri.parse(filePath)
|
||||
val contentResolver = context.contentResolver
|
||||
val deleted = contentResolver.delete(uri, null, null)
|
||||
if (deleted > 0) {
|
||||
println("File deleted successfully: $filePath")
|
||||
} else {
|
||||
println("Failed to delete file: $filePath")
|
||||
}
|
||||
}
|
||||
}
|
||||
+1065
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,802 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.Spanned;
|
||||
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.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.AddittionalGetterSetter;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.AdditionalQuestiongetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.AuditDataGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityStockFacingGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.T2PGetterSetter;
|
||||
|
||||
public class AuditActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
List<Integer> checkHeaderArray = new ArrayList<>();
|
||||
boolean checkflag = true;
|
||||
private SharedPreferences preferences;
|
||||
String categoryName, categoryId, Error_Message = "", pathforcheck = "", _path = "", str, img_str = "", img_str2 = "";
|
||||
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, store_flag_str, country_id = "";
|
||||
GSKOrangeDB db;
|
||||
ArrayList<AuditDataGetterSetter> question_list = new ArrayList<>(), childListData;
|
||||
HashMap<AuditDataGetterSetter, ArrayList<AuditDataGetterSetter>> hashMapAnsListChildData;
|
||||
AnswerAdapter questionAdapter;
|
||||
RecyclerView recyclerView;
|
||||
Uri outputFileUri;
|
||||
String gallery_package = "";
|
||||
int child_position = -1;
|
||||
String error_msg = "";
|
||||
Toolbar toolbar;
|
||||
LinearLayout no_data_lay;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_audit);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
no_data_lay = (LinearLayout) findViewById(R.id.no_data_lay);
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
|
||||
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
|
||||
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
|
||||
store_flag_str = preferences.getString(CommonString.KEY_STORE_FLAG, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
|
||||
toolbar.setTitle(getResources().getString(R.string.audit));
|
||||
str = CommonString.getImagesFolder(context);
|
||||
recyclerView = (RecyclerView) findViewById(R.id.list);
|
||||
|
||||
db = new GSKOrangeDB(this);
|
||||
db.open();
|
||||
|
||||
//Intent data
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
|
||||
//Header
|
||||
question_list = db.getAfterSaveAuditQuestionAnswerData(store_id, categoryId);
|
||||
if (question_list.size() == 0) {
|
||||
question_list = getAuditQnsRemoved();
|
||||
}
|
||||
|
||||
hashMapAnsListChildData = new HashMap<>();
|
||||
childListData = new ArrayList<>();
|
||||
|
||||
if (question_list.size() > 0) {
|
||||
String select = getString(R.string.title_activity_select_dropdown);
|
||||
// Adding child data
|
||||
for (int i = 0; i < question_list.size(); i++) {
|
||||
childListData = db.getAuditAnswerData(question_list.get(i).getQUESTION_ID(), categoryId, storeType_id, select);
|
||||
ArrayList<AuditDataGetterSetter> answerList = new ArrayList<>();
|
||||
for (int j = 0; j < childListData.size(); j++) {
|
||||
answerList.add(childListData.get(j));
|
||||
}
|
||||
|
||||
hashMapAnsListChildData.put(question_list.get(i), answerList); // Header, Child data
|
||||
}
|
||||
|
||||
questionAdapter = new AnswerAdapter(question_list, hashMapAnsListChildData);
|
||||
recyclerView.setAdapter(questionAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
} else {
|
||||
no_data_lay.setVisibility(View.VISIBLE);
|
||||
fab.hide();//setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener()
|
||||
{
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
|
||||
{
|
||||
if (dy > 0 && fab.isShown())
|
||||
{
|
||||
fab.hide();
|
||||
}
|
||||
|
||||
if (dy < 0 && !fab.isShown())
|
||||
{
|
||||
fab.show();
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState)
|
||||
{
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE)
|
||||
{
|
||||
fab.show();
|
||||
}
|
||||
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
}*/
|
||||
});
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (question_list.size() > 0) {
|
||||
recyclerView.clearFocus();
|
||||
if (validateData(question_list)) {
|
||||
db.saveAuditQuestionAnswerData(question_list, store_id, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
} else {
|
||||
questionAdapter.notifyDataSetChanged();
|
||||
Snackbar.make(recyclerView, error_msg, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(recyclerView, getString(R.string.NodataAvailable), Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ArrayList<AuditDataGetterSetter> getAuditQnsRemoved() {
|
||||
|
||||
boolean t2p_flag = false;
|
||||
|
||||
boolean flag_t2p_mapping;
|
||||
if (store_flag_str.equalsIgnoreCase(CommonString.FROM_DEVIATION)) {
|
||||
flag_t2p_mapping = db.isMappingT2PData(store_id, categoryId, CommonString.TABLE_MAPPING_T2P_ADHOC);
|
||||
} else {
|
||||
flag_t2p_mapping = db.isMappingT2PData(store_id, categoryId, CommonString.TABLE_MAPPING_T2P);
|
||||
}
|
||||
|
||||
if (flag_t2p_mapping) {
|
||||
if (db.isFilledT2P(store_id, categoryId)) {
|
||||
ArrayList<T2PGetterSetter> t2PList = db.getT2pComplianceData(store_id, categoryId);
|
||||
|
||||
for (int i = 0; i < t2PList.size(); i++) {
|
||||
if (t2PList.get(i).getPresent() == 1) {
|
||||
t2p_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!t2p_flag) {
|
||||
if (db.additionalVisibilitydata(store_id, categoryId)) {
|
||||
ArrayList<AddittionalGetterSetter> additionalList = db.getAdditionalMainStock(store_id, categoryId);
|
||||
for (int i = 0; i < additionalList.size(); i++) {
|
||||
if (additionalList.get(i).getBtn_toogle().equals("1")) {
|
||||
t2p_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<AuditDataGetterSetter> question_list = db.getAuditCategoryWise(categoryId, storeType_id);
|
||||
Iterator<AuditDataGetterSetter> iterator = question_list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
AuditDataGetterSetter item = iterator.next(); // must be called before you can call iterator.remove()
|
||||
// Check condition
|
||||
if (!item.getKEYACCOUNT_ID().equals("0") && !item.getKEYACCOUNT_ID().equals(keyAccount_id)) {
|
||||
iterator.remove();
|
||||
} else if (!item.getCHECK_TYPE().equals("NA") && item.getCHECK_TYPE().equals("T2P")) {
|
||||
|
||||
if (!t2p_flag) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return question_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getResources().getString(R.string.audit));
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (question_list.size() > 0) {
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(AuditActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (question_list.size() > 0) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(AuditActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class DecimalDigitsInputFilter implements InputFilter {
|
||||
|
||||
Pattern mPattern;
|
||||
|
||||
public DecimalDigitsInputFilter(int digitsBeforeZero, int digitsAfterZero) {
|
||||
mPattern = Pattern.compile("[0-9]{0," + (digitsBeforeZero - 1) + "}+((\\.[0-9]{0," + (digitsAfterZero - 1) + "})?)||(\\.)?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
||||
|
||||
Matcher matcher = mPattern.matcher(dest);
|
||||
if (!matcher.matches())
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AnswerAdapter extends RecyclerView.Adapter<AnswerAdapter.ViewHolder> {
|
||||
ArrayList<AuditDataGetterSetter> questionList;
|
||||
HashMap<AuditDataGetterSetter, ArrayList<AuditDataGetterSetter>> answerHashMap;
|
||||
|
||||
public AnswerAdapter(ArrayList<AuditDataGetterSetter> questionList,
|
||||
HashMap<AuditDataGetterSetter, ArrayList<AuditDataGetterSetter>> answerHashMap) {
|
||||
this.questionList = questionList;
|
||||
this.answerHashMap = answerHashMap;
|
||||
}
|
||||
|
||||
public AnswerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.audit_question_list_item, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
public void onBindViewHolder(final AnswerAdapter.ViewHolder holder, @SuppressLint("RecyclerView") final int position) {
|
||||
holder.data = questionList.get(position);
|
||||
holder.txt_question.setText(holder.data.getQUESTION());
|
||||
holder.txt_question.setId(position);
|
||||
|
||||
// Log.e("mandate_data",holder.data.getCAMERA_ALLOW()+","+holder.data.getCAMERA_MANDATORY() + "," + holder.data.getQUESTION_ID());
|
||||
|
||||
ArrayList<AuditDataGetterSetter> ans_list = answerHashMap.get(holder.data);
|
||||
|
||||
if (holder.data.getANSWER_TYPE().equalsIgnoreCase("Dropdown")) {
|
||||
holder.sp_auditAnswer.setVisibility(View.VISIBLE);
|
||||
holder.sp_auditAnswer.setId(position);
|
||||
holder.edt_answer.setVisibility(View.GONE);
|
||||
holder.edt_answer.setId(position);
|
||||
}
|
||||
else if (holder.data.getANSWER_TYPE().equalsIgnoreCase("TEXTBOX")) {
|
||||
int maxLength = Integer.parseInt(holder.data.getMaxlength());
|
||||
InputFilter[] fArray = new InputFilter[1];
|
||||
fArray[0] = new InputFilter.LengthFilter(maxLength);
|
||||
holder.edt_answer.setFilters(fArray);
|
||||
holder.edt_answer.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
holder.edt_answer.setVisibility(View.VISIBLE);
|
||||
holder.edt_answer.setId(position);
|
||||
if (country_id.equals("4")) {
|
||||
holder.edt_answer.setHint(R.string.pls_fill_stock_count);
|
||||
holder.edt_answer.setId(position);
|
||||
}
|
||||
|
||||
holder.sp_auditAnswer.setVisibility(View.GONE);
|
||||
holder.sp_auditAnswer.setId(position);
|
||||
|
||||
} else if (holder.data.getANSWER_TYPE().equalsIgnoreCase("DECIMAL")) {
|
||||
int maxLength = Integer.parseInt(holder.data.getMaxlength());
|
||||
holder.edt_answer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
holder.edt_answer.setFilters(new InputFilter[]{new DecimalDigitsInputFilter(maxLength, 2)});
|
||||
|
||||
holder.edt_answer.setVisibility(View.VISIBLE);
|
||||
holder.edt_answer.setId(position);
|
||||
|
||||
if (country_id.equals("4")) {
|
||||
holder.edt_answer.setHint(R.string.pls_fill_stock_count);
|
||||
}
|
||||
|
||||
holder.sp_auditAnswer.setVisibility(View.GONE);
|
||||
holder.sp_auditAnswer.setId(position);
|
||||
|
||||
} else if (holder.data.getANSWER_TYPE().equalsIgnoreCase("NUMBER")) {
|
||||
int maxLength = Integer.parseInt(holder.data.getMaxlength());
|
||||
InputFilter[] fArray = new InputFilter[1];
|
||||
fArray[0] = new InputFilter.LengthFilter(maxLength);
|
||||
holder.edt_answer.setFilters(fArray);
|
||||
holder.edt_answer.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
holder.edt_answer.setVisibility(View.VISIBLE);
|
||||
holder.edt_answer.setId(position);
|
||||
|
||||
if (country_id.equals("4")) {
|
||||
holder.edt_answer.setHint(R.string.pls_fill_stock_count);
|
||||
}
|
||||
|
||||
holder.sp_auditAnswer.setVisibility(View.GONE);
|
||||
holder.sp_auditAnswer.setId(position);
|
||||
}
|
||||
|
||||
if (holder.data.getCAMERA_ALLOW().equals("1")) {
|
||||
holder.parent_cam_layout.setVisibility(View.VISIBLE);
|
||||
holder.parent_cam_layout.setId(position);
|
||||
} else {
|
||||
holder.parent_cam_layout.setVisibility(View.GONE);
|
||||
holder.parent_cam_layout.setId(position);
|
||||
}
|
||||
//text
|
||||
if (holder.data.getREMARK_ALLOW().equals("1")) {
|
||||
holder.edt_text.setVisibility(View.VISIBLE);
|
||||
holder.edt_text.setId(position);
|
||||
|
||||
holder.txt_leval.setVisibility(View.VISIBLE);
|
||||
holder.txt_leval.setText(holder.data.getREMARK_LEVEL());
|
||||
holder.txt_leval.setId(position);
|
||||
} else {
|
||||
holder.edt_text.setVisibility(View.GONE);
|
||||
holder.edt_text.setId(position);
|
||||
holder.txt_leval.setVisibility(View.GONE);
|
||||
holder.txt_leval.setId(position);
|
||||
}
|
||||
|
||||
holder.sp_auditAnswer.setAdapter(new AnswerSpinnerAdapter(AuditActivity.this, R.layout.custom_spinner_item, ans_list));
|
||||
|
||||
final ArrayList<AuditDataGetterSetter> finalAns_list = ans_list;
|
||||
holder.sp_auditAnswer.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
AuditDataGetterSetter ans = finalAns_list.get(position);
|
||||
holder.data.setANSWER_ID(ans.getANSWER_ID());
|
||||
holder.data.setANSWER(ans.getANSWER());
|
||||
holder.data.setCAMERA_ALLOW(ans.getCAMERA_ALLOW());
|
||||
holder.data.setREMARK_ALLOW(ans.getREMARK_ALLOW());
|
||||
holder.data.setREMARK_LEVEL(ans.getREMARK_LEVEL());
|
||||
holder.data.setCAMERA_MANDATORY(ans.getCAMERA_MANDATORY());
|
||||
|
||||
Log.e("mandate_data",holder.data.getCAMERA_ALLOW() + ","+ holder.data.getCAMERA_MANDATORY());
|
||||
|
||||
//text
|
||||
if (holder.data.getREMARK_ALLOW().equals("1")) {
|
||||
holder.edt_text.setVisibility(View.VISIBLE);
|
||||
holder.txt_leval.setVisibility(View.VISIBLE);
|
||||
holder.txt_leval.setText(holder.data.getREMARK_LEVEL());
|
||||
} else {
|
||||
holder.edt_text.setVisibility(View.GONE);
|
||||
holder.txt_leval.setVisibility(View.GONE);
|
||||
holder.data.setTXT_REMARK("");
|
||||
}
|
||||
|
||||
if (holder.data.getCAMERA_ALLOW().equals("1")) {
|
||||
holder.parent_cam_layout.setVisibility(View.VISIBLE);
|
||||
if (ans.getNO_OF_CAMERA().equals("2")) {
|
||||
holder.img_cam2.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.img_cam2.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
holder.parent_cam_layout.setVisibility(View.GONE);
|
||||
if (holder.data.getCAM_IMAGE() != null && holder.data.getCAM_IMAGE().equals("")) {
|
||||
if (new File(str + holder.data.getCAM_IMAGE()).exists()) {
|
||||
new File(str + holder.data.getCAM_IMAGE()).delete();
|
||||
}
|
||||
}
|
||||
if (holder.data.getCAM_IMAGE2() != null && holder.data.getCAM_IMAGE2().equals("")) {
|
||||
if (new File(str + holder.data.getCAM_IMAGE2()).exists()) {
|
||||
new File(str + holder.data.getCAM_IMAGE2()).delete();
|
||||
}
|
||||
}
|
||||
holder.data.setCAM_IMAGE("");
|
||||
holder.data.setCAM_IMAGE2("");
|
||||
holder.img_cam.setBackgroundResource(R.mipmap.camera_orange);
|
||||
holder.img_cam2.setBackgroundResource(R.mipmap.camera_orange);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.img_cam.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
pathforcheck = store_id + "AuditAnsPic" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context)+ pathforcheck;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
child_position = position;
|
||||
startCameraActivity(0);
|
||||
}
|
||||
});
|
||||
|
||||
holder.img_cam2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
pathforcheck = store_id + "AuditAnsPic2" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context)+ pathforcheck;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
child_position = position;
|
||||
startCameraActivity(1);
|
||||
}
|
||||
});
|
||||
|
||||
holder.edt_answer.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus) {
|
||||
if (holder.data.getANSWER_TYPE().equalsIgnoreCase("NUMBER")) {
|
||||
holder.data.setANSWER_ID("0");
|
||||
holder.data.setANSWER(((EditText) v).getText().toString().replaceFirst("^0+.(?!$)", ""));
|
||||
} else {
|
||||
holder.data.setANSWER_ID("0");
|
||||
holder.data.setANSWER(((EditText) v).getText().toString().replaceAll("[&^<>{}'$]", ""));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//set remark
|
||||
holder.edt_text.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus) {
|
||||
holder.data.setTXT_REMARK(((EditText) v).getText().toString().replaceAll("[&^<>{}'$]", ""));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < ans_list.size(); i++) {
|
||||
if (holder.data.getANSWER_TYPE().equalsIgnoreCase("Dropdown")
|
||||
&& ans_list.get(i).getANSWER_ID().equals(holder.data.getANSWER_ID())) {
|
||||
holder.sp_auditAnswer.setSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.data.getANSWER_TYPE().equalsIgnoreCase("TEXTBOX")
|
||||
|| holder.data.getANSWER_TYPE().equalsIgnoreCase("DECIMAL")
|
||||
|| holder.data.getANSWER_TYPE().equalsIgnoreCase("NUMBER")) {
|
||||
holder.edt_answer.setText(holder.data.getANSWER());
|
||||
holder.edt_answer.setId(position);
|
||||
}
|
||||
|
||||
//set text
|
||||
if (holder.data.getREMARK_ALLOW().equalsIgnoreCase("1")) {
|
||||
holder.edt_text.setText(holder.data.getTXT_REMARK());
|
||||
holder.edt_text.setId(position);
|
||||
}
|
||||
|
||||
if (!img_str.equals("")) {
|
||||
if (child_position == position) {
|
||||
holder.data.setCAM_IMAGE(img_str);
|
||||
img_str = "";
|
||||
child_position = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!img_str2.equals("")) {
|
||||
if (child_position == position) {
|
||||
holder.data.setCAM_IMAGE2(img_str2);
|
||||
img_str2 = "";
|
||||
child_position = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.data.getCAM_IMAGE().equals("")) {
|
||||
holder.img_cam.setBackgroundResource(R.mipmap.camera_orange);
|
||||
holder.img_cam.setId(position);
|
||||
|
||||
} else {
|
||||
holder.img_cam.setBackgroundResource(R.mipmap.camera_green);
|
||||
holder.img_cam.setId(position);
|
||||
}
|
||||
|
||||
if (holder.data.getCAM_IMAGE2().equals("")) {
|
||||
holder.img_cam2.setBackgroundResource(R.mipmap.camera_orange);
|
||||
holder.img_cam2.setId(position);
|
||||
} else {
|
||||
holder.img_cam2.setBackgroundResource(R.mipmap.camera_green);
|
||||
holder.img_cam2.setId(position);
|
||||
}
|
||||
|
||||
|
||||
if (!checkflag) {
|
||||
if (checkHeaderArray.contains(position)) {
|
||||
holder.card_view.setBackgroundColor(getResources().getColor(R.color.red));
|
||||
holder.card_view.setId(position);
|
||||
} else {
|
||||
holder.card_view.setBackgroundColor(getResources().getColor(R.color.white));
|
||||
holder.card_view.setId(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return questionList.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final TextView txt_question, txt_leval;
|
||||
public final Spinner sp_auditAnswer;
|
||||
public final EditText edt_answer, edt_text;
|
||||
public final ImageView img_cam, img_cam2;
|
||||
public final RelativeLayout parent_cam_layout;
|
||||
CardView card_view;
|
||||
AuditDataGetterSetter data;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
mView = view;
|
||||
|
||||
txt_leval = (TextView) view.findViewById(R.id.txt_leval);
|
||||
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_text = (EditText) view.findViewById(R.id.edt_text);
|
||||
edt_answer = (EditText) view.findViewById(R.id.edt_answer);
|
||||
img_cam = (ImageView) view.findViewById(R.id.img_cam);
|
||||
img_cam2 = (ImageView) view.findViewById(R.id.img_cam2);
|
||||
parent_cam_layout = (RelativeLayout) view.findViewById(R.id.parent_cam_layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class AnswerSpinnerAdapter extends ArrayAdapter<AuditDataGetterSetter> {
|
||||
List<AuditDataGetterSetter> list;
|
||||
Context context;
|
||||
int resourceId;
|
||||
|
||||
public AnswerSpinnerAdapter(Context context, int resourceId, ArrayList<AuditDataGetterSetter> list) {
|
||||
super(context, resourceId, list);
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
AuditDataGetterSetter cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.tv_text);
|
||||
txt_spinner.setText(list.get(position).getANSWER());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
|
||||
AuditDataGetterSetter cm = list.get(position);
|
||||
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.tv_text);
|
||||
txt_spinner.setText(cm.getANSWER());
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
boolean validateData(ArrayList<AuditDataGetterSetter> data) {
|
||||
//boolean flag = true;
|
||||
checkHeaderArray.clear();
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (data.get(i).getANSWER_TYPE().equalsIgnoreCase("TEXTBOX") && data.get(i).getANSWER().equalsIgnoreCase("")
|
||||
|| data.get(i).getANSWER_TYPE().equalsIgnoreCase("DECIMAL") && data.get(i).getANSWER().equalsIgnoreCase("")
|
||||
|| data.get(i).getANSWER_TYPE().equalsIgnoreCase("NUMBER") && data.get(i).getANSWER().equalsIgnoreCase("")) {
|
||||
error_msg = getString(R.string.pls_answer_all_qns);
|
||||
checkflag = false;
|
||||
} else if (data.get(i).getANSWER_TYPE().equalsIgnoreCase("DROPDOWN") && data.get(i).getANSWER_ID().equalsIgnoreCase("0")) {
|
||||
error_msg = getString(R.string.pls_answer_all_qns);
|
||||
checkflag = false;
|
||||
} else if (data.get(i).getCAMERA_ALLOW().equals("1") && data.get(i).getCAMERA_MANDATORY().equals("1") && data.get(i).getCAM_IMAGE().equals("")) {
|
||||
error_msg = getString(R.string.click_image);
|
||||
checkflag = false;
|
||||
} else if (data.get(i).getCAMERA_ALLOW().equals("1") && data.get(i).getCAMERA_MANDATORY().equals("1")
|
||||
&& data.get(i).getNO_OF_CAMERA().equals("2") && data.get(i).getCAM_IMAGE2().equals("")) {
|
||||
error_msg = getString(R.string.click_image);
|
||||
checkflag = false;
|
||||
//text
|
||||
} else if (data.get(i).getREMARK_ALLOW().equals("1") && data.get(i).getTXT_REMARK().equals("")) {
|
||||
error_msg = getString(R.string.pleaseenterRemarks);
|
||||
checkflag = false;
|
||||
} else {
|
||||
checkflag = true;
|
||||
}
|
||||
|
||||
if (checkflag == false) {
|
||||
if (!checkHeaderArray.contains(i)) {
|
||||
checkHeaderArray.add(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return checkflag;
|
||||
}
|
||||
|
||||
protected void startCameraActivity(int code) {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, code);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, code);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@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.equals("")) {
|
||||
if (new File(str + pathforcheck).exists()) {
|
||||
if (requestCode == 0) {
|
||||
img_str = pathforcheck;
|
||||
} else {
|
||||
img_str2 = pathforcheck;
|
||||
}
|
||||
|
||||
pathforcheck = "";
|
||||
questionAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,661 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.CategoryImagesAllowed;
|
||||
|
||||
public class CategoryPicture extends AppCompatActivity {
|
||||
private Context context;
|
||||
String _pathforcheck1, _pathforcheck2, _pathforcheck3, _pathforcheck4, Camerapath1, Camerapath2, _path, CaMpath, str, msg, categoryName, categoryId;
|
||||
ImageView im1, im2, im3, im4;
|
||||
ListView listview;
|
||||
String store_id, date, intime, img_str1 = "", img_str2 = "", img_str3 = "", img_str4 = "", togglevalue = "1", CATEGORY_ID, camera_allow, store_type_id, class_id, key_account_id, country_id, store_flag_str;
|
||||
private SharedPreferences preferences;
|
||||
Uri outputFileUri;
|
||||
String gallery_package = "";
|
||||
GSKOrangeDB db;
|
||||
ArrayList<CategoryPictureGetterSetter> adddata = new ArrayList<CategoryPictureGetterSetter>();
|
||||
int Adapterposition;
|
||||
ArrayList<CategoryPictureGetterSetter> listdat = new ArrayList<CategoryPictureGetterSetter>();
|
||||
CategoryAdapter adapteradditional;
|
||||
Toolbar toolbar;
|
||||
|
||||
ArrayList<CategoryImagesAllowed> categoryImagesAllowed = new ArrayList<>();
|
||||
|
||||
boolean editFlag = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_category_picture);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
context = this;
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
camera_allow = preferences.getString(CommonString.KEY_CAMERA_ALLOW, "");
|
||||
store_type_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
|
||||
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
|
||||
key_account_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
|
||||
store_flag_str = preferences.getString(CommonString.KEY_STORE_FLAG, null);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
|
||||
str = CommonString.getImagesFolder(context);
|
||||
db = new GSKOrangeDB(CategoryPicture.this);
|
||||
db.open();
|
||||
im1 = (ImageView) findViewById(R.id.image1);
|
||||
im2 = (ImageView) findViewById(R.id.image2);
|
||||
im3 = (ImageView) findViewById(R.id.image3);
|
||||
im4 = (ImageView) findViewById(R.id.image4);
|
||||
listview = (ListView) findViewById(R.id.listview);
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
|
||||
adddata = db.getCategoryPictureData(store_id, categoryId);
|
||||
categoryImagesAllowed = db.getCategoryPictureAllowedData(categoryId);
|
||||
if (categoryImagesAllowed.size() > 0) {
|
||||
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam1(), im1);
|
||||
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam2(), im2);
|
||||
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam2(), im3);
|
||||
setCamAllowImage(categoryImagesAllowed.get(0).isImg_cam3(), im4);
|
||||
}
|
||||
|
||||
if (adddata.size() != 0) {
|
||||
|
||||
String key_id = adddata.get(0).getKEY_ID();
|
||||
|
||||
listdat = db.getCategoryPictureListData(store_id, categoryId, key_id);
|
||||
|
||||
String image1 = adddata.get(0).getCategoryImage1();
|
||||
String image2 = adddata.get(0).getCategoryImage2();
|
||||
String image3 = adddata.get(0).getCategoryImage3();
|
||||
String image4 = adddata.get(0).getCategoryImage4();
|
||||
|
||||
if (image1 != null && !image1.equals("")) {
|
||||
im1.setImageResource(R.mipmap.camera_green);
|
||||
img_str1 = image1;
|
||||
}
|
||||
|
||||
if (image2 != null && !image2.equals("")) {
|
||||
im2.setImageResource(R.mipmap.camera_green);
|
||||
img_str2 = image2;
|
||||
}
|
||||
|
||||
if (image3 != null && !image3.equals("")) {
|
||||
im3.setImageResource(R.mipmap.camera_green);
|
||||
img_str3 = image3;
|
||||
}
|
||||
|
||||
if (image4 != null && !image4.equals("")) {
|
||||
im4.setImageResource(R.mipmap.camera_green);
|
||||
img_str4 = image4;
|
||||
}
|
||||
|
||||
} else {
|
||||
db.open();
|
||||
if (country_id.equals("7") || country_id.equals("8") || country_id.equals("11") || country_id.equals("17")) {
|
||||
listdat = db.getCategoryPicturedata(date, categoryId, null, null, null, store_id, CommonString.TABLE_MAPPING_STOCK_STOREWISE);
|
||||
} else if (store_flag_str.equalsIgnoreCase(CommonString.FROM_DEVIATION)) {
|
||||
listdat = db.getCategoryPicturedata(date, categoryId, key_account_id, store_type_id, class_id, store_id, CommonString.TABLE_MAPPING_STOCK_ADHOC);
|
||||
} else {
|
||||
listdat = db.getCategoryPicturedata(date, categoryId, key_account_id, store_type_id, class_id, store_id, CommonString.TABLE_MAPPING_STOCK);
|
||||
}
|
||||
}
|
||||
adapteradditional = new CategoryPicture.CategoryAdapter(CategoryPicture.this, listdat);
|
||||
listview.setAdapter(adapteradditional);
|
||||
|
||||
|
||||
fab.setOnClickListener(view -> {
|
||||
final CategoryPictureGetterSetter CP = new CategoryPictureGetterSetter();
|
||||
CP.setCategoryImage1(img_str1);
|
||||
CP.setCategoryImage2(img_str2);
|
||||
CP.setCategoryImage3(img_str3);
|
||||
CP.setCategoryImage4(img_str4);
|
||||
CP.setStore_ID(store_id);
|
||||
CP.setCamera_allow(camera_allow);
|
||||
|
||||
if (validateData(CP, listdat)) {
|
||||
db.open();
|
||||
db.InsertCategoryPictureData(CP, listdat, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
/* AlertDialog.Builder builder = new AlertDialog.Builder(CategoryPicture.this);
|
||||
builder.setMessage(getResources().getString(R.string.check_save_message))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
db.open();
|
||||
|
||||
db.InsertCategoryPictureData(CP, listdat, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
|
||||
|
||||
} else {
|
||||
Snackbar.make(view, R.string.title_activity_take_image, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
im1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
|
||||
_pathforcheck1 = store_id + "CategoryPicture1" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck1;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
im2.setOnClickListener(view -> {
|
||||
|
||||
_pathforcheck2 = store_id + "CategoryPicture2" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck2;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
});
|
||||
im3.setOnClickListener(view -> {
|
||||
|
||||
_pathforcheck3 = store_id + "CategoryPicture3" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck3;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
|
||||
|
||||
});
|
||||
im4.setOnClickListener(view -> {
|
||||
|
||||
_pathforcheck4 = store_id + "CategoryPicture4" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck4;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private static String arabicToenglish(String number) {
|
||||
char[] chars = new char[number.length()];
|
||||
for (int i = 0; i < number.length(); i++) {
|
||||
char ch = number.charAt(i);
|
||||
if (ch >= 0x0660 && ch <= 0x0669)
|
||||
ch -= 0x0660 - '0';
|
||||
else if (ch >= 0x06f0 && ch <= 0x06F9)
|
||||
ch -= 0x06f0 - '0';
|
||||
chars[i] = ch;
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
public String getCurrentTimeNotUsed() {
|
||||
Calendar m_cal = Calendar.getInstance();
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss:mmm");
|
||||
String cdate = formatter.format(m_cal.getTime());
|
||||
|
||||
if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_KSA)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
} else if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_UAE)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
} else if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_JORDAN)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
}
|
||||
return cdate;
|
||||
}
|
||||
|
||||
|
||||
protected void startCameraActivity() {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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:
|
||||
|
||||
editFlag = true;
|
||||
|
||||
if (_pathforcheck1 != null && !_pathforcheck1.equals("")) {
|
||||
if (new File(str + _pathforcheck1).exists()) {
|
||||
|
||||
im1.setImageResource(R.mipmap.camera_green);
|
||||
|
||||
img_str1 = _pathforcheck1;
|
||||
_pathforcheck1 = "";
|
||||
}
|
||||
}
|
||||
if (_pathforcheck2 != null && !_pathforcheck2.equals("")) {
|
||||
if (new File(str + _pathforcheck2).exists()) {
|
||||
|
||||
im2.setImageResource(R.mipmap.camera_green);
|
||||
|
||||
img_str2 = _pathforcheck2;
|
||||
_pathforcheck2 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (_pathforcheck3 != null && !_pathforcheck3.equals("")) {
|
||||
if (new File(str + _pathforcheck3).exists()) {
|
||||
|
||||
im3.setImageResource(R.mipmap.camera_green);
|
||||
|
||||
img_str3 = _pathforcheck3;
|
||||
_pathforcheck3 = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (_pathforcheck4 != null && !_pathforcheck4.equals("")) {
|
||||
if (new File(str + _pathforcheck4).exists()) {
|
||||
|
||||
im4.setImageResource(R.mipmap.camera_green);
|
||||
|
||||
img_str4 = _pathforcheck4;
|
||||
_pathforcheck4 = "";
|
||||
}
|
||||
}
|
||||
if (Camerapath1 != null && !Camerapath1.equals("")) {
|
||||
if (new File(str + Camerapath1).exists()) {
|
||||
|
||||
|
||||
listdat.get(Adapterposition).setSubCategoryCamera1(Camerapath1);
|
||||
|
||||
Camerapath1 = "";
|
||||
listview.invalidateViews();
|
||||
}
|
||||
}
|
||||
|
||||
if (Camerapath2 != null && !Camerapath2.equals("")) {
|
||||
if (new File(str + Camerapath2).exists()) {
|
||||
|
||||
listdat.get(Adapterposition).setSubCategoryCamera2(Camerapath2);
|
||||
|
||||
Camerapath2 = "";
|
||||
listview.invalidateViews();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
|
||||
public class CategoryAdapter extends BaseAdapter {
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
private Context mcontext;
|
||||
private ArrayList<CategoryPictureGetterSetter> list;
|
||||
|
||||
public CategoryAdapter(Activity activity, ArrayList<CategoryPictureGetterSetter> list1) {
|
||||
|
||||
mInflater = LayoutInflater.from(getBaseContext());
|
||||
mcontext = activity;
|
||||
list = list1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position1) {
|
||||
|
||||
return position1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position1) {
|
||||
|
||||
return position1;
|
||||
}
|
||||
|
||||
class ViewHolder {
|
||||
TextView brand, qty_bought, display;
|
||||
Button camera1, camera2, delete;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position1, View convertView, ViewGroup parent) {
|
||||
|
||||
final CategoryPicture.CategoryAdapter.ViewHolder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
|
||||
convertView = mInflater
|
||||
.inflate(R.layout.contentcatgoryadpterlayout, null);
|
||||
holder = new CategoryPicture.CategoryAdapter.ViewHolder();
|
||||
holder.brand = (TextView) convertView.findViewById(R.id.textviewname);
|
||||
holder.camera1 = (Button) convertView.findViewById(R.id.button3);
|
||||
holder.camera2 = (Button) convertView.findViewById(R.id.cameranew);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (CategoryPicture.CategoryAdapter.ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.camera1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
//Camerapath1 = store_id + "CategoryPicture" + list.get(position1).getSUB_CATEGORY_ID()+ date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
/* if(CommonFunctions.getCurrentTimeWithLanguage(mcontext).replace(":", "").contains("????")){
|
||||
Camerapath1 = store_id + "CategoryPicture" + list.get(position1).getSUB_CATEGORY_ID()+ date.replace("/", "") + new Random().nextInt(999999) + ".jpg";
|
||||
}
|
||||
else{
|
||||
Camerapath1 = store_id + "CategoryPicture" + list.get(position1).getSUB_CATEGORY_ID()+ date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(mcontext).replace(":", "") + ".jpg";
|
||||
}*/
|
||||
|
||||
Camerapath1 = store_id + "CategoryPicture" + list.get(position1).getSUB_CATEGORY_ID() + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(mcontext).replace(":", "") + ".jpg";
|
||||
Adapterposition = position1;
|
||||
// Log.e("Camimage",Camerapath1);
|
||||
_path = CommonString.getImagesFolder(context) + Camerapath1;
|
||||
// intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(mcontext);
|
||||
startCameraActivity();
|
||||
listview.invalidateViews();
|
||||
}
|
||||
});
|
||||
|
||||
holder.camera2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (listdat.get(position1).getImage_allow().equals("1") && listdat.get(position1).getSubCategoryCamera1().equalsIgnoreCase("")) {
|
||||
Snackbar.make(listview, R.string.first_click_compulsory_image, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
// Camerapath2 = store_id + "CategoryPicture" + list.get(position1).getSUB_CATEGORY_ID().toString() + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
Camerapath2 = store_id + "CategoryPicture" + list.get(position1).getSUB_CATEGORY_ID().toString() + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(mcontext).replace(":", "") + ".jpg";
|
||||
Adapterposition = position1;
|
||||
_path = CommonString.getImagesFolder(context) + Camerapath2;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(mcontext);
|
||||
// intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
listview.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.brand.setText(list.get(position1).getSUB_CATEGORY().toString());
|
||||
|
||||
|
||||
if (!listdat.get(position1).getSubCategoryCamera1().equalsIgnoreCase("")) {
|
||||
|
||||
holder.camera1.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
|
||||
} else if (listdat.get(position1).getImage_allow().equals("1")) {
|
||||
holder.camera1.setBackgroundResource(R.drawable.camera_orange_star_green);
|
||||
} else {
|
||||
holder.camera1.setBackgroundResource(R.mipmap.camera_orange);
|
||||
}
|
||||
|
||||
if (!listdat.get(position1).getSubCategoryCamera2().equalsIgnoreCase("")) {
|
||||
|
||||
|
||||
holder.camera2.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
} else {
|
||||
holder.camera2.setBackgroundResource(R.mipmap.camera_orange);
|
||||
}
|
||||
|
||||
holder.brand.setId(position1);
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean validateData(CategoryPictureGetterSetter data, ArrayList<CategoryPictureGetterSetter> list) {
|
||||
boolean flag = true;
|
||||
|
||||
if (categoryImagesAllowed.size() > 0) {
|
||||
|
||||
if (categoryImagesAllowed.get(0).isImg_cam1()) {
|
||||
if (data.getCategoryImage1().equals("")) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (categoryImagesAllowed.get(0).isImg_cam2()) {
|
||||
if (data.getCategoryImage2().equals("")) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (categoryImagesAllowed.get(0).isImg_cam3()) {
|
||||
if (data.getCategoryImage3().equals("")) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (categoryImagesAllowed.get(0).isImg_cam4()) {
|
||||
if (data.getCategoryImage4().equals("")) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
if (list.get(i).getImage_allow().equals("1")) {
|
||||
|
||||
String imageu = list.get(i).getSubCategoryCamera1();
|
||||
|
||||
if (imageu.equalsIgnoreCase("")) {
|
||||
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
showDataLossAlert();
|
||||
}
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
void showDataLossAlert() {
|
||||
if (editFlag) {
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(CategoryPicture.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
showDataLossAlert();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getResources().getString(R.string.title_activity_category_picture));
|
||||
}
|
||||
|
||||
public void setCamAllowImage(boolean isAllowed, ImageView img_cam) {
|
||||
|
||||
if (isAllowed) {
|
||||
img_cam.setImageResource(R.drawable.camera_orange_star_green);
|
||||
} else {
|
||||
img_cam.setImageResource(R.mipmap.camera_orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter;
|
||||
import cpm.com.gskmtorange.GetterSetter.CoverageBean;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.constant.CommonUtils;
|
||||
import cpm.com.gskmtorange.download.DownloadActivity;
|
||||
|
||||
public class CheckoutActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
private String username, visit_date, store_id, store_flag_str;
|
||||
private Data data;
|
||||
private SharedPreferences preferences = null;
|
||||
GSKOrangeDB db;
|
||||
CoverageBean coverageBean;
|
||||
String lat, lon, checkOutImagePath = "";
|
||||
Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_checkout);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
db = new GSKOrangeDB(this);
|
||||
db.open();
|
||||
context = this;
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
store_id = getIntent().getStringExtra(CommonString.KEY_STORE_ID);
|
||||
store_flag_str = getIntent().getStringExtra(CommonString.KEY_STORE_FLAG);
|
||||
checkOutImagePath = getIntent().getStringExtra(CommonString.KEY_CHECKOUT_IMAGE);
|
||||
lat = getIntent().getStringExtra(CommonString.KEY_LATITUDE);
|
||||
lon = getIntent().getStringExtra(CommonString.KEY_LONGITUDE);
|
||||
coverageBean = db.getCoverageSpecificData(visit_date, store_id);
|
||||
new BackgroundTask(CheckoutActivity.this).execute();
|
||||
}
|
||||
|
||||
private class BackgroundTask extends AsyncTask<Void, Data, String> {
|
||||
private Context context;
|
||||
|
||||
BackgroundTask(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
dialog = new Dialog(context);
|
||||
dialog.setContentView(R.layout.custom);
|
||||
dialog.setTitle(getString(R.string.title_activity_checkout));
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
//String result = "";
|
||||
data = new Data();
|
||||
data.value = 20;
|
||||
data.name = "Checked out Data Uploading";
|
||||
publishProgress(data);
|
||||
String onXML = "[STORE_CHECK_OUT_STATUS]" + "[USER_ID]" + username + "[/USER_ID]" + "[STORE_ID]" + store_id + "[/STORE_ID]" + "[LATITUDE]" + lat + "[/LATITUDE]" + "[LOGITUDE]" + lon + "[/LOGITUDE]" + "[CHECKOUT_DATE]" + visit_date + "[/CHECKOUT_DATE]" + "[CHECK_OUTTIME]" + CommonFunctions.getCurrentTimeWithLanguage(context) + "[/CHECK_OUTTIME]" + "[CHECK_INTIME]" + coverageBean.getInTime() + "[/CHECK_INTIME]" + "[CREATED_BY]" + username + "[/CREATED_BY]" + "[/STORE_CHECK_OUT_STATUS]";
|
||||
final String sos_xml = "[DATA]" + onXML + "[/DATA]";
|
||||
String service;
|
||||
if (store_flag_str.equals(CommonString.FROM_ADDITIONAL) || store_flag_str.equals(CommonString.FROM_ADDITIONAL_ADHOC)) {
|
||||
service = CommonString.METHOD_UPLOAD_CHECKOUT_STATUS_ADDITIONAL;
|
||||
} else if (store_flag_str.equals(CommonString.FROM_PHARMA)) {
|
||||
service = CommonString.METHOD_UPLOAD_CHECKOUT_STATUS_PHARMA;
|
||||
} else {
|
||||
service = CommonString.METHOD_UPLOAD_CHECKOUT_STATUS;
|
||||
}
|
||||
|
||||
SoapObject request = new SoapObject(CommonString.NAMESPACE, service);
|
||||
request.addProperty("onXML", sos_xml);
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION + service, envelope);
|
||||
|
||||
Object result = (Object) envelope.getResponse();
|
||||
|
||||
if (!result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
return service;
|
||||
}
|
||||
if (result.toString().equalsIgnoreCase(CommonString.KEY_NO_DATA)) {
|
||||
return service;
|
||||
}
|
||||
if (result.toString().equalsIgnoreCase(CommonString.KEY_FAILURE)) {
|
||||
return service;
|
||||
}
|
||||
|
||||
data.value = 100;
|
||||
data.name = "Checkout Done";
|
||||
publishProgress(data);
|
||||
|
||||
if (result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
deleteIRURl();
|
||||
db.open();
|
||||
db.updateCheckoutOuttime(store_id, CommonFunctions.getCurrentTimeWithLanguage(context), CommonString.KEY_Y, checkOutImagePath);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString(CommonString.KEY_STORE_ID, "");
|
||||
editor.putString(CommonString.KEY_STORE_NAME, "");
|
||||
editor.putString(CommonString.KEY_VISIT_DATE, "");
|
||||
editor.putString(CommonString.KEY_CAMERA_ALLOW, "");
|
||||
editor.putString(CommonString.KEY_CHECKOUT_STATUS, "");
|
||||
editor.putString(CommonString.KEY_CLASS_ID, "");
|
||||
editor.putString(CommonString.KEY_EMP_ID, "");
|
||||
editor.putString(CommonString.KEY_GEO_TAG, "");
|
||||
editor.putString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
editor.putString(CommonString.KEY_STORETYPE_ID, "");
|
||||
editor.putString(CommonString.KEY_UPLOAD_STATUS, "");
|
||||
editor.commit();
|
||||
|
||||
String table;
|
||||
switch (store_flag_str) {
|
||||
case CommonString.FROM_JCP:
|
||||
table = CommonString.KEY_JOURNEY_PLAN;
|
||||
break;
|
||||
case CommonString.FROM_ADDITIONAL:
|
||||
table = CommonString.KEY_JOURNEY_PLAN_ADDITIONAL;
|
||||
break;
|
||||
case CommonString.FROM_PHARMA:
|
||||
table = CommonString.KEY_JOURNEY_PLAN_PHARMA;
|
||||
break;
|
||||
case CommonString.FROM_ADDITIONAL_ADHOC:
|
||||
table = CommonString.KEY_ADHOC_JOURNEYPLAN_ADDITIONAL;
|
||||
break;
|
||||
default:
|
||||
table = CommonString.KEY_ADHOC_JOURNEY_PLAN;
|
||||
break;
|
||||
}
|
||||
|
||||
db.updateCheckoutStatus(store_id, CommonString.KEY_Y, table);
|
||||
|
||||
} else {
|
||||
if (result.toString().equalsIgnoreCase(CommonString.KEY_FALSE)) {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
return CommonString.KEY_SUCCESS;
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
runOnUiThread(() -> {
|
||||
// TODO Auto-generated method stub
|
||||
showAlert(CommonString.MESSAGE_EXCEPTION);
|
||||
});
|
||||
} catch (IOException e) {
|
||||
runOnUiThread(() -> showAlert(CommonString.MESSAGE_SOCKETEXCEPTION));
|
||||
} catch (Exception e) {
|
||||
runOnUiThread(() -> {
|
||||
// TODO Auto-generated method stub
|
||||
showAlert(CommonString.MESSAGE_EXCEPTION);
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onPostExecute(result);
|
||||
dialog.dismiss();
|
||||
if (result.equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
showAlert(getString(R.string.checkout_successful));
|
||||
} else if (!result.equals("")) {
|
||||
Toast.makeText(context, "Network Error Try Again", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int value;
|
||||
String name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getResources().getString(R.string.title_activity_checkout));
|
||||
}
|
||||
|
||||
private void deleteIRURl() {
|
||||
try {
|
||||
ArrayList<CategoryPictureGetterSetter> irList = db.getIrPDforUpload(store_id, visit_date);
|
||||
if (irList != null && !irList.isEmpty()) {
|
||||
for (int i = 0; i < irList.size(); i++) {
|
||||
ArrayList<ImageUri> uris = irList.get(i).getImageUris();
|
||||
if (uris != null && !uris.isEmpty()) {
|
||||
for (int k = 0; k < uris.size(); k++) {
|
||||
CommonUtils.INSTANCE.deleteSpecificImage(this,uris.get(k).getUri());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void showAlert(String str) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(CheckoutActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false).setPositiveButton("OK", (dialog, id) -> finish());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.androidbuts.multispinnerfilter.KeyPairBoolData;
|
||||
import com.androidbuts.multispinnerfilter.MultiSpinnerSearch;
|
||||
import com.androidbuts.multispinnerfilter.SpinnerListener;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.CoachingVisitGetterSetter;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.SupervisorListGetterSetter;
|
||||
|
||||
public class CoachingVisitActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, View.OnClickListener {
|
||||
private Context context;
|
||||
private GSKOrangeDB database;
|
||||
ArrayList<SupervisorListGetterSetter> supervisorList;
|
||||
private Spinner exist_spinner; //supervisor_spinner;
|
||||
private ArrayAdapter<CharSequence> exist_adapter, supervisor_adapter;
|
||||
int coaching_visit;
|
||||
LinearLayout linear_supervisor;
|
||||
ImageView img_cam;
|
||||
FloatingActionButton fab_next, fab_save;
|
||||
String emp_id;
|
||||
protected String _pathforcheck = "", _path, image_name = "", str, country_id, store_flag_str;
|
||||
String visit_date, store_id, username;
|
||||
private SharedPreferences preferences;
|
||||
String gallery_package = "";
|
||||
Uri outputFileUri;
|
||||
boolean saved_flag = false, update_flag = false;
|
||||
ArrayList<CoachingVisitGetterSetter> coachingVisitdata;
|
||||
boolean coaching_visit_camera_flag = false;
|
||||
MultiSpinnerSearch multi_spinner_supervisor;
|
||||
ArrayList<String> selectedSupervisorList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_coaching_visit);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
linear_supervisor = (LinearLayout) findViewById(R.id.linear_supervisor);
|
||||
exist_spinner = (Spinner) findViewById(R.id.spinner_coaching_visit);
|
||||
//supervisor_spinner = (Spinner) findViewById(R.id.spinner_supervisor);
|
||||
img_cam = (ImageView) findViewById(R.id.img_cam);
|
||||
|
||||
multi_spinner_supervisor = (MultiSpinnerSearch) findViewById(R.id.multi_spinner_supervisor);
|
||||
context = this;
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
toolbar.setTitle(getResources().getString(R.string.title_activity_coaching_visit));
|
||||
|
||||
str = CommonString.getImagesFolder(context);
|
||||
|
||||
store_id = getIntent().getStringExtra(CommonString.KEY_STORE_ID);
|
||||
store_flag_str = getIntent().getStringExtra(CommonString.KEY_STORE_FLAG);
|
||||
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
//store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, null);
|
||||
|
||||
fab_next = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab_save = (FloatingActionButton) findViewById(R.id.fab_save);
|
||||
|
||||
database = new GSKOrangeDB(this);
|
||||
database.open();
|
||||
|
||||
coachingVisitdata = database.getCoachingVisitData(store_id);
|
||||
|
||||
//Enable disable According to Configuration
|
||||
ArrayList<ConfigurationMasterGetterSetter> configurationData = database.getConfigurationMasterData(country_id);
|
||||
if (configurationData.size() > 0) {
|
||||
|
||||
for (int i = 0; i < configurationData.size(); i++) {
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("COACHING VISIT IMAGE") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
coaching_visit_camera_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (coaching_visit_camera_flag) {
|
||||
img_cam.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
img_cam.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
supervisorList = database.getSupervisorListData();
|
||||
|
||||
exist_adapter = new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_item);
|
||||
|
||||
String select_str = getResources().getString(R.string.select);
|
||||
|
||||
exist_adapter.add(select_str);
|
||||
exist_adapter.add(getResources().getString(R.string.yes));
|
||||
exist_adapter.add(getResources().getString(R.string.no));
|
||||
|
||||
exist_spinner.setAdapter(exist_adapter);
|
||||
|
||||
exist_adapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
exist_spinner.setOnItemSelectedListener(this);
|
||||
|
||||
if (coachingVisitdata.size() != 0) {
|
||||
update_flag = true;
|
||||
fab_save.hide();//setVisibility(View.GONE);
|
||||
fab_next.show();//setVisibility(View.VISIBLE);
|
||||
if (coachingVisitdata.get(0).isExists()) {
|
||||
exist_spinner.setSelection(1);
|
||||
} else {
|
||||
exist_spinner.setSelection(2);
|
||||
}
|
||||
exist_spinner.setEnabled(false);
|
||||
}
|
||||
|
||||
fab_next.setOnClickListener(this);
|
||||
fab_save.setOnClickListener(this);
|
||||
img_cam.setOnClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
switch (parent.getId()) {
|
||||
case R.id.spinner_coaching_visit:
|
||||
if (position != 0) {
|
||||
|
||||
if (!update_flag) {
|
||||
|
||||
fab_save.show();//setVisibility(View.VISIBLE);
|
||||
|
||||
if (position == 1) {
|
||||
|
||||
linear_supervisor.setVisibility(View.VISIBLE);
|
||||
|
||||
coaching_visit = 1;
|
||||
|
||||
/*supervisor_adapter = new ArrayAdapter<CharSequence>(this,
|
||||
android.R.layout.simple_spinner_item);
|
||||
|
||||
String select_str = getResources().getString(R.string.select_promo);
|
||||
|
||||
supervisor_adapter.add(select_str);
|
||||
|
||||
for (int i = 0; i < supervisorList.size(); i++) {
|
||||
supervisor_adapter.add(supervisorList.get(i).getSUPERVISOR().get(0));
|
||||
}
|
||||
|
||||
supervisor_spinner.setAdapter(supervisor_adapter);
|
||||
|
||||
supervisor_adapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
supervisor_spinner.setOnItemSelectedListener(this);*/
|
||||
|
||||
/**
|
||||
* Getting array of String to Bind in Spinner
|
||||
*/
|
||||
//final List<String> list = Arrays.asList(getResources().getStringArray(R.array.sports_array));
|
||||
|
||||
final List<KeyPairBoolData> listArray0 = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < supervisorList.size(); i++) {
|
||||
KeyPairBoolData h = new KeyPairBoolData();
|
||||
h.setId(i + 1);
|
||||
h.setName(supervisorList.get(i).getSUPERVISOR().get(0));
|
||||
h.setSelected(false);
|
||||
listArray0.add(h);
|
||||
}
|
||||
|
||||
multi_spinner_supervisor.setItems(listArray0, -1, new SpinnerListener() {
|
||||
|
||||
@Override
|
||||
public void onItemsSelected(List<KeyPairBoolData> items) {
|
||||
|
||||
selectedSupervisorList.clear();
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (items.get(i).isSelected()) {
|
||||
|
||||
selectedSupervisorList.add(items.get(i).getName());
|
||||
Log.i("MultiSpinner", i + " : " + items.get(i).getName() + " : " + items.get(i).isSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
coaching_visit = 0;
|
||||
selectedSupervisorList.clear();
|
||||
linear_supervisor.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
coaching_visit = -1;
|
||||
linear_supervisor.setVisibility(View.GONE);
|
||||
fab_save.hide();//setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.multi_spinner_supervisor:
|
||||
/* if(position!=0){
|
||||
emp_id = supervisorList.get(position-1).getEMP_ID().get(0);
|
||||
}
|
||||
else {
|
||||
emp_id = "";
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.img_cam:
|
||||
_pathforcheck = store_id + "CoachingVisit" + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
startCameraActivity();
|
||||
break;
|
||||
|
||||
case R.id.fab_save:
|
||||
if (coaching_visit == 1) {
|
||||
String error_msg = "";
|
||||
boolean flag = true;
|
||||
//if(emp_id.equals("")){
|
||||
if (selectedSupervisorList.size() == 0) {
|
||||
flag = false;
|
||||
error_msg = getString(R.string.title_activity_select_dropdown);
|
||||
} else if (coaching_visit_camera_flag && image_name.equals("")) {
|
||||
flag = false;
|
||||
error_msg = getString(R.string.clickimage);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
for (int i = 0; i < selectedSupervisorList.size(); i++) {
|
||||
CoachingVisitGetterSetter coachingVisitGetterSetter = new CoachingVisitGetterSetter();
|
||||
coachingVisitGetterSetter.setEmp_id(getEmp_idFromName(selectedSupervisorList.get(i)));
|
||||
coachingVisitGetterSetter.setImg_path(image_name);
|
||||
coachingVisitGetterSetter.setExists(coaching_visit == 1);
|
||||
database.insertCoachingVisitData(coachingVisitGetterSetter, store_id);
|
||||
}
|
||||
|
||||
Toast.makeText(context, getString(R.string.save_message), Toast.LENGTH_SHORT).show();
|
||||
|
||||
saved_flag = true;
|
||||
|
||||
fab_next.show();//setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Snackbar.make(linear_supervisor, error_msg, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
CoachingVisitGetterSetter coachingVisitGetterSetter = new CoachingVisitGetterSetter();
|
||||
coachingVisitGetterSetter.setEmp_id("0");
|
||||
coachingVisitGetterSetter.setImg_path(image_name);
|
||||
coachingVisitGetterSetter.setExists(coaching_visit == 1);
|
||||
|
||||
database.insertCoachingVisitData(coachingVisitGetterSetter, store_id);
|
||||
|
||||
Toast.makeText(context, getString(R.string.save_message), Toast.LENGTH_SHORT).show();
|
||||
saved_flag = true;
|
||||
fab_next.show();//setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case R.id.fab:
|
||||
|
||||
if (saved_flag || update_flag) {
|
||||
|
||||
// Intent i = new Intent(CoachingVisitActivity.this, StoreCheckoutImageActivity.class);
|
||||
Intent i = new Intent(CoachingVisitActivity.this, CoachingVisitStoreActivity.class);
|
||||
i.putExtra(CommonString.KEY_STORE_ID, store_id);
|
||||
i.putExtra(CommonString.KEY_STORE_FLAG, store_flag_str);
|
||||
startActivity(i);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
Snackbar.make(linear_supervisor, getString(R.string.please_save_data), Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String getEmp_idFromName(String name) {
|
||||
String emp_id = "0";
|
||||
|
||||
for (int i = 0; i < supervisorList.size(); i++) {
|
||||
if (supervisorList.get(i).getSUPERVISOR().get(0).equalsIgnoreCase(name)) {
|
||||
emp_id = supervisorList.get(i).getEMP_ID().get(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return emp_id;
|
||||
}
|
||||
|
||||
protected void startCameraActivity() {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
//Crashlytics.logException(new Exception(e.getCause()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingSuperCall")
|
||||
@SuppressWarnings("deprecation")
|
||||
@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(str + _pathforcheck).exists()) {
|
||||
|
||||
img_cam.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
|
||||
|
||||
image_name = _pathforcheck;
|
||||
|
||||
_pathforcheck = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
+444
@@ -0,0 +1,444 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.androidbuts.multispinnerfilter.KeyPairBoolData;
|
||||
import com.androidbuts.multispinnerfilter.MultiSpinnerSearch;
|
||||
import com.androidbuts.multispinnerfilter.SpinnerListener;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.CoachingVisitGetterSetter;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.SupervisorListGetterSetter;
|
||||
|
||||
public class CoachingVisitStoreActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, View.OnClickListener {
|
||||
|
||||
private Context context;
|
||||
private GSKOrangeDB database;
|
||||
ArrayList<SupervisorListGetterSetter> supervisorList;
|
||||
private Spinner exist_spinner; //supervisor_spinner;
|
||||
private ArrayAdapter<CharSequence> exist_adapter, supervisor_adapter;
|
||||
int coaching_visit;
|
||||
LinearLayout linear_supervisor;
|
||||
ImageView img_cam;
|
||||
FloatingActionButton fab_next, fab_save;
|
||||
String emp_id;
|
||||
protected String _pathforcheck = "", _path, image_name = "", str, country_id, store_flag_str;
|
||||
String visit_date, store_id, username;
|
||||
private SharedPreferences preferences;
|
||||
String gallery_package = "";
|
||||
Uri outputFileUri;
|
||||
boolean saved_flag = false, update_flag = false;
|
||||
ArrayList<CoachingVisitGetterSetter> coachingVisitdata;
|
||||
boolean coaching_visit_camera_flag = false;
|
||||
MultiSpinnerSearch multi_spinner_supervisor;
|
||||
|
||||
ArrayList<String> selectedSupervisorList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_coaching_visit_store);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
linear_supervisor = (LinearLayout) findViewById(R.id.linear_supervisor);
|
||||
exist_spinner = (Spinner) findViewById(R.id.spinner_coaching_visit);
|
||||
//supervisor_spinner = (Spinner) findViewById(R.id.spinner_supervisor);
|
||||
img_cam = (ImageView) findViewById(R.id.img_cam);
|
||||
|
||||
multi_spinner_supervisor = (MultiSpinnerSearch) findViewById(R.id.multi_spinner_supervisor);
|
||||
context = this;
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
toolbar.setTitle(getResources().getString(R.string.title_activity_coaching_visit_store));
|
||||
|
||||
str = CommonString.getImagesFolder(context);
|
||||
|
||||
store_id = getIntent().getStringExtra(CommonString.KEY_STORE_ID);
|
||||
store_flag_str = getIntent().getStringExtra(CommonString.KEY_STORE_FLAG);
|
||||
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
//store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, null);
|
||||
|
||||
fab_next = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab_save = (FloatingActionButton) findViewById(R.id.fab_save);
|
||||
|
||||
database = new GSKOrangeDB(this);
|
||||
database.open();
|
||||
|
||||
coachingVisitdata = database.getCoachingVisitStoreData(store_id);
|
||||
|
||||
//Enable disable According to Configuration
|
||||
ArrayList<ConfigurationMasterGetterSetter> configurationData = database.getConfigurationMasterData(country_id);
|
||||
if (configurationData.size() > 0) {
|
||||
|
||||
for (int i = 0; i < configurationData.size(); i++) {
|
||||
if (configurationData.get(i).getCONFIGURE().get(0).equalsIgnoreCase("COACHING VISIT IMAGE") &&
|
||||
configurationData.get(i).getACTIVE().get(0).equalsIgnoreCase("1")) {
|
||||
coaching_visit_camera_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (coaching_visit_camera_flag) {
|
||||
img_cam.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
img_cam.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
supervisorList = database.getSupervisorcheckListData();
|
||||
|
||||
exist_adapter = new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_item);
|
||||
|
||||
String select_str = getResources().getString(R.string.select);
|
||||
|
||||
exist_adapter.add(select_str);
|
||||
exist_adapter.add(getResources().getString(R.string.yes));
|
||||
exist_adapter.add(getResources().getString(R.string.no));
|
||||
|
||||
exist_spinner.setAdapter(exist_adapter);
|
||||
|
||||
exist_adapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
exist_spinner.setOnItemSelectedListener(this);
|
||||
|
||||
if (coachingVisitdata.size() != 0) {
|
||||
update_flag = true;
|
||||
fab_save.hide();//setVisibility(View.GONE);
|
||||
fab_next.show();//setVisibility(View.VISIBLE);
|
||||
if (coachingVisitdata.get(0).isExists()) {
|
||||
exist_spinner.setSelection(1);
|
||||
} else {
|
||||
exist_spinner.setSelection(2);
|
||||
}
|
||||
exist_spinner.setEnabled(false);
|
||||
}
|
||||
|
||||
fab_next.setOnClickListener(this);
|
||||
fab_save.setOnClickListener(this);
|
||||
img_cam.setOnClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
switch (parent.getId()) {
|
||||
case R.id.spinner_coaching_visit:
|
||||
if (position != 0) {
|
||||
|
||||
if (!update_flag) {
|
||||
|
||||
fab_save.show();//setVisibility(View.VISIBLE);
|
||||
|
||||
if (position == 1) {
|
||||
|
||||
linear_supervisor.setVisibility(View.VISIBLE);
|
||||
|
||||
coaching_visit = 1;
|
||||
|
||||
/**
|
||||
* Getting array of String to Bind in Spinner
|
||||
*/
|
||||
//final List<String> list = Arrays.asList(getResources().getStringArray(R.array.sports_array));
|
||||
|
||||
final List<KeyPairBoolData> listArray0 = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < supervisorList.size(); i++) {
|
||||
KeyPairBoolData h = new KeyPairBoolData();
|
||||
h.setId(i + 1);
|
||||
h.setName(supervisorList.get(i).getSUPERVISOR().get(0));
|
||||
h.setSelected(false);
|
||||
listArray0.add(h);
|
||||
}
|
||||
|
||||
multi_spinner_supervisor.setItems(listArray0, -1, new SpinnerListener() {
|
||||
|
||||
@Override
|
||||
public void onItemsSelected(List<KeyPairBoolData> items) {
|
||||
|
||||
selectedSupervisorList.clear();
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (items.get(i).isSelected()) {
|
||||
|
||||
selectedSupervisorList.add(items.get(i).getName());
|
||||
Log.i("MultiSpinner", i + " : " + items.get(i).getName() + " : " + items.get(i).isSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
coaching_visit = 0;
|
||||
selectedSupervisorList.clear();
|
||||
linear_supervisor.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
coaching_visit = -1;
|
||||
linear_supervisor.setVisibility(View.GONE);
|
||||
fab_save.hide();//setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.multi_spinner_supervisor:
|
||||
|
||||
/* if(position!=0){
|
||||
emp_id = supervisorList.get(position-1).getEMP_ID().get(0);
|
||||
}
|
||||
else {
|
||||
emp_id = "";
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.img_cam:
|
||||
_pathforcheck = store_id + "CheckVisit" + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
|
||||
startCameraActivity();
|
||||
break;
|
||||
|
||||
case R.id.fab_save:
|
||||
|
||||
if (coaching_visit == 1) {
|
||||
|
||||
String error_msg = "";
|
||||
boolean flag = true;
|
||||
//if(emp_id.equals("")){
|
||||
if (selectedSupervisorList.size() == 0) {
|
||||
flag = false;
|
||||
error_msg = getString(R.string.title_activity_select_dropdown);
|
||||
} else if (coaching_visit_camera_flag && image_name.equals("")) {
|
||||
flag = false;
|
||||
error_msg = getString(R.string.clickimage);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
|
||||
for (int i = 0; i < selectedSupervisorList.size(); i++) {
|
||||
CoachingVisitGetterSetter coachingVisitGetterSetter = new CoachingVisitGetterSetter();
|
||||
coachingVisitGetterSetter.setEmp_id(getEmp_idFromName(selectedSupervisorList.get(i)));
|
||||
coachingVisitGetterSetter.setImg_path(image_name);
|
||||
coachingVisitGetterSetter.setExists(coaching_visit == 1);
|
||||
|
||||
database.insertCoachingVisitStoreData(coachingVisitGetterSetter, store_id);
|
||||
}
|
||||
|
||||
Toast.makeText(context, getString(R.string.save_message), Toast.LENGTH_SHORT).show();
|
||||
|
||||
saved_flag = true;
|
||||
|
||||
fab_next.show();//setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Snackbar.make(linear_supervisor, error_msg, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
CoachingVisitGetterSetter coachingVisitGetterSetter = new CoachingVisitGetterSetter();
|
||||
coachingVisitGetterSetter.setEmp_id("0");
|
||||
coachingVisitGetterSetter.setImg_path(image_name);
|
||||
coachingVisitGetterSetter.setExists(coaching_visit == 1);
|
||||
|
||||
database.insertCoachingVisitStoreData(coachingVisitGetterSetter, store_id);
|
||||
|
||||
Toast.makeText(context, getString(R.string.save_message), Toast.LENGTH_SHORT).show();
|
||||
saved_flag = true;
|
||||
fab_next.show();//setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case R.id.fab:
|
||||
|
||||
if (saved_flag || update_flag) {
|
||||
|
||||
Intent i = new Intent(CoachingVisitStoreActivity.this, StoreCheckoutImageActivity.class);
|
||||
i.putExtra(CommonString.KEY_STORE_ID, store_id);
|
||||
i.putExtra(CommonString.KEY_STORE_FLAG, store_flag_str);
|
||||
startActivity(i);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
} else {
|
||||
Snackbar.make(linear_supervisor, getString(R.string.please_save_data), Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String getEmp_idFromName(String name) {
|
||||
String emp_id = "0";
|
||||
|
||||
for (int i = 0; i < supervisorList.size(); i++) {
|
||||
if (supervisorList.get(i).getSUPERVISOR().get(0).equalsIgnoreCase(name)) {
|
||||
emp_id = supervisorList.get(i).getEMP_ID().get(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return emp_id;
|
||||
}
|
||||
|
||||
protected void startCameraActivity() {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
//Crashlytics.logException(new Exception(e.getCause()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingSuperCall")
|
||||
@SuppressWarnings("deprecation")
|
||||
@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(str + _pathforcheck).exists()) {
|
||||
|
||||
img_cam.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
|
||||
|
||||
image_name = _pathforcheck;
|
||||
|
||||
_pathforcheck = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
+812
@@ -0,0 +1,812 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
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.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.BrandMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.CompetitonPromoGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.PROMOTION_TYPE_MASTERGetterSetter;
|
||||
|
||||
public class CompetitionPromoActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, View.OnClickListener {
|
||||
private Context context;
|
||||
ToggleButton btntoggle;
|
||||
boolean isDataAdded = false, isExists = true, is_camera_compulsory = false;
|
||||
LinearLayout lin_parent;
|
||||
GSKOrangeDB db;
|
||||
private SharedPreferences preferences;
|
||||
Spinner spinner_brand_list,sp_promotion_typ,sp_subcategory;
|
||||
String store_id, visit_date, username, country_id,keyAccount_id,class_id,storeType_id;
|
||||
String categoryName, categoryId;
|
||||
ArrayList<BrandMasterGetterSetter> brand_list = new ArrayList<>();
|
||||
ArrayList<BrandMasterGetterSetter> subcategory_list = new ArrayList<>();
|
||||
ArrayList<PROMOTION_TYPE_MASTERGetterSetter> promotion_list = new ArrayList<>();
|
||||
String brand = "",subcategory="", _path = "";
|
||||
String promotion = "";
|
||||
EditText et_sku_name;
|
||||
FloatingActionButton fab_save, fab_add;
|
||||
ImageView imgCam, imgCam1, imgCam2;
|
||||
String img_str = "", img_str1 = "", img_str2 = "";
|
||||
String _pathforcheck, _pathforcheck1, _pathforcheck2;
|
||||
Uri outputFileUri;
|
||||
String gallery_package = "";
|
||||
boolean editFlag = false, isdata_added = false;
|
||||
String str, skuName;
|
||||
int brand_id = 0;
|
||||
int subcategoryId = 0;
|
||||
int promotion_id = 0;
|
||||
RecyclerView rec_added_counterfeit_product;
|
||||
ArrayList<CompetitonPromoGetterSetter> addedCounterfeitProducts = new ArrayList<>();
|
||||
ArrayList<CompetitonPromoGetterSetter> exists_data = new ArrayList<>();
|
||||
private LinearLayout lay_competitor_name;
|
||||
|
||||
ProductAdapter productAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_compition_promo);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
btntoggle = (ToggleButton) findViewById(R.id.btntoggle);
|
||||
lin_parent = (LinearLayout) findViewById(R.id.lin_parent_promo);
|
||||
et_sku_name = (EditText) findViewById(R.id.et_sku_name);
|
||||
sp_subcategory = (Spinner) findViewById(R.id.sp_subcategory);
|
||||
spinner_brand_list = (Spinner) findViewById(R.id.sp_brand);
|
||||
sp_promotion_typ = (Spinner) findViewById(R.id.sp_promotion_typ);
|
||||
lay_competitor_name = (LinearLayout) findViewById(R.id.lay_competitor_name);
|
||||
rec_added_counterfeit_product = (RecyclerView) findViewById(R.id.rec_added_counterfeit_product);
|
||||
|
||||
//fab
|
||||
fab_save = findViewById(R.id.fab);
|
||||
fab_add = findViewById(R.id.fab_add);
|
||||
|
||||
//camera Images
|
||||
imgCam = (ImageView) findViewById(R.id.img_cam);
|
||||
imgCam1 = (ImageView) findViewById(R.id.img_cam1);
|
||||
imgCam2 = (ImageView) findViewById(R.id.img_cam2);
|
||||
context = this;
|
||||
//preference data
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, null);
|
||||
|
||||
|
||||
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
|
||||
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
|
||||
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
//Intent data
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
|
||||
db = new GSKOrangeDB(CompetitionPromoActivity.this);
|
||||
db.open();
|
||||
|
||||
btntoggle.setOnClickListener(this);
|
||||
fab_save.setOnClickListener(this);
|
||||
fab_add.setOnClickListener(this);
|
||||
imgCam.setOnClickListener(this);
|
||||
imgCam1.setOnClickListener(this);
|
||||
imgCam2.setOnClickListener(this);
|
||||
|
||||
promotion_list = db.getPromotionTypeData();
|
||||
subcategory_list = db.getSubcategoryData(keyAccount_id, storeType_id,class_id,categoryId);
|
||||
|
||||
//subcategory data
|
||||
BrandMasterGetterSetter subcategory_select = new BrandMasterGetterSetter();
|
||||
String subcat_select = getResources().getString(R.string.select);
|
||||
subcategory_select.setSUB_CATEGORY(subcat_select);
|
||||
subcategory_select.setSUB_CATEGORY_ID("0");
|
||||
subcategory_list.add(0, subcategory_select);
|
||||
CustomSubcategoryAdapter subcat_adapter = new CustomSubcategoryAdapter(CompetitionPromoActivity.this, R.layout.custom_spinner_item, subcategory_list);
|
||||
sp_subcategory.setAdapter(subcat_adapter);
|
||||
sp_subcategory.setOnItemSelectedListener(this);
|
||||
|
||||
|
||||
/*//brand data
|
||||
BrandMasterGetterSetter brand_select = new BrandMasterGetterSetter();
|
||||
String select = getResources().getString(R.string.select);
|
||||
brand_select.setBRAND(select);
|
||||
brand_select.setBRAND_ID("0");
|
||||
brand_list.add(0, brand_select);
|
||||
CustomBrandAdapter adapter = new CustomBrandAdapter(CompetitionPromoActivity.this, R.layout.custom_spinner_item, brand_list);
|
||||
spinner_brand_list.setAdapter(adapter);
|
||||
spinner_brand_list.setOnItemSelectedListener(this);*/
|
||||
|
||||
//competitor
|
||||
PROMOTION_TYPE_MASTERGetterSetter promoType_select = new PROMOTION_TYPE_MASTERGetterSetter();
|
||||
String selectcomp = getResources().getString(R.string.select);
|
||||
promoType_select.setPROMOTION_TYPE(selectcomp);
|
||||
promoType_select.setPROMOTION_TYPE_ID("0");
|
||||
promotion_list.add(0, promoType_select);
|
||||
CustomPromotionTypeAdapter comp_adapter = new CustomPromotionTypeAdapter(CompetitionPromoActivity.this, R.layout.custom_spinner_item, promotion_list);
|
||||
sp_promotion_typ.setAdapter(comp_adapter);
|
||||
sp_promotion_typ.setOnItemSelectedListener(this);
|
||||
|
||||
|
||||
|
||||
|
||||
//Product List
|
||||
exists_data = db.getCompetitionPromoExistsAfterData(store_id, categoryId);
|
||||
|
||||
if(exists_data.size()>0){
|
||||
isExists = exists_data.get(0).isExists();
|
||||
if(exists_data.get(0).isExists()){
|
||||
addedCounterfeitProducts = db.getCometionPromoAfterData(store_id, categoryId);
|
||||
if(addedCounterfeitProducts.size()>0){
|
||||
rec_added_counterfeit_product.setLayoutManager(new LinearLayoutManager(context));
|
||||
productAdapter = new ProductAdapter(addedCounterfeitProducts);
|
||||
rec_added_counterfeit_product.setAdapter(productAdapter);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//fab_add.hide();//.setVisibility(View.GONE);
|
||||
addedCounterfeitProducts.clear();
|
||||
lin_parent.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
btntoggle.setChecked(isExists);
|
||||
|
||||
str = CommonString.getImagesFolder(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
switch (id) {
|
||||
case R.id.btntoggle:
|
||||
isExists = btntoggle.isChecked();
|
||||
|
||||
if (isExists) {
|
||||
lin_parent.setVisibility(View.VISIBLE);
|
||||
isdata_added = true;
|
||||
} else {
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(CompetitionPromoActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
lin_parent.setVisibility(View.GONE);
|
||||
|
||||
brand = "";
|
||||
subcategory = "";
|
||||
promotion = "";
|
||||
brand_id = 0;
|
||||
subcategoryId = 0;
|
||||
promotion_id = 0;
|
||||
skuName = "";
|
||||
img_str = "";
|
||||
img_str1 = "";
|
||||
img_str2 = "";
|
||||
et_sku_name.setText("");
|
||||
sp_subcategory.setSelection(0);
|
||||
spinner_brand_list.setSelection(0);
|
||||
sp_promotion_typ.setSelection(0);
|
||||
|
||||
addedCounterfeitProducts.clear();
|
||||
isdata_added = true;
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//checkBox.setChecked(true);
|
||||
btntoggle.setChecked(true);
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.fab_add:
|
||||
|
||||
skuName = et_sku_name.getText().toString().replaceAll("[&^<>{}'$]", "").replaceFirst("^0+(?!$)", "");
|
||||
|
||||
if (promotion.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_select_promo_type, Snackbar.LENGTH_SHORT).show();
|
||||
} else if (subcategory.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_select_sub_category, Snackbar.LENGTH_SHORT).show();
|
||||
}else if (brand.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_select_competitor, Snackbar.LENGTH_SHORT).show();
|
||||
} else if (skuName.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_enter_comment, Snackbar.LENGTH_SHORT).show();
|
||||
} /*else if (img_str.equals("") && img_str1.equals("") && img_str2.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.click_image, Snackbar.LENGTH_SHORT).show();
|
||||
}*/ else {
|
||||
CompetitonPromoGetterSetter product = new CompetitonPromoGetterSetter();
|
||||
product.setBrand(brand);
|
||||
product.setPromotion(promotion);
|
||||
product.setBrandId(brand_id);
|
||||
product.setPromotion_id(promotion_id);
|
||||
product.setSkuName(skuName);
|
||||
product.setImgStr(img_str);
|
||||
product.setImgStr1(img_str1);
|
||||
product.setImgStr2(img_str2);
|
||||
|
||||
addedCounterfeitProducts.add(product);
|
||||
|
||||
rec_added_counterfeit_product.setLayoutManager(new LinearLayoutManager(context));
|
||||
productAdapter = new ProductAdapter(addedCounterfeitProducts);
|
||||
rec_added_counterfeit_product.setAdapter(productAdapter);
|
||||
|
||||
subcategory = "";
|
||||
brand = "";
|
||||
promotion = "";
|
||||
subcategoryId = 0;
|
||||
brand_id = 0;
|
||||
promotion_id = 0;
|
||||
skuName = "";
|
||||
img_str = "";
|
||||
img_str1 = "";
|
||||
img_str2 = "";
|
||||
et_sku_name.setText("");
|
||||
sp_subcategory.setSelection(0);
|
||||
spinner_brand_list.setSelection(0);
|
||||
sp_promotion_typ.setSelection(0);
|
||||
//clearBrandSpinner();
|
||||
|
||||
imgCam.setBackgroundResource(R.mipmap.camera_orange);
|
||||
imgCam1.setBackgroundResource(R.mipmap.camera_orange);
|
||||
imgCam2.setBackgroundResource(R.mipmap.camera_orange);
|
||||
|
||||
isdata_added = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.fab:
|
||||
if(isExists && addedCounterfeitProducts.size()==0){
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.title_activity_Want_add,Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
db.InsertComptionPromotData(addedCounterfeitProducts, categoryId, store_id, isExists);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.img_cam:
|
||||
_pathforcheck = store_id + "CounterfeitProductImg1" + categoryId + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
startCameraActivity();
|
||||
break;
|
||||
|
||||
case R.id.img_cam1:
|
||||
_pathforcheck1 = store_id + "CounterfeitProductImg2" + categoryId + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck1;
|
||||
startCameraActivity();
|
||||
break;
|
||||
|
||||
case R.id.img_cam2:
|
||||
_pathforcheck2 = store_id + "CounterfeitProductImg3" + categoryId + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck2;
|
||||
startCameraActivity();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void clearBrandSpinner() {
|
||||
brand_list.clear();
|
||||
|
||||
BrandMasterGetterSetter brand_select = new BrandMasterGetterSetter();
|
||||
String str = getResources().getString(R.string.select);
|
||||
brand_select.setBRAND(str);
|
||||
brand_select.setBRAND_ID("0");
|
||||
brand_list.add(0, brand_select);
|
||||
CustomBrandAdapter adapter = new CustomBrandAdapter(CompetitionPromoActivity.this, R.layout.custom_spinner_item, brand_list);
|
||||
|
||||
spinner_brand_list.setAdapter(adapter);
|
||||
spinner_brand_list.setOnItemSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (parent.getId()) {
|
||||
case R.id.sp_subcategory:
|
||||
if (position != 0) {
|
||||
subcategory = subcategory_list.get(position).getSUB_CATEGORY().get(0);
|
||||
subcategoryId = Integer.parseInt(subcategory_list.get(position).getSUB_CATEGORY_ID().get(0));
|
||||
|
||||
brand_list = db.getCompetionData(keyAccount_id, storeType_id,class_id,categoryId,subcategoryId);
|
||||
//brand data
|
||||
BrandMasterGetterSetter brand_select = new BrandMasterGetterSetter();
|
||||
String select = getResources().getString(R.string.select);
|
||||
brand_select.setBRAND(select);
|
||||
brand_select.setBRAND_ID("0");
|
||||
brand_list.add(0, brand_select);
|
||||
CustomBrandAdapter adapter = new CustomBrandAdapter(CompetitionPromoActivity.this, R.layout.custom_spinner_item, brand_list);
|
||||
spinner_brand_list.setAdapter(adapter);
|
||||
spinner_brand_list.setOnItemSelectedListener(this);
|
||||
|
||||
lay_competitor_name.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
subcategory = "";
|
||||
subcategoryId = 0;
|
||||
lay_competitor_name.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.sp_brand:
|
||||
|
||||
if (position != 0) {
|
||||
brand = brand_list.get(position).getBRAND().get(0);
|
||||
brand_id = Integer.parseInt(brand_list.get(position).getBRAND_ID().get(0));
|
||||
} else {
|
||||
brand = "";
|
||||
brand_id = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.sp_promotion_typ:
|
||||
|
||||
if (position != 0) {
|
||||
promotion = promotion_list.get(position).getPROMOTION_TYPE().get(0);
|
||||
promotion_id = Integer.parseInt(promotion_list.get(position).getPROMOTION_TYPE_ID().get(0));
|
||||
} else {
|
||||
promotion = "";
|
||||
promotion_id = 0;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
|
||||
//subcategory data
|
||||
public class CustomSubcategoryAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private Activity activity;
|
||||
private ArrayList data;
|
||||
BrandMasterGetterSetter tempValues = null;
|
||||
LayoutInflater inflater;
|
||||
|
||||
/*************
|
||||
* CustomSubcategoryAdapter Constructor
|
||||
*****************/
|
||||
public CustomSubcategoryAdapter(
|
||||
CompetitionPromoActivity activitySpinner,
|
||||
int textViewResourceId,
|
||||
ArrayList objects
|
||||
|
||||
) {
|
||||
super(activitySpinner, textViewResourceId, objects);
|
||||
|
||||
/********** Take passed values **********/
|
||||
activity = activitySpinner;
|
||||
data = objects;
|
||||
/*********** Layout inflator to call external xml layout () **********************/
|
||||
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
// This funtion called for each row ( Called data.size() times )
|
||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
/********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
|
||||
View row = inflater.inflate(R.layout.custom_spinner_item, parent, false);
|
||||
|
||||
/***** Get each Model object from Arraylist ********/
|
||||
tempValues = null;
|
||||
tempValues = (BrandMasterGetterSetter) data.get(position);
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.tv_text);
|
||||
|
||||
if (position == 0) {
|
||||
|
||||
// Default selected Spinner item
|
||||
label.setText(getResources().getString(R.string.select));
|
||||
//sub.setText("");
|
||||
} else {
|
||||
// Set values for spinner each row
|
||||
label.setText(tempValues.getSUB_CATEGORY().get(0));
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class CustomBrandAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private Activity activity;
|
||||
private ArrayList data;
|
||||
BrandMasterGetterSetter tempValues = null;
|
||||
LayoutInflater inflater;
|
||||
|
||||
/*************
|
||||
* CustomBrandAdapter Constructor
|
||||
*****************/
|
||||
public CustomBrandAdapter(
|
||||
CompetitionPromoActivity activitySpinner,
|
||||
int textViewResourceId,
|
||||
ArrayList objects
|
||||
|
||||
) {
|
||||
super(activitySpinner, textViewResourceId, objects);
|
||||
|
||||
/********** Take passed values **********/
|
||||
activity = activitySpinner;
|
||||
data = objects;
|
||||
/*********** Layout inflator to call external xml layout () **********************/
|
||||
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
// This funtion called for each row ( Called data.size() times )
|
||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
/********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
|
||||
View row = inflater.inflate(R.layout.custom_spinner_item, parent, false);
|
||||
|
||||
/***** Get each Model object from Arraylist ********/
|
||||
tempValues = null;
|
||||
tempValues = (BrandMasterGetterSetter) data.get(position);
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.tv_text);
|
||||
|
||||
if (position == 0) {
|
||||
|
||||
// Default selected Spinner item
|
||||
label.setText(getResources().getString(R.string.select));
|
||||
//sub.setText("");
|
||||
} else {
|
||||
// Set values for spinner each row
|
||||
label.setText(tempValues.getBRAND().get(0));
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CustomPromotionTypeAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private Activity activity;
|
||||
private ArrayList data;
|
||||
PROMOTION_TYPE_MASTERGetterSetter tempValues = null;
|
||||
LayoutInflater inflater;
|
||||
|
||||
/*************
|
||||
* CustomPromotionTypeAdapter Constructor
|
||||
*****************/
|
||||
public CustomPromotionTypeAdapter(
|
||||
CompetitionPromoActivity activitySpinner,
|
||||
int textViewResourceId,
|
||||
ArrayList objects
|
||||
|
||||
) {
|
||||
super(activitySpinner, textViewResourceId, objects);
|
||||
|
||||
/********** Take passed values **********/
|
||||
activity = activitySpinner;
|
||||
data = objects;
|
||||
/*********** Layout inflator to call external xml layout () **********************/
|
||||
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
// This funtion called for each row ( Called data.size() times )
|
||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
/********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
|
||||
View row = inflater.inflate(R.layout.custom_spinner_item, parent, false);
|
||||
|
||||
/***** Get each Model object from Arraylist ********/
|
||||
tempValues = null;
|
||||
tempValues = (PROMOTION_TYPE_MASTERGetterSetter) data.get(position);
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.tv_text);
|
||||
|
||||
if (position == 0) {
|
||||
|
||||
// Default selected Spinner item
|
||||
label.setText(getResources().getString(R.string.select));
|
||||
//sub.setText("");
|
||||
} else {
|
||||
// Set values for spinner each row
|
||||
label.setText(tempValues.getPROMOTION_TYPE().get(0));
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
protected void startCameraActivity() {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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:
|
||||
|
||||
editFlag = true;
|
||||
|
||||
if (_pathforcheck != null && !_pathforcheck.equals("")) {
|
||||
if (new File(str + _pathforcheck).exists()) {
|
||||
|
||||
imgCam.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
img_str = _pathforcheck;
|
||||
_pathforcheck = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (_pathforcheck1 != null && !_pathforcheck1.equals("")) {
|
||||
if (new File(str + _pathforcheck1).exists()) {
|
||||
|
||||
imgCam1.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
img_str1 = _pathforcheck1;
|
||||
_pathforcheck1 = "";
|
||||
}
|
||||
}
|
||||
if (_pathforcheck2 != null && !_pathforcheck2.equals("")) {
|
||||
if (new File(str + _pathforcheck2).exists()) {
|
||||
|
||||
imgCam2.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
img_str2 = _pathforcheck2;
|
||||
_pathforcheck2 = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHolder> {
|
||||
|
||||
private ArrayList<CompetitonPromoGetterSetter> list;
|
||||
|
||||
public ProductAdapter(ArrayList<CompetitonPromoGetterSetter> promoList) {
|
||||
list = promoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_competition_promo, parent, false);
|
||||
return new ProductAdapter.ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ProductAdapter.ViewHolder holder, int position) {
|
||||
|
||||
final CompetitonPromoGetterSetter mItem = list.get(position);
|
||||
holder.tv_brand.setText(getString(R.string.promotion_type) + " - " + mItem.getPromotion());
|
||||
holder.tv_competitor.setText(getString(R.string.competitor) + " - " + mItem.getBrand());
|
||||
holder.tv_sku_name.setText(getString(R.string.comment) + " - " + mItem.getSkuName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final TextView tv_brand, tv_competitor,tv_sku_name;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
|
||||
mView = view;
|
||||
tv_brand = (TextView) mView.findViewById(R.id.tv_brand);
|
||||
tv_sku_name = (TextView) mView.findViewById(R.id.tv_sku_name);
|
||||
tv_competitor = (TextView) mView.findViewById(R.id.tv_competitor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
ischanged();
|
||||
}
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
void ischanged(){
|
||||
if(isdata_added){
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(CompetitionPromoActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
else {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
ischanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,444 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.StringReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.ChatMessageGetterSetter;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.gsk_dailyentry.StoreWisePerformanceActivity;
|
||||
import cpm.com.gskmtorange.xmlHandlers.FailureXMLHandler;
|
||||
|
||||
public class ConversationActivity extends AppCompatActivity {
|
||||
String userId, culture_id, store_id, chat_id, message_main, visit_date;
|
||||
private SharedPreferences preferences = null;
|
||||
GSKOrangeDB db;
|
||||
private Context context;
|
||||
ArrayList<ChatMessageGetterSetter> conversation_list = new ArrayList<>();
|
||||
MyRecyclerAdapter adapter;
|
||||
RecyclerView rec;
|
||||
EditText et_reply;
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_conversation);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
db = new GSKOrangeDB(ConversationActivity.this);
|
||||
db.open();
|
||||
context = this;
|
||||
rec = (RecyclerView) findViewById(R.id.rec_conversation);
|
||||
et_reply = (EditText) findViewById(R.id.et_reply);
|
||||
|
||||
chat_id = getIntent().getStringExtra(CommonString.KEY_CHAT_ID);
|
||||
message_main = getIntent().getStringExtra(CommonString.KEY_MESSAGE);
|
||||
|
||||
setTitle(message_main);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
userId = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
culture_id = preferences.getString(CommonString.KEY_CULTURE_ID, "");
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
|
||||
conversation_list = db.getChatMessageCommentsData(store_id, chat_id);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String reply = et_reply.getText().toString();
|
||||
if (reply.equals("")) {
|
||||
Snackbar.make(et_reply, R.string.reply_alert, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
|
||||
/* ChatMessageGetterSetter msg = new ChatMessageGetterSetter();
|
||||
msg.setCHAT_ID("0");
|
||||
msg.setMESSAGE("");
|
||||
msg.setMESSAGEDATE(visit_date);
|
||||
msg.setSENDERID("0");
|
||||
msg.setSENDER(userId);
|
||||
msg.setRECEIVERID("0");
|
||||
msg.setRECEIVER(userId);
|
||||
msg.setSTOREID(store_id);
|
||||
msg.setCOMMENTDATE(visit_date);
|
||||
msg.setCOMMENT(reply);
|
||||
msg.setSENDER_USERID(userId);
|
||||
|
||||
conversation_list.add(msg);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
et_reply.setText("");*/
|
||||
|
||||
// Check if no view has focus:
|
||||
View v = getCurrentFocus();
|
||||
if (v != null) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
new GeoTagUpload(ConversationActivity.this).execute(reply);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//if (conversation_list.size() > 0) {
|
||||
adapter = new MyRecyclerAdapter(context, conversation_list);
|
||||
rec.setAdapter(adapter);
|
||||
rec.setLayoutManager(new LinearLayoutManager(context));
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.MyViewHolder> {
|
||||
|
||||
private LayoutInflater inflator;
|
||||
|
||||
ArrayList<ChatMessageGetterSetter> data = new ArrayList<>();
|
||||
|
||||
public MyRecyclerAdapter(Context context, ArrayList<ChatMessageGetterSetter> data) {
|
||||
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyRecyclerAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = inflator.inflate(R.layout.conversation_item, parent, false);
|
||||
|
||||
MyRecyclerAdapter.MyViewHolder holder = new MyRecyclerAdapter.MyViewHolder(view);
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MyRecyclerAdapter.MyViewHolder holder, final int position) {
|
||||
|
||||
//final MappingPlanogramCountrywiseGetterSetter current = data.get(position);
|
||||
|
||||
final String msg_topic_str = data.get(position).getCOMMENT();
|
||||
final String latest_msg_str = data.get(position).getRECEIVER();
|
||||
final String date_time_str = data.get(position).getCOMMENTDATE();
|
||||
final String msg_from_str = data.get(position).getSENDER();
|
||||
final String sender_user_id = data.get(position).getSENDER_USERID();
|
||||
|
||||
if (sender_user_id.equals(userId)) {
|
||||
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
buttonLayoutParams.setMargins(100, 10, 5, 0);
|
||||
holder.parent_item.setLayoutParams(buttonLayoutParams);
|
||||
holder.card_view.setCardBackgroundColor(getResources().getColor(R.color.char_card_bg));
|
||||
} else {
|
||||
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
buttonLayoutParams.setMargins(5, 10, 100, 0);
|
||||
holder.parent_item.setLayoutParams(buttonLayoutParams);
|
||||
holder.card_view.setCardBackgroundColor(getResources().getColor(R.color.white));
|
||||
}
|
||||
|
||||
holder.msg_topic.setText(msg_topic_str);
|
||||
holder.latest_msg.setText(latest_msg_str);
|
||||
holder.date_time.setText(date_time_str);
|
||||
holder.msg_from.setText(msg_from_str);
|
||||
//holder.detail.setText(current.getDocument_descriiption().get(0));
|
||||
|
||||
holder.parent_layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return conversation_list.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView msg_topic, latest_msg, date_time, msg_from;
|
||||
LinearLayout parent_layout, parent_item;
|
||||
CardView card_view;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
msg_topic = (TextView) itemView.findViewById(R.id.tv_msg_topic);
|
||||
latest_msg = (TextView) itemView.findViewById(R.id.tv_latest_msg);
|
||||
date_time = (TextView) itemView.findViewById(R.id.tv_date_time);
|
||||
msg_from = (TextView) itemView.findViewById(R.id.tv_from);
|
||||
|
||||
parent_layout = (LinearLayout) itemView.findViewById(R.id.layout_parent);
|
||||
parent_item = (LinearLayout) itemView.findViewById(R.id.parent_item);
|
||||
card_view = (CardView) itemView.findViewById(R.id.card_view);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class GeoTagUpload extends AsyncTask<String, Void, String> {
|
||||
|
||||
private Context context;
|
||||
|
||||
GeoTagUpload(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
|
||||
super.onPreExecute();
|
||||
|
||||
dialog = new Dialog(context);
|
||||
dialog.setContentView(R.layout.custom);
|
||||
dialog.setTitle(getResources().getString(R.string.dialog_title));
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... params) {
|
||||
|
||||
boolean flag_success = false;
|
||||
String strflag = "";
|
||||
try {
|
||||
|
||||
GSKOrangeDB db = new GSKOrangeDB(ConversationActivity.this);
|
||||
db.open();
|
||||
String reply = params[0];
|
||||
|
||||
SAXParserFactory saxPF = SAXParserFactory.newInstance();
|
||||
SAXParser saxP = saxPF.newSAXParser();
|
||||
XMLReader xmlR = saxP.getXMLReader();
|
||||
|
||||
|
||||
String current_xml = "";
|
||||
|
||||
String onXML = "[CHAT_REPLY][CHAT_ID]"
|
||||
+ chat_id
|
||||
+ "[/CHAT_ID]"
|
||||
+ "[SENDER_ID]"
|
||||
+ "0"
|
||||
+ "[/SENDER_ID]"
|
||||
+ "[RECIEVER_ID]"
|
||||
+ "0"
|
||||
+ "[/RECIEVER_ID]"
|
||||
+ "[STORE_ID]"
|
||||
+ store_id
|
||||
+ "[/STORE_ID]"
|
||||
+ "[MESSAGE]"
|
||||
+ reply
|
||||
+ "[/MESSAGE]"
|
||||
+ "[USER_ID]"
|
||||
+ userId
|
||||
+ "[/USER_ID]"
|
||||
+ "[/CHAT_REPLY]";
|
||||
|
||||
current_xml = "[DATA]" + onXML
|
||||
+ "[/DATA]";
|
||||
|
||||
SoapObject request = new SoapObject(CommonString.NAMESPACE,
|
||||
CommonString.METHOD_UPLOAD_CHAT_DATA);
|
||||
//request.addProperty("MID", "0");
|
||||
// request.addProperty("KEYS", "CURRENT_DATA");
|
||||
// request.addProperty("USERNAME", username);
|
||||
|
||||
request.addProperty("onXML", current_xml);
|
||||
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
HttpTransportSE androidHttpTransport = new HttpTransportSE(
|
||||
CommonString.URL);
|
||||
androidHttpTransport.call(
|
||||
CommonString.SOAP_ACTION_UPLOAD_CHAT_DATA, envelope);
|
||||
Object result = (Object) envelope.getResponse();
|
||||
|
||||
if (result.toString().contains(
|
||||
CommonString.KEY_SUCCESS)) {
|
||||
flag_success = true;
|
||||
} else {
|
||||
flag_success = false;
|
||||
}
|
||||
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
|
||||
flag_success = false;
|
||||
strflag = CommonString.MESSAGE_EXCEPTION;
|
||||
|
||||
} catch (SocketTimeoutException e) {
|
||||
flag_success = false;
|
||||
strflag = CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
|
||||
} catch (InterruptedIOException e) {
|
||||
|
||||
flag_success = false;
|
||||
strflag = CommonString.MESSAGE_EXCEPTION;
|
||||
|
||||
} catch (IOException e) {
|
||||
flag_success = false;
|
||||
strflag = CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
} catch (XmlPullParserException e) {
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
//Crashlytics.logException(new Exception(e.getCause()));
|
||||
|
||||
flag_success = false;
|
||||
strflag = CommonString.MESSAGE_XmlPull;
|
||||
} catch (Exception e) {
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
// Crashlytics.logException(new Exception(e.getCause()));
|
||||
|
||||
flag_success = false;
|
||||
strflag = CommonString.MESSAGE_EXCEPTION;
|
||||
}
|
||||
|
||||
if (flag_success) {
|
||||
return CommonString.KEY_SUCCESS;
|
||||
} else {
|
||||
return strflag;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
|
||||
dialog.dismiss();
|
||||
|
||||
if (result.equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
dialog.dismiss();
|
||||
|
||||
String reply = et_reply.getText().toString();
|
||||
|
||||
ChatMessageGetterSetter msg = new ChatMessageGetterSetter();
|
||||
msg.setCHAT_ID("0");
|
||||
msg.setMESSAGE("");
|
||||
msg.setMESSAGEDATE(visit_date);
|
||||
msg.setSENDERID("0");
|
||||
msg.setSENDER(userId);
|
||||
msg.setRECEIVERID("0");
|
||||
msg.setRECEIVER(userId);
|
||||
msg.setSTOREID(store_id);
|
||||
msg.setCOMMENTDATE(visit_date);
|
||||
msg.setCOMMENT(reply);
|
||||
msg.setSENDER_USERID(userId);
|
||||
|
||||
conversation_list.add(msg);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
et_reply.setText("");
|
||||
//showAlert(getString(R.string.data_downloaded_successfully));
|
||||
} else {
|
||||
|
||||
showAlert(getString(R.string.DataNot) + " " + result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showAlert(String str) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
|
||||
public class CounterfeitIndicatorWebActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
WebView webView;
|
||||
String url = "https://gskme.parinaam.in/res/eg/fake.html";
|
||||
private SharedPreferences preferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_counterfeit_indicator_web);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getResources().getString(R.string.title_activity_counterfeit_indicator_web));
|
||||
|
||||
webView = (WebView) findViewById(R.id.webview);
|
||||
|
||||
webView.setWebViewClient(new MyWebViewClient());
|
||||
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
|
||||
if (!url.equals("")) {
|
||||
|
||||
webView.loadUrl(url);
|
||||
|
||||
}
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).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) {
|
||||
/* progress.setVisibility(View.GONE);
|
||||
WebViewActivity.this.progress.setProgress(100);*/
|
||||
//imageView.setVisibility(View.INVISIBLE);
|
||||
webView.setVisibility(View.VISIBLE);
|
||||
super.onPageFinished(view, url);
|
||||
view.clearCache(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
/* progress.setVisibility(View.VISIBLE);
|
||||
WebViewActivity.this.progress.setProgress(0);*/
|
||||
super.onPageStarted(view, url, favicon);
|
||||
}
|
||||
|
||||
}
|
||||
@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() {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
+604
@@ -0,0 +1,604 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
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.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.SpinnerAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.BrandMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.CounterfeitProductGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.CounterfeitProductGetterSetter;
|
||||
|
||||
public class CounterfeitProductsActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, View.OnClickListener {
|
||||
|
||||
private Context context;
|
||||
ToggleButton btntoggle;
|
||||
boolean isDataAdded = false, isExists = true, is_camera_compulsory = false;
|
||||
LinearLayout lin_parent;
|
||||
GSKOrangeDB db;
|
||||
private SharedPreferences preferences;
|
||||
Spinner spinner_brand_list;
|
||||
String store_id, visit_date, username, country_id;
|
||||
String categoryName, categoryId;
|
||||
ArrayList<BrandMasterGetterSetter> brand_list = new ArrayList<>();
|
||||
String brand = "", _path = "";
|
||||
EditText et_stock, et_sku_name;
|
||||
FloatingActionButton fab_save, fab_add;
|
||||
ImageView imgCam, imgCam1, imgCam2;
|
||||
String img_str = "", img_str1 = "", img_str2 = "";
|
||||
String _pathforcheck, _pathforcheck1, _pathforcheck2;
|
||||
Uri outputFileUri;
|
||||
String gallery_package = "";
|
||||
boolean editFlag = false, isdata_added = false;
|
||||
String str, skuName, stock = "";
|
||||
int brand_id = 0;
|
||||
RecyclerView rec_added_counterfeit_product;
|
||||
ArrayList<CounterfeitProductGetterSetter> addedCounterfeitProducts = new ArrayList<>();
|
||||
ArrayList<CounterfeitProductGetterSetter> exists_data = new ArrayList<>();
|
||||
ProductAdapter productAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_counterfeit_products);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
btntoggle = (ToggleButton) findViewById(R.id.btntoggle);
|
||||
lin_parent = (LinearLayout) findViewById(R.id.lin_parent_promo);
|
||||
et_stock = (EditText) findViewById(R.id.et_stock);
|
||||
et_sku_name = (EditText) findViewById(R.id.et_sku_name);
|
||||
spinner_brand_list = (Spinner) findViewById(R.id.sp_brand);
|
||||
rec_added_counterfeit_product = (RecyclerView) findViewById(R.id.rec_added_counterfeit_product);
|
||||
|
||||
//fab
|
||||
fab_save = findViewById(R.id.fab);
|
||||
fab_add = findViewById(R.id.fab_add);
|
||||
|
||||
//camera Images
|
||||
imgCam = (ImageView) findViewById(R.id.img_cam);
|
||||
imgCam1 = (ImageView) findViewById(R.id.img_cam1);
|
||||
imgCam2 = (ImageView) findViewById(R.id.img_cam2);
|
||||
|
||||
//preference data
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, null);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
//Intent data
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
|
||||
db = new GSKOrangeDB(CounterfeitProductsActivity.this);
|
||||
db.open();
|
||||
|
||||
btntoggle.setOnClickListener(this);
|
||||
fab_save.setOnClickListener(this);
|
||||
fab_add.setOnClickListener(this);
|
||||
imgCam.setOnClickListener(this);
|
||||
imgCam1.setOnClickListener(this);
|
||||
imgCam2.setOnClickListener(this);
|
||||
|
||||
// brand_list = db.getBrandMasterData(store_id, categoryId);
|
||||
brand_list = db.getBrandMasterData(store_id, categoryId);
|
||||
//brand_list = db.getBrandData(categoryId);
|
||||
|
||||
BrandMasterGetterSetter brand_select = new BrandMasterGetterSetter();
|
||||
String select = getResources().getString(R.string.select);
|
||||
brand_select.setBRAND(select);
|
||||
brand_select.setBRAND_ID("0");
|
||||
brand_list.add(0, brand_select);
|
||||
CustomBrandAdapter adapter = new CustomBrandAdapter(CounterfeitProductsActivity.this, R.layout.custom_spinner_item, brand_list);
|
||||
|
||||
spinner_brand_list.setAdapter(adapter);
|
||||
spinner_brand_list.setOnItemSelectedListener(this);
|
||||
|
||||
//Product List
|
||||
exists_data = db.getCounterfeitProductExistsAfterData(store_id, categoryId);
|
||||
|
||||
if(exists_data.size()>0){
|
||||
isExists = exists_data.get(0).isExists();
|
||||
if(exists_data.get(0).isExists()){
|
||||
addedCounterfeitProducts = db.getCounterfeitProductAfterData(store_id, categoryId);
|
||||
if(addedCounterfeitProducts.size()>0){
|
||||
rec_added_counterfeit_product.setLayoutManager(new LinearLayoutManager(context));
|
||||
productAdapter = new ProductAdapter(addedCounterfeitProducts);
|
||||
rec_added_counterfeit_product.setAdapter(productAdapter);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//fab_add.hide();//.setVisibility(View.GONE);
|
||||
addedCounterfeitProducts.clear();
|
||||
lin_parent.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
btntoggle.setChecked(isExists);
|
||||
|
||||
str = CommonString.getImagesFolder(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
switch (id) {
|
||||
case R.id.btntoggle:
|
||||
isExists = btntoggle.isChecked();
|
||||
|
||||
if (isExists) {
|
||||
lin_parent.setVisibility(View.VISIBLE);
|
||||
isdata_added = true;
|
||||
} else {
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(CounterfeitProductsActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
lin_parent.setVisibility(View.GONE);
|
||||
|
||||
brand = "";
|
||||
brand_id = 0;
|
||||
|
||||
stock = "";
|
||||
skuName = "";
|
||||
img_str = "";
|
||||
img_str1 = "";
|
||||
img_str2 = "";
|
||||
|
||||
et_stock.setText("");
|
||||
et_sku_name.setText("");
|
||||
spinner_brand_list.setSelection(0);
|
||||
|
||||
addedCounterfeitProducts.clear();
|
||||
isdata_added = true;
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//checkBox.setChecked(true);
|
||||
btntoggle.setChecked(true);
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.fab_add:
|
||||
|
||||
skuName = et_sku_name.getText().toString().replaceAll("[&^<>{}'$]", "").replaceFirst("^0+(?!$)", "");
|
||||
stock = et_stock.getText().toString();
|
||||
|
||||
if (brand.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_select_brand, Snackbar.LENGTH_SHORT).show();
|
||||
} else if (stock.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_enter_stock, Snackbar.LENGTH_SHORT).show();
|
||||
} else if (skuName.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.pls_enter_sku, Snackbar.LENGTH_SHORT).show();
|
||||
} else if (img_str.equals("") && img_str1.equals("") && img_str2.equals("")) {
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.click_image, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
CounterfeitProductGetterSetter product = new CounterfeitProductGetterSetter();
|
||||
product.setBrand(brand);
|
||||
product.setBrandId(brand_id);
|
||||
product.setStock(Integer.parseInt(stock));
|
||||
product.setSkuName(skuName);
|
||||
product.setImgStr(img_str);
|
||||
product.setImgStr1(img_str1);
|
||||
product.setImgStr2(img_str2);
|
||||
|
||||
addedCounterfeitProducts.add(product);
|
||||
|
||||
rec_added_counterfeit_product.setLayoutManager(new LinearLayoutManager(context));
|
||||
productAdapter = new ProductAdapter(addedCounterfeitProducts);
|
||||
rec_added_counterfeit_product.setAdapter(productAdapter);
|
||||
|
||||
brand = "";
|
||||
brand_id = 0;
|
||||
|
||||
stock = "";
|
||||
skuName = "";
|
||||
img_str = "";
|
||||
img_str1 = "";
|
||||
img_str2 = "";
|
||||
|
||||
et_stock.setText("");
|
||||
et_sku_name.setText("");
|
||||
spinner_brand_list.setSelection(0);
|
||||
//clearBrandSpinner();
|
||||
|
||||
imgCam.setBackgroundResource(R.mipmap.camera_orange);
|
||||
imgCam1.setBackgroundResource(R.mipmap.camera_orange);
|
||||
imgCam2.setBackgroundResource(R.mipmap.camera_orange);
|
||||
|
||||
isdata_added = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.fab:
|
||||
if(isExists && addedCounterfeitProducts.size()==0){
|
||||
Snackbar.make(rec_added_counterfeit_product, R.string.title_activity_Want_add,Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
db.InsertCounterfeitProductData(addedCounterfeitProducts, categoryId, store_id, isExists);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.img_cam:
|
||||
_pathforcheck = store_id + "CounterfeitProductImg1" + categoryId + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
startCameraActivity();
|
||||
break;
|
||||
|
||||
case R.id.img_cam1:
|
||||
_pathforcheck1 = store_id + "CounterfeitProductImg2" + categoryId + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck1;
|
||||
startCameraActivity();
|
||||
break;
|
||||
|
||||
case R.id.img_cam2:
|
||||
_pathforcheck2 = store_id + "CounterfeitProductImg3" + categoryId + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck2;
|
||||
startCameraActivity();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void clearBrandSpinner() {
|
||||
brand_list.clear();
|
||||
|
||||
BrandMasterGetterSetter brand_select = new BrandMasterGetterSetter();
|
||||
String str = getResources().getString(R.string.select);
|
||||
brand_select.setBRAND(str);
|
||||
brand_select.setBRAND_ID("0");
|
||||
brand_list.add(0, brand_select);
|
||||
CustomBrandAdapter adapter = new CustomBrandAdapter(CounterfeitProductsActivity.this, R.layout.custom_spinner_item, brand_list);
|
||||
|
||||
spinner_brand_list.setAdapter(adapter);
|
||||
spinner_brand_list.setOnItemSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (parent.getId()) {
|
||||
case R.id.sp_brand:
|
||||
|
||||
if (position != 0) {
|
||||
brand = brand_list.get(position).getBRAND().get(0);
|
||||
brand_id = Integer.parseInt(brand_list.get(position).getBRAND_ID().get(0));
|
||||
} else {
|
||||
brand = "";
|
||||
brand_id = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
|
||||
public class CustomBrandAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private Activity activity;
|
||||
private ArrayList data;
|
||||
BrandMasterGetterSetter tempValues = null;
|
||||
LayoutInflater inflater;
|
||||
|
||||
/*************
|
||||
* CustomBrandAdapter Constructor
|
||||
*****************/
|
||||
public CustomBrandAdapter(
|
||||
CounterfeitProductsActivity activitySpinner,
|
||||
int textViewResourceId,
|
||||
ArrayList objects
|
||||
|
||||
) {
|
||||
super(activitySpinner, textViewResourceId, objects);
|
||||
|
||||
/********** Take passed values **********/
|
||||
activity = activitySpinner;
|
||||
data = objects;
|
||||
/*********** Layout inflator to call external xml layout () **********************/
|
||||
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
// This funtion called for each row ( Called data.size() times )
|
||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
/********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
|
||||
View row = inflater.inflate(R.layout.custom_spinner_item, parent, false);
|
||||
|
||||
/***** Get each Model object from Arraylist ********/
|
||||
tempValues = null;
|
||||
tempValues = (BrandMasterGetterSetter) data.get(position);
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.tv_text);
|
||||
|
||||
if (position == 0) {
|
||||
|
||||
// Default selected Spinner item
|
||||
label.setText(getResources().getString(R.string.select));
|
||||
//sub.setText("");
|
||||
} else {
|
||||
// Set values for spinner each row
|
||||
label.setText(tempValues.getBRAND().get(0));
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
protected void startCameraActivity() {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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:
|
||||
|
||||
editFlag = true;
|
||||
|
||||
if (_pathforcheck != null && !_pathforcheck.equals("")) {
|
||||
if (new File(str + _pathforcheck).exists()) {
|
||||
|
||||
imgCam.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
img_str = _pathforcheck;
|
||||
_pathforcheck = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (_pathforcheck1 != null && !_pathforcheck1.equals("")) {
|
||||
if (new File(str + _pathforcheck1).exists()) {
|
||||
|
||||
imgCam1.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
img_str1 = _pathforcheck1;
|
||||
_pathforcheck1 = "";
|
||||
}
|
||||
}
|
||||
if (_pathforcheck2 != null && !_pathforcheck2.equals("")) {
|
||||
if (new File(str + _pathforcheck2).exists()) {
|
||||
|
||||
imgCam2.setBackgroundResource(R.mipmap.camera_green);
|
||||
|
||||
img_str2 = _pathforcheck2;
|
||||
_pathforcheck2 = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHolder> {
|
||||
|
||||
private ArrayList<CounterfeitProductGetterSetter> list;
|
||||
|
||||
public ProductAdapter(ArrayList<CounterfeitProductGetterSetter> promoList) {
|
||||
list = promoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_counterfeit_product, parent, false);
|
||||
return new ProductAdapter.ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ProductAdapter.ViewHolder holder, int position) {
|
||||
|
||||
final CounterfeitProductGetterSetter mItem = list.get(position);
|
||||
holder.tv_brand.setText(getString(R.string.brand) + " - " + mItem.getBrand());
|
||||
holder.tv_sku_name.setText(getString(R.string.skuname) + " - " + mItem.getSkuName());
|
||||
holder.tv_stock.setText(" - " + mItem.getStock());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final TextView tv_brand, tv_sku_name, tv_stock;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
|
||||
mView = view;
|
||||
|
||||
tv_brand = (TextView) mView.findViewById(R.id.tv_brand);
|
||||
tv_sku_name = (TextView) mView.findViewById(R.id.tv_sku_name);
|
||||
tv_stock = (TextView) mView.findViewById(R.id.tv_stock);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
ischanged();
|
||||
}
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
void ischanged(){
|
||||
if(isdata_added){
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(CounterfeitProductsActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
else {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
ischanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.adapter.ListAdapter;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.BrandMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityStockFacingGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.NoCameraDataGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.SelectGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.SkuGetterSetter;
|
||||
|
||||
public class CreateSelfActivity extends AppCompatActivity {
|
||||
GSKOrangeDB db;
|
||||
String store_id, visit_date, username, keyAccount_id, class_id, storeType_id, store_flag_str;
|
||||
String categoryName, categoryId, country_id;
|
||||
private SharedPreferences preferences;
|
||||
MSL_AvailabilityStockFacingGetterSetter brand_selected;
|
||||
int number_of_rows = 0;
|
||||
RecyclerView rec_sub_category;
|
||||
static int FROM_DIALOG = 0;
|
||||
static int FROM_CLICK = 1;
|
||||
private Context context;
|
||||
ArrayList<MSL_AvailabilityStockFacingGetterSetter> added_sub_category_list;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_create_self);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
rec_sub_category = (RecyclerView) findViewById(R.id.rec_sub_category);
|
||||
context = this;
|
||||
//preference data
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
store_flag_str = preferences.getString(CommonString.KEY_STORE_FLAG, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
|
||||
|
||||
//Intent data
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
|
||||
db = new GSKOrangeDB(CreateSelfActivity.this);
|
||||
db.open();
|
||||
|
||||
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
|
||||
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showSkuDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
number_of_rows = 0;
|
||||
brand_selected = null;
|
||||
db.open();
|
||||
added_sub_category_list = new ArrayList<>();
|
||||
//kenya use
|
||||
ArrayList<MSL_AvailabilityStockFacingGetterSetter> sub_category_list = db.getSubCategoryMaster(categoryId, store_id, country_id);
|
||||
|
||||
for (int i = 0; i < sub_category_list.size(); i++) {
|
||||
ArrayList<NoCameraDataGetterSetter> noCameraLastVisitData;
|
||||
if (store_flag_str.equalsIgnoreCase(CommonString.FROM_DEVIATION)) {
|
||||
noCameraLastVisitData = db.getNoCameraLastVisitCategoryData(store_id, categoryId,
|
||||
sub_category_list.get(i).getSub_category_id(), CommonString.TABLE_NO_CAMERA_LAST_VISIT_DATA_ADHOC);
|
||||
} else {
|
||||
noCameraLastVisitData = db.getNoCameraLastVisitCategoryData(store_id, categoryId, sub_category_list.get(i).getSub_category_id(),
|
||||
"NO_CAMERA_LAST_VISIT_DATA");
|
||||
}
|
||||
if (db.getNoCameraCategoryDataInserted(store_id, categoryId, sub_category_list.get(i).getSub_category_id()).size() > 0) {
|
||||
MSL_AvailabilityStockFacingGetterSetter subCategory = new MSL_AvailabilityStockFacingGetterSetter();
|
||||
subCategory.setSub_category(sub_category_list.get(i).getSub_category());
|
||||
subCategory.setSub_category_id(sub_category_list.get(i).getSub_category_id());
|
||||
added_sub_category_list.add(subCategory);
|
||||
} else if (noCameraLastVisitData.size() > 0) {
|
||||
MSL_AvailabilityStockFacingGetterSetter subCategory = new MSL_AvailabilityStockFacingGetterSetter();
|
||||
subCategory.setSub_category(sub_category_list.get(i).getSub_category());
|
||||
subCategory.setSub_category_id(sub_category_list.get(i).getSub_category_id());
|
||||
added_sub_category_list.add(subCategory);
|
||||
}
|
||||
}
|
||||
|
||||
if (added_sub_category_list.size() > 0) {
|
||||
rec_sub_category.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
SubcategoryAdapter skuAdapter = new SubcategoryAdapter(added_sub_category_list);
|
||||
rec_sub_category.setAdapter(skuAdapter);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
public void showSkuDialog() {
|
||||
final ArrayList<MSL_AvailabilityStockFacingGetterSetter> sub_category_list = db.getSubCategoryMaster(categoryId, store_id, country_id);
|
||||
MSL_AvailabilityStockFacingGetterSetter brand = new MSL_AvailabilityStockFacingGetterSetter();
|
||||
brand.setSub_category("select");
|
||||
sub_category_list.add(0, brand);
|
||||
// ArrayList<SkuMasterGetterSetter> skuMasterGetterSetterArrayList = db.getSkuT2PData("1", "1", "1",)
|
||||
final Dialog dialog = new Dialog(CreateSelfActivity.this);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
dialog.setContentView(R.layout.create_self_dialog_layout);
|
||||
//pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
//dialog.setCancelable(false);
|
||||
final Spinner spinner_sub_category = (Spinner) dialog.findViewById(R.id.spinner_sub_category);
|
||||
final Spinner spinner_sku = (Spinner) dialog.findViewById(R.id.spinner_no_rows);
|
||||
final Button btn_create = (Button) dialog.findViewById(R.id.btn_create);
|
||||
Button btn_cancel = (Button) dialog.findViewById(R.id.btn_cancel);
|
||||
|
||||
btn_create.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (brand_selected == null) {
|
||||
Snackbar.make(btn_create, "Please select Sub Category", Snackbar.LENGTH_SHORT).show();
|
||||
} else if (number_of_rows == 0) {
|
||||
Snackbar.make(btn_create, "Please select number of rows", Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
|
||||
boolean sub_category_already_filled = false;
|
||||
if (added_sub_category_list.size() > 0) {
|
||||
for (int k = 0; k < added_sub_category_list.size(); k++) {
|
||||
if (added_sub_category_list.get(k).getSub_category_id().equals(brand_selected.getSub_category_id())) {
|
||||
sub_category_already_filled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sub_category_already_filled) {
|
||||
Snackbar.make(btn_create, "Sub Category already added", Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Intent in = new Intent(context, NoCameraActivity.class);
|
||||
in.putExtra("categoryName", categoryName);
|
||||
in.putExtra("categoryId", categoryId);
|
||||
in.putExtra(CommonString.KEY_NUMBER_OF_ROWS, number_of_rows);
|
||||
in.putExtra(CommonString.KEY_SUB_CATEGORY, brand_selected);
|
||||
in.putExtra(CommonString.KEY_FROM, FROM_DIALOG);
|
||||
startActivity(in);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
dialog.cancel();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btn_cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
dialog.cancel();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Create custom adapter object ( see below CustomAdapter.java )
|
||||
CustomAdapter adapter = new CustomAdapter(CreateSelfActivity.this, R.layout.custom_spinner_item, sub_category_list);
|
||||
// Set adapter to spinner
|
||||
spinner_sub_category.setAdapter(adapter);
|
||||
|
||||
final ArrayList<String> no_of_rows = new ArrayList<>();
|
||||
no_of_rows.add(getString(R.string.select));
|
||||
for (int i = 1; i < 9; i++) {
|
||||
no_of_rows.add(i + "");
|
||||
}
|
||||
CustomSpinnerAdapter skuadapter = new CustomSpinnerAdapter(CreateSelfActivity.this, R.layout.custom_spinner_item, no_of_rows);
|
||||
spinner_sku.setAdapter(skuadapter);
|
||||
|
||||
|
||||
spinner_sub_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
if (position != 0) {
|
||||
brand_selected = sub_category_list.get(position);
|
||||
} else {
|
||||
brand_selected = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
spinner_sku.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
if (position != 0) {
|
||||
number_of_rows = Integer.parseInt(no_of_rows.get(position));
|
||||
} else {
|
||||
number_of_rows = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
public class CustomSpinnerAdapter extends ArrayAdapter<String> {
|
||||
|
||||
String tempValues = null;
|
||||
LayoutInflater inflater;
|
||||
private Activity activity;
|
||||
private ArrayList data;
|
||||
|
||||
/*************
|
||||
* CustomAdapter Constructor
|
||||
*****************/
|
||||
public CustomSpinnerAdapter(
|
||||
CreateSelfActivity activitySpinner,
|
||||
int textViewResourceId,
|
||||
ArrayList objects
|
||||
|
||||
) {
|
||||
super(activitySpinner, textViewResourceId, objects);
|
||||
|
||||
/********** Take passed values **********/
|
||||
activity = activitySpinner;
|
||||
data = objects;
|
||||
/*********** Layout inflator to call external xml layout () **********************/
|
||||
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
// This funtion called for each row ( Called data.size() times )
|
||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
/********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
|
||||
View row = inflater.inflate(R.layout.custom_spinner_item, parent, false);
|
||||
|
||||
/***** Get each Model object from Arraylist ********/
|
||||
tempValues = null;
|
||||
tempValues = (String) data.get(position);
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.tv_text);
|
||||
|
||||
if (position == 0) {
|
||||
|
||||
// Default selected Spinner item
|
||||
label.setText(getString(R.string.select));
|
||||
//sub.setText("");
|
||||
} else {
|
||||
// Set values for spinner each row
|
||||
label.setText(tempValues);
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomAdapter extends ArrayAdapter<String> {
|
||||
|
||||
MSL_AvailabilityStockFacingGetterSetter tempValues = null;
|
||||
LayoutInflater inflater;
|
||||
private Activity activity;
|
||||
private ArrayList data;
|
||||
|
||||
/*************
|
||||
* CustomAdapter Constructor
|
||||
*****************/
|
||||
public CustomAdapter(
|
||||
CreateSelfActivity activitySpinner,
|
||||
int textViewResourceId,
|
||||
ArrayList objects
|
||||
|
||||
) {
|
||||
super(activitySpinner, textViewResourceId, objects);
|
||||
|
||||
/********** Take passed values **********/
|
||||
activity = activitySpinner;
|
||||
data = objects;
|
||||
/*********** Layout inflator to call external xml layout () **********************/
|
||||
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getCustomView(position, convertView, parent);
|
||||
}
|
||||
|
||||
// This funtion called for each row ( Called data.size() times )
|
||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
/********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
|
||||
View row = inflater.inflate(R.layout.custom_spinner_item, parent, false);
|
||||
|
||||
/***** Get each Model object from Arraylist ********/
|
||||
tempValues = null;
|
||||
tempValues = (MSL_AvailabilityStockFacingGetterSetter) data.get(position);
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.tv_text);
|
||||
|
||||
if (position == 0) {
|
||||
|
||||
// Default selected Spinner item
|
||||
label.setText(getString(R.string.select));
|
||||
//sub.setText("");
|
||||
} else {
|
||||
// Set values for spinner each row
|
||||
label.setText(tempValues.getSub_category());
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
/* android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(CreateSelfActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
//Adapte sub category
|
||||
|
||||
public class SubcategoryAdapter extends RecyclerView.Adapter<SubcategoryAdapter.ViewHolder> {
|
||||
|
||||
private ArrayList<MSL_AvailabilityStockFacingGetterSetter> list;
|
||||
|
||||
public SubcategoryAdapter(ArrayList<MSL_AvailabilityStockFacingGetterSetter> skuList) {
|
||||
list = skuList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubcategoryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.sub_category_item_list, parent, false);
|
||||
return new SubcategoryAdapter.ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final SubcategoryAdapter.ViewHolder holder, final int position) {
|
||||
|
||||
holder.tv_sub_category.setText(list.get(position).getSub_category());
|
||||
|
||||
holder.parentLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent in = new Intent(context, NoCameraActivity.class);
|
||||
in.putExtra("categoryName", categoryName);
|
||||
in.putExtra("categoryId", categoryId);
|
||||
in.putExtra(CommonString.KEY_NUMBER_OF_ROWS, 0);
|
||||
in.putExtra(CommonString.KEY_SUB_CATEGORY, list.get(position));
|
||||
in.putExtra(CommonString.KEY_FROM, FROM_CLICK);
|
||||
startActivity(in);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final LinearLayout parentLayout;
|
||||
public final TextView tv_sub_category;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
|
||||
mView = view;
|
||||
tv_sub_category = (TextView) mView.findViewById(R.id.tv_sub_category);
|
||||
parentLayout = (LinearLayout) mView.findViewById(R.id.linear_parent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,376 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.upload.UploadActivity;
|
||||
import cpm.com.gskmtorange.upload.UploadImageWithRetrofit;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.DeliveryCallsGetterSetter;
|
||||
|
||||
public class DeliveryCallActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
private Context context;
|
||||
private SharedPreferences preferences;
|
||||
private GSKOrangeDB database;
|
||||
String visit_date, userId;
|
||||
ArrayList<DeliveryCallsGetterSetter> deliveryCallsList;
|
||||
RecyclerView recyclerView;
|
||||
DeliveryAdapter deliveryAdapter;
|
||||
FloatingActionButton fab_upload, fab;
|
||||
Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_delivery_call);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
recyclerView = (RecyclerView) findViewById(R.id.rec_delivery_calls);
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab_upload = (FloatingActionButton) findViewById(R.id.fab_upload);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
userId = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
database = new GSKOrangeDB(this);
|
||||
database.open();
|
||||
|
||||
fab.setOnClickListener(this);
|
||||
fab_upload.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
int id = v.getId();
|
||||
|
||||
switch (id) {
|
||||
|
||||
case R.id.fab_upload:
|
||||
|
||||
new UploadTask().execute();
|
||||
break;
|
||||
|
||||
case R.id.fab:
|
||||
|
||||
if (isCheckedIn()) {
|
||||
Snackbar.make(recyclerView, getString(R.string.title_store_list_checkout_current), Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
|
||||
Intent in = new Intent(context, DeliveryCallAddStoreActivity.class);
|
||||
startActivity(in);
|
||||
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class DeliveryAdapter extends RecyclerView.Adapter<DeliveryAdapter.MyViewHolder> {
|
||||
|
||||
private LayoutInflater inflator;
|
||||
|
||||
List<DeliveryCallsGetterSetter> data = Collections.emptyList();
|
||||
|
||||
public DeliveryAdapter(Context context, List<DeliveryCallsGetterSetter> data) {
|
||||
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeliveryAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = inflator.inflate(R.layout.delivery_calls_item, parent, false);
|
||||
|
||||
DeliveryAdapter.MyViewHolder holder = new DeliveryAdapter.MyViewHolder(view);
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(DeliveryAdapter.MyViewHolder holder, int position) {
|
||||
final DeliveryCallsGetterSetter current = data.get(position);
|
||||
holder.tv_store_name.setText(current.getSTORE_NAME());
|
||||
holder.tv_store_address.setText(current.getADDRESS());
|
||||
|
||||
if (current.getUPLOAD_STATUS().equals(CommonString.KEY_CHECK_IN)) {
|
||||
holder.imageview.setVisibility(View.INVISIBLE);
|
||||
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.green));
|
||||
} else if (current.getUPLOAD_STATUS().equals(CommonString.KEY_U)) {
|
||||
holder.imageview.setVisibility(View.VISIBLE);
|
||||
holder.imageview.setBackgroundResource(R.mipmap.tick);
|
||||
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.colorOrange));
|
||||
} else if (current.getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
|
||||
holder.imageview.setVisibility(View.VISIBLE);
|
||||
holder.imageview.setBackgroundResource(R.mipmap.exclamation);
|
||||
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.colorOrange));
|
||||
} else {
|
||||
holder.imageview.setVisibility(View.INVISIBLE);
|
||||
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.colorOrange));
|
||||
}
|
||||
|
||||
holder.cardView.setOnClickListener(v -> {
|
||||
switch (current.getUPLOAD_STATUS()) {
|
||||
case CommonString.KEY_CHECK_IN:
|
||||
Intent in = new Intent(context, DeliveryCallAddStoreActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_ID, current);
|
||||
in.putExtra(CommonString.KEY_STORE_FLAG, false);
|
||||
startActivity(in);
|
||||
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
break;
|
||||
case CommonString.KEY_U:
|
||||
Snackbar.make(v, R.string.title_store_list_activity_store_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
break;
|
||||
case CommonString.KEY_C:
|
||||
Snackbar.make(v, R.string.title_store_list_activity_store_already_checkout, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return deliveryCallsList.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView tv_store_name, tv_store_address;
|
||||
CardView cardView;
|
||||
ImageView imageview;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
tv_store_name = (TextView) itemView.findViewById(R.id.tv_store_name);
|
||||
tv_store_address = (TextView) itemView.findViewById(R.id.tv_store_address);
|
||||
cardView = (CardView) itemView.findViewById(R.id.card_view);
|
||||
imageview = (ImageView) itemView.findViewById(R.id.delivery_ico);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getString(R.string.delivery_call));
|
||||
deliveryCallsList = database.getDeliveryCallsData(visit_date);
|
||||
if (!deliveryCallsList.isEmpty()) {
|
||||
deliveryAdapter = new DeliveryAdapter(context, deliveryCallsList);
|
||||
recyclerView.setAdapter(deliveryAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
if (isCheckedIn()) {
|
||||
fab_upload.hide();//setVisibility(View.GONE);
|
||||
} else if (isUploadAble()) {
|
||||
fab_upload.show();//setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
Object result = "";
|
||||
|
||||
class Data {
|
||||
int value;
|
||||
String name;
|
||||
}
|
||||
|
||||
class UploadTask extends AsyncTask<Void, Data, String> {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
dialog = new Dialog(DeliveryCallActivity.this);
|
||||
dialog.setContentView(R.layout.custom);
|
||||
dialog.setTitle(getString(R.string.uploaddata));
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
((TextView) dialog.findViewById(R.id.tv_title)).setText(getString(R.string.uploaddata));
|
||||
}
|
||||
|
||||
@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 String doInBackground(Void... voids) {
|
||||
try {
|
||||
Data data = new Data();
|
||||
ArrayList<DeliveryCallsGetterSetter> _deliveryCallsList = database.getDeliveryCallsData(null);
|
||||
for (int i = 0; i < _deliveryCallsList.size(); i++) {
|
||||
if (_deliveryCallsList.get(i).getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
|
||||
data.value = 50;
|
||||
data.name = getString(R.string.delivery_call);
|
||||
publishProgress(data);
|
||||
String store_name = URLEncoder.encode(_deliveryCallsList.get(i).getSTORE_NAME(), "utf-8");
|
||||
String store_address = URLEncoder.encode(_deliveryCallsList.get(i).getADDRESS(), "utf-8");
|
||||
String onXML = "[DELIVERY_CALLS_DATA]"
|
||||
+ "[USER_ID]" + userId + "[/USER_ID]"
|
||||
+ "[VISIT_DATE]" + _deliveryCallsList.get(i).getVISIT_DATE() + "[/VISIT_DATE]"
|
||||
+ "[STORE_NAME]" + store_name + "[/STORE_NAME]"
|
||||
+ "[STORE_ADDRESS]" + store_address + "[/STORE_ADDRESS]"
|
||||
+ "[IN_TIME]" + _deliveryCallsList.get(i).getIn_time() + "[/IN_TIME]"
|
||||
+ "[OUT_TIME]" + _deliveryCallsList.get(i).getOut_time() + "[/OUT_TIME]"
|
||||
+ "[IN_TIME_IMAGE]" + _deliveryCallsList.get(i).getIN_TIME_IMAGE() + "[/IN_TIME_IMAGE]"
|
||||
+ "[OUT_TIME_IMAGE]" + _deliveryCallsList.get(i).getOUT_TIME_IMAGE() + "[/OUT_TIME_IMAGE]"
|
||||
+ "[LATITUDE]" + _deliveryCallsList.get(i).getLATITUDE() + "[/LATITUDE]"
|
||||
+ "[LONGITUDE]" + _deliveryCallsList.get(i).getLONGITUDE() + "[/LONGITUDE]"
|
||||
+ "[/DELIVERY_CALLS_DATA]";
|
||||
|
||||
final String delivery_xml = "[DATA]" + onXML + "[/DATA]";
|
||||
|
||||
SoapObject request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_UPLOAD_STOCK_XML_DATA);
|
||||
request.addProperty("XMLDATA", delivery_xml);
|
||||
request.addProperty("KEYS", "DELIVERY_CALLS");
|
||||
request.addProperty("USERNAME", userId);
|
||||
request.addProperty("MID", 0);
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION + CommonString.METHOD_UPLOAD_STOCK_XML_DATA, envelope);
|
||||
result = envelope.getResponse();
|
||||
if (!result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
return CommonString.METHOD_UPLOAD_STOCK_XML_DATA;
|
||||
} else {
|
||||
database.open();
|
||||
database.updateDeliveryCallsUploadStatus(_deliveryCallsList.get(i).getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.fillInStackTrace();
|
||||
} catch (XmlPullParserException e) {
|
||||
e.fillInStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
dialog.dismiss();
|
||||
if (result.contains(CommonString.KEY_SUCCESS)) {
|
||||
//db.deleteAllTables();
|
||||
File f = new File(CommonString.getImagesFolder(context));
|
||||
File fileAll[] = f.listFiles();
|
||||
ArrayList<String> file_list = new ArrayList<>();
|
||||
for (int i = 0; i < fileAll.length; i++) {
|
||||
String name = fileAll[i].getName();
|
||||
if (name.contains("DeliveryCalls")) {
|
||||
file_list.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
UploadImageWithRetrofit.uploadedFiles = 0;
|
||||
UploadImageWithRetrofit.totalFiles = file_list.size();
|
||||
UploadImageWithRetrofit uploadImg = new UploadImageWithRetrofit(visit_date, userId, DeliveryCallActivity.this);
|
||||
uploadImg.UploadDeliveryImageRecursive(DeliveryCallActivity.this, file_list, 0);
|
||||
} else {
|
||||
showAlert(getString(R.string.error) + result.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showAlert(String str) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(DeliveryCallActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
||||
finish();
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
boolean isCheckedIn() {
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < deliveryCallsList.size(); i++) {
|
||||
if (deliveryCallsList.get(i).getUPLOAD_STATUS().equals(CommonString.KEY_CHECK_IN)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
boolean isUploadAble() {
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < deliveryCallsList.size(); i++) {
|
||||
if (deliveryCallsList.get(i).getUPLOAD_STATUS().equals(CommonString.KEY_C)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
+567
@@ -0,0 +1,567 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
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.ResultCallback;
|
||||
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.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.DeliveryCallsGetterSetter;
|
||||
|
||||
public class DeliveryCallAddStoreActivity extends AppCompatActivity implements View.OnClickListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
||||
|
||||
EditText et_customer, et_address;
|
||||
ImageView img_checkin, img_checkout;
|
||||
String name, address, error_msg, img_checkin_path = "", img_checkout_path = "";
|
||||
boolean checkin_flag = true;
|
||||
protected String _pathforcheck = "", _path, str, visit_date, in_time, out_time;
|
||||
private SharedPreferences preferences;
|
||||
Uri outputFileUri;
|
||||
String gallery_package = "";
|
||||
private GSKOrangeDB database;
|
||||
DeliveryCallsGetterSetter deliveryCallsData;
|
||||
|
||||
LocationManager locationManager;
|
||||
boolean enabled;
|
||||
private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000;
|
||||
|
||||
private LocationRequest mLocationRequest;
|
||||
private static int UPDATE_INTERVAL = 500; // 5 sec
|
||||
private static int FATEST_INTERVAL = 100; // 1 sec
|
||||
private static int DISPLACEMENT = 5; // 10 meters
|
||||
private static final int REQUEST_LOCATION = 1;
|
||||
private Location mLastLocation;
|
||||
|
||||
double lat = 0.0, lon = 0.0;
|
||||
GoogleApiClient mGoogleApiClient;
|
||||
private static final String TAG = DeliveryCallAddStoreActivity.class.getSimpleName();
|
||||
Context context;
|
||||
Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_delivery_call_add_store);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
database = new GSKOrangeDB(this);
|
||||
database.open();
|
||||
|
||||
context = this;
|
||||
|
||||
et_customer = findViewById(R.id.et_customer_name);
|
||||
et_address = findViewById(R.id.et_address);
|
||||
img_checkin = findViewById(R.id.img_checkin);
|
||||
img_checkout = findViewById(R.id.img_checkout);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
checkin_flag = getIntent().getBooleanExtra(CommonString.KEY_STORE_FLAG, true);
|
||||
deliveryCallsData = (DeliveryCallsGetterSetter) getIntent().getSerializableExtra(CommonString.KEY_STORE_ID);
|
||||
|
||||
if (checkin_flag) {
|
||||
img_checkin.setOnClickListener(this);
|
||||
} else {
|
||||
et_customer.setText(deliveryCallsData.getSTORE_NAME());
|
||||
et_address.setText(deliveryCallsData.getADDRESS());
|
||||
et_customer.setEnabled(false);
|
||||
et_address.setEnabled(false);
|
||||
img_checkin.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
|
||||
img_checkout.setOnClickListener(this);
|
||||
}
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isValid()) {
|
||||
|
||||
if (checkin_flag) {
|
||||
|
||||
if (lat == 0.0 || lon == 0.0) {
|
||||
|
||||
} else {
|
||||
DeliveryCallsGetterSetter deliveryCallsGetterSetter = new DeliveryCallsGetterSetter();
|
||||
deliveryCallsGetterSetter.setSTORE_NAME(name);
|
||||
deliveryCallsGetterSetter.setADDRESS(address);
|
||||
deliveryCallsGetterSetter.setIN_TIME_IMAGE(img_checkin_path);
|
||||
deliveryCallsGetterSetter.setOUT_TIME_IMAGE(img_checkout_path);
|
||||
deliveryCallsGetterSetter.setUPLOAD_STATUS(CommonString.KEY_CHECK_IN);
|
||||
deliveryCallsGetterSetter.setVISIT_DATE(visit_date);
|
||||
deliveryCallsGetterSetter.setIn_time(in_time);
|
||||
deliveryCallsGetterSetter.setLATITUDE(lat);
|
||||
deliveryCallsGetterSetter.setLONGITUDE(lon);
|
||||
|
||||
database.InsertDeliveryCalls(deliveryCallsGetterSetter);
|
||||
}
|
||||
} else {
|
||||
|
||||
deliveryCallsData.setOut_time(out_time);
|
||||
database.updateDeliveryCallsOut(deliveryCallsData, CommonString.KEY_C, img_checkout_path);
|
||||
}
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
} else {
|
||||
Snackbar.make(et_customer, error_msg, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
str = CommonString.getImagesFolder(context);
|
||||
|
||||
if (checkPlayServices()) {
|
||||
|
||||
// Building the GoogleApi client
|
||||
buildGoogleApiClient();
|
||||
|
||||
createLocationRequest();
|
||||
}
|
||||
|
||||
/* locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
|
||||
if (!enabled) {
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
|
||||
DeliveryCallAddStoreActivity.this);
|
||||
|
||||
// Setting Dialog Title
|
||||
alertDialog.setTitle(getResources().getString(R.string.gps));
|
||||
|
||||
// Setting Dialog Message
|
||||
alertDialog.setMessage(getResources().getString(R.string.gpsebale));
|
||||
|
||||
// Setting Positive "Yes" Button
|
||||
alertDialog.setPositiveButton(getResources().getString(R.string.yes),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
Intent intent = new Intent(
|
||||
Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
// Setting Negative "NO" Button
|
||||
alertDialog.setNegativeButton(getResources().getString(R.string.no),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// Write your code here to invoke NO event
|
||||
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
// Showing Alert Message
|
||||
alertDialog.show();
|
||||
|
||||
}*/
|
||||
|
||||
// Create an instance of GoogleAPIClient.
|
||||
if (mGoogleApiClient == null) {
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(this)
|
||||
.addConnectionCallbacks(this)
|
||||
.addOnConnectionFailedListener(this)
|
||||
.addApi(LocationServices.API)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getString(R.string.delivery_call));
|
||||
|
||||
checkgpsEnableDevice();
|
||||
// Resuming the periodic location updates
|
||||
if (mGoogleApiClient.isConnected()) {
|
||||
startLocationUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkgpsEnableDevice() {
|
||||
boolean flag = true;
|
||||
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();
|
||||
flag = false;
|
||||
} else if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(context)) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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(new ResultCallback<LocationSettingsResult>() {
|
||||
@Override
|
||||
public void onResult(LocationSettingsResult result) {
|
||||
final Status status = result.getStatus();
|
||||
switch (status.getStatusCode()) {
|
||||
case 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.
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isValid() {
|
||||
boolean flag = true;
|
||||
|
||||
name = et_customer.getText().toString().replaceAll("[&^<>{}'$]", " ");
|
||||
address = et_address.getText().toString().replaceAll("[&^<>{}'$]", " ");
|
||||
|
||||
if (name.equals("")) {
|
||||
error_msg = getString(R.string.please_fill) + " " + getString(R.string.customer_store_name);
|
||||
flag = false;
|
||||
} else if (address.equals("")) {
|
||||
error_msg = getString(R.string.please_fill) + " " + getString(R.string.address);
|
||||
flag = false;
|
||||
} else if (checkin_flag) {
|
||||
if (img_checkin_path.equals("")) {
|
||||
error_msg = getString(R.string.please_click) + " " + getString(R.string.intime_image).toLowerCase();
|
||||
flag = false;
|
||||
}
|
||||
} else if (img_checkout_path.equals("")) {
|
||||
error_msg = getString(R.string.please_click) + " " + getString(R.string.outtime_image).toLowerCase();
|
||||
flag = false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.img_checkin:
|
||||
|
||||
in_time = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
|
||||
_pathforcheck = "DeliveryCalls" + visit_date.replace("/", "") + "InTime" + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
|
||||
startCameraActivity(0);
|
||||
break;
|
||||
|
||||
case R.id.img_checkout:
|
||||
|
||||
out_time = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
|
||||
_pathforcheck = "DeliveryCalls" + visit_date.replace("/", "") + "OutTime" + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
|
||||
startCameraActivity(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void startCameraActivity(int request_code) {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") || packag.equalsIgnoreCase("الاستوديو")) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera") || packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, request_code);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, request_code);
|
||||
|
||||
} catch (Exception e) {
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
// Crashlytics.logException(new Exception(e.getCause()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingSuperCall")
|
||||
@SuppressWarnings("deprecation")
|
||||
@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(str + _pathforcheck).exists()) {
|
||||
|
||||
if (requestCode == 0) {
|
||||
img_checkin.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
|
||||
img_checkin_path = _pathforcheck;
|
||||
} else {
|
||||
img_checkout.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
|
||||
img_checkout_path = _pathforcheck;
|
||||
}
|
||||
_pathforcheck = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkPlayServices() {
|
||||
int resultCode = GooglePlayServicesUtil
|
||||
.isGooglePlayServicesAvailable(this);
|
||||
if (resultCode != ConnectionResult.SUCCESS) {
|
||||
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
|
||||
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
|
||||
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() {
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(this)
|
||||
.addConnectionCallbacks(this)
|
||||
.addOnConnectionFailedListener(this)
|
||||
.addApi(LocationServices.API).build();
|
||||
}
|
||||
|
||||
|
||||
protected void createLocationRequest() {
|
||||
mLocationRequest = new LocationRequest();
|
||||
mLocationRequest.setInterval(UPDATE_INTERVAL);
|
||||
mLocationRequest.setFastestInterval(FATEST_INTERVAL);
|
||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
|
||||
}
|
||||
|
||||
protected void startLocationUpdates() {
|
||||
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stopping location updates
|
||||
*/
|
||||
protected void stopLocationUpdates() {
|
||||
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(Bundle bundle) {
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(this, 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(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (mLastLocation != null) {
|
||||
lat = mLastLocation.getLatitude();
|
||||
lon = mLastLocation.getLongitude();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (mRequestingLocationUpdates) {
|
||||
startLocationUpdates();
|
||||
// }
|
||||
|
||||
// startLocationUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuspended(int i) {
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(ConnectionResult connectionResult) {
|
||||
Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + connectionResult.getErrorCode());
|
||||
}
|
||||
|
||||
|
||||
protected void onStart() {
|
||||
super.onStart();// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
//client.connect();
|
||||
if (mGoogleApiClient != null) {
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
// AppIndex.AppIndexApi.start(client, getIndexApiAction());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
// AppIndex.AppIndexApi.end(client, getIndexApiAction());
|
||||
/* if (mGoogleApiClient.isConnected()) {
|
||||
mGoogleApiClient.disconnect();
|
||||
}*/
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
//client.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
//stopLocationUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
|
||||
public class First2Fragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_first2, container, false);
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(First2Fragment.this)
|
||||
.navigate(R.id.action_First2Fragment_to_Second2Fragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
|
||||
public class FirstFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_first, container, false);
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(FirstFragment.this)
|
||||
.navigate(R.id.action_FirstFragment_to_SecondFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.messgae.AlertMessage;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.JourneyPlanGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlHandlers.XMLHandlers;
|
||||
|
||||
public class FutureJCPActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
FloatingActionButton fab;
|
||||
//ImageButton calenderBtn;
|
||||
TextView txt_date;
|
||||
RecyclerView futureJcpList;
|
||||
Calendar c;
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
SharedPreferences preferences;
|
||||
String _UserId;
|
||||
ProgressDialog progressDialog;
|
||||
int eventType;
|
||||
JourneyPlanGetterSetter journeyPlanPreviousGetterSetter;
|
||||
String culture_id;
|
||||
Context context;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_future_jcp);
|
||||
declaration();
|
||||
|
||||
//calenderBtn.setOnClickListener(this);
|
||||
fab.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iconCalender:
|
||||
c = Calendar.getInstance();
|
||||
year = c.get(Calendar.YEAR);
|
||||
month = c.get(Calendar.MONTH);
|
||||
day = c.get(Calendar.DAY_OF_MONTH);
|
||||
showDatePickerDialog(year, month, day);
|
||||
break;
|
||||
case R.id.fab:
|
||||
Snackbar.make(v, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void showDatePickerDialog(int year, int month, int day) {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, pickerListener, year, month, day);
|
||||
// ((ViewGroup) datePickerDialog.getDatePicker()).findViewById(Resources.getSystem().getIdentifier("year", "id", "android")).setVisibility(View.GONE);
|
||||
//datePickerDialog.findViewById(Resources.getSystem().getIdentifier("year", "id", "android")).setVisibility(View.GONE);
|
||||
datePickerDialog.setTitle("");
|
||||
datePickerDialog.show();
|
||||
}
|
||||
|
||||
private DatePickerDialog.OnDateSetListener pickerListener = new DatePickerDialog.OnDateSetListener() {
|
||||
|
||||
// when dialog box is closed, below method will be called.
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int selectedYear,
|
||||
int selectedMonth, int selectedDay) {
|
||||
|
||||
futureJcpList.removeAllViewsInLayout();
|
||||
futureJcpList.invalidate();
|
||||
year = selectedYear;
|
||||
month = selectedMonth + 1;
|
||||
day = selectedDay;
|
||||
|
||||
String day_str = String.valueOf(day);
|
||||
day_str = "00" + day_str;
|
||||
day_str = day_str.substring(day_str.length() - 2, day_str.length());
|
||||
|
||||
|
||||
String month_str = String.valueOf(month);
|
||||
month_str = "00" + month_str;
|
||||
month_str = month_str.substring(month_str.length() - 2, month_str.length());
|
||||
|
||||
String yeat_str = String.valueOf(year);
|
||||
|
||||
txt_date.setText(new StringBuilder().append(month_str).append("/").append(day_str).append("/").append(yeat_str)
|
||||
);
|
||||
new Task().execute(txt_date.getText().toString());
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void declaration() {
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
//calenderBtn = (ImageButton) findViewById(R.id.iconCalender);
|
||||
txt_date = (TextView) findViewById(R.id.txt_date);
|
||||
futureJcpList = (RecyclerView) findViewById(R.id.futureJcpList);
|
||||
context = this;
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
_UserId = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
culture_id = preferences.getString(CommonString.KEY_CULTURE_ID, "");
|
||||
progressDialog = new ProgressDialog(FutureJCPActivity.this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
c = Calendar.getInstance();
|
||||
year = c.get(Calendar.YEAR);
|
||||
month = c.get(Calendar.MONTH);
|
||||
day = c.get(Calendar.DAY_OF_MONTH);
|
||||
showDatePickerDialog(year, month, day);
|
||||
}
|
||||
|
||||
// AsyncTask asyncTask = new AsyncTask<String, String, String>() {
|
||||
class Task extends AsyncTask<String, String, String> {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog.setTitle("Please wait");
|
||||
progressDialog.setMessage("Fetching Data..");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... params) {
|
||||
XmlPullParserFactory factory = null;
|
||||
try {
|
||||
factory = XmlPullParserFactory
|
||||
.newInstance();
|
||||
|
||||
factory.setNamespaceAware(true);
|
||||
XmlPullParser xpp = factory.newPullParser();
|
||||
SoapSerializationEnvelope envelope;
|
||||
HttpTransportSE androidHttpTransport;
|
||||
SoapObject request;
|
||||
|
||||
// Brand Master data
|
||||
request = new SoapObject(CommonString.NAMESPACE,
|
||||
CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", _UserId);
|
||||
request.addProperty("Type", "JOURNEY_SEARCH:" + params[0]);
|
||||
request.addProperty("cultureid", culture_id);
|
||||
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
Log.d("requestdata",request.toString());
|
||||
|
||||
androidHttpTransport.call(
|
||||
CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
Object resultFuturedata = (Object) envelope.getResponse();
|
||||
|
||||
if (resultFuturedata.toString() != null) {
|
||||
xpp.setInput(new StringReader(resultFuturedata.toString()));
|
||||
xpp.next();
|
||||
eventType = xpp.getEventType();
|
||||
journeyPlanPreviousGetterSetter = XMLHandlers.JCPXMLHandler(xpp, eventType);
|
||||
}
|
||||
return "Success";
|
||||
} catch (XmlPullParserException e) {
|
||||
e.printStackTrace();
|
||||
return "failure";
|
||||
} catch (SoapFault soapFault) {
|
||||
soapFault.printStackTrace();
|
||||
return "failure";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return getResources().getString(R.string.nonetwork);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "failure";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String o) {
|
||||
super.onPostExecute(o);
|
||||
progressDialog.dismiss();
|
||||
if (o.equalsIgnoreCase("Success")) {
|
||||
if (journeyPlanPreviousGetterSetter.getSTORE_ID().size() > 0) {
|
||||
|
||||
MyListAdapter adapter = new MyListAdapter(context, journeyPlanPreviousGetterSetter);
|
||||
futureJcpList.setLayoutManager(new LinearLayoutManager(context));
|
||||
futureJcpList.setAdapter(adapter);
|
||||
} else {
|
||||
|
||||
Snackbar.make(futureJcpList,R.string.no_route_plan_for_day,Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
|
||||
Snackbar.make(futureJcpList,o,Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.date_menu, menu);
|
||||
|
||||
// return true so that the menu pop up is opened
|
||||
return true;
|
||||
}
|
||||
|
||||
@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 == R.id.iconCalender){
|
||||
c = Calendar.getInstance();
|
||||
year = c.get(Calendar.YEAR);
|
||||
month = c.get(Calendar.MONTH);
|
||||
day = c.get(Calendar.DAY_OF_MONTH);
|
||||
showDatePickerDialog(year, month, day);
|
||||
|
||||
}else if (id == android.R.id.home) {
|
||||
|
||||
// NavUtils.navigateUpFromSameTask(this);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
class MyListAdapter extends RecyclerView.Adapter<MyListAdapter.ViewHolder> {
|
||||
LayoutInflater layoutInflater;
|
||||
JourneyPlanGetterSetter journeyPlanPreviousGetterSetter;
|
||||
|
||||
MyListAdapter(Context context, JourneyPlanGetterSetter journeyPlanPreviousGetterSetter) {
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
this.journeyPlanPreviousGetterSetter = journeyPlanPreviousGetterSetter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = layoutInflater.inflate(R.layout.item_future_jcp_list, parent, false);
|
||||
ViewHolder viewHolder = new ViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
if (holder != null) {
|
||||
holder.txt_store_cd.setText(journeyPlanPreviousGetterSetter.getSTORE_ID().get(position));
|
||||
holder.txt_keyacct.setText(journeyPlanPreviousGetterSetter.getKEYACCOUNT().get(position));
|
||||
holder.txt_storename.setText(journeyPlanPreviousGetterSetter.getSTORE_NAME().get(position));
|
||||
holder.txt_city.setText(journeyPlanPreviousGetterSetter.getCITY().get(position));
|
||||
holder.txt_storetype.setText(journeyPlanPreviousGetterSetter.getSTORETYPE().get(position));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return journeyPlanPreviousGetterSetter.getSTORE_ID().size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txt_store_cd, txt_keyacct, txt_storename, txt_city, txt_storetype;
|
||||
LinearLayout ll_itemfutureJCP;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
txt_store_cd = (TextView) view.findViewById(R.id.txt_store_cd);
|
||||
txt_keyacct = (TextView) view.findViewById(R.id.txt_keyacct);
|
||||
txt_storename = (TextView) view.findViewById(R.id.txt_storename);
|
||||
txt_city = (TextView) view.findViewById(R.id.txt_city);
|
||||
txt_storetype = (TextView) view.findViewById(R.id.txt_storetype);
|
||||
ll_itemfutureJCP = (LinearLayout) view.findViewById(R.id.ll_itemfutureJCP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.ChatMessageGetterSetter;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.gsk_dailyentry.CategoryListActivity;
|
||||
import cpm.com.gskmtorange.gsk_dailyentry.CategoryWisePerformanceActivity;
|
||||
import cpm.com.gskmtorange.gsk_dailyentry.DailyDataMenuActivity;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.ChatMessageDownloadGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.TableBean;
|
||||
import cpm.com.gskmtorange.xmlHandlers.XMLHandlers;
|
||||
|
||||
public class MessageActivity extends AppCompatActivity {
|
||||
//ArrayList<MessageGetterSetter> messages;
|
||||
private Context context;
|
||||
String categoryName = "", categoryId;
|
||||
|
||||
MyRecyclerAdapter adapter;
|
||||
RecyclerView rec;
|
||||
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
private Data data;
|
||||
int eventType;
|
||||
|
||||
String userId, culture_id, store_id;
|
||||
private SharedPreferences preferences = null;
|
||||
|
||||
GSKOrangeDB db;
|
||||
ArrayList<ChatMessageGetterSetter> chatmessagelist = new ArrayList<>();
|
||||
Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_message);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
rec = (RecyclerView)findViewById(R.id.rec);
|
||||
|
||||
db = new GSKOrangeDB(MessageActivity.this);
|
||||
db.open();
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
userId = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
culture_id = preferences.getString(CommonString.KEY_CULTURE_ID, "");
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(MessageActivity.this, CategoryListActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
});
|
||||
|
||||
//messages = getMessages();
|
||||
|
||||
/* if(messages.size()>0){
|
||||
adapter = new MyRecyclerAdapter(getApplicationContext(), messages);
|
||||
rec.setAdapter(adapter);
|
||||
rec.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
toolbar.setTitle(getString(R.string.title_activity_message));
|
||||
new DowloadAsync(MessageActivity.this).execute();
|
||||
}
|
||||
|
||||
/*ArrayList<MessageGetterSetter> getMessages(){
|
||||
ArrayList<MessageGetterSetter> messages = new ArrayList<>();
|
||||
|
||||
for(int i=0; i<5;i++){
|
||||
MessageGetterSetter msg = new MessageGetterSetter();
|
||||
|
||||
msg.setMessage("Store data need to be filled");
|
||||
msg.setFrom("Superviser"+(i+1));
|
||||
msg.setDate("11:20:32 11/06/2018");
|
||||
msg.setLatest_msg("Working on it");
|
||||
|
||||
messages.add(msg);
|
||||
}
|
||||
return messages;
|
||||
}*/
|
||||
|
||||
/*class MessageGetterSetter{
|
||||
|
||||
String message="", from, date, latest_msg;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getLatest_msg() {
|
||||
return latest_msg;
|
||||
}
|
||||
|
||||
public void setLatest_msg(String latest_msg) {
|
||||
this.latest_msg = latest_msg;
|
||||
}
|
||||
}
|
||||
*/
|
||||
class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.MyViewHolder> {
|
||||
|
||||
private LayoutInflater inflator;
|
||||
|
||||
ArrayList<ChatMessageGetterSetter> data = new ArrayList<>();
|
||||
|
||||
public MyRecyclerAdapter(Context context, ArrayList<ChatMessageGetterSetter> data) {
|
||||
|
||||
inflator = LayoutInflater.from(context);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = inflator.inflate(R.layout.message_topic_item, parent, false);
|
||||
|
||||
MyRecyclerAdapter.MyViewHolder holder = new MyRecyclerAdapter.MyViewHolder(view);
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MyViewHolder holder, final int position) {
|
||||
|
||||
//final MappingPlanogramCountrywiseGetterSetter current = data.get(position);
|
||||
|
||||
final String msg_topic_str = data.get(position).getMESSAGE();
|
||||
//final String latest_msg_str = data.get(position).getRECEIVER();
|
||||
final String date_time_str = data.get(position).getMESSAGEDATE();
|
||||
final String msg_from_str = data.get(position).getSENDER();
|
||||
|
||||
holder.msg_topic.setText(msg_topic_str);
|
||||
//holder.latest_msg.setText(latest_msg_str);
|
||||
holder.date_time.setText(date_time_str);
|
||||
holder.msg_from.setText(msg_from_str);
|
||||
//holder.detail.setText(current.getDocument_descriiption().get(0));
|
||||
|
||||
holder.parent_layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent in = new Intent(MessageActivity.this, ConversationActivity.class);
|
||||
in.putExtra(CommonString.KEY_CHAT_ID, data.get(position).getCHAT_ID());
|
||||
in.putExtra(CommonString.KEY_MESSAGE, data.get(position).getMESSAGE());
|
||||
startActivity(in);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return chatmessagelist.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView msg_topic, latest_msg, date_time, msg_from;
|
||||
LinearLayout parent_layout;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
msg_topic = (TextView) itemView.findViewById(R.id.tv_msg_topic);
|
||||
latest_msg = (TextView) itemView.findViewById(R.id.tv_latest_msg);
|
||||
date_time = (TextView) itemView.findViewById(R.id.tv_date_time);
|
||||
msg_from = (TextView) itemView.findViewById(R.id.tv_from);
|
||||
|
||||
parent_layout = (LinearLayout) itemView.findViewById(R.id.layout_parent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//region Download doc
|
||||
private class DowloadAsync extends AsyncTask<Void, Data, String> {
|
||||
|
||||
private Context context;
|
||||
|
||||
DowloadAsync(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
||||
dialog = new Dialog(MessageActivity.this);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.custom);
|
||||
//dialog.setTitle("Download Files");
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
|
||||
data = new Data();
|
||||
String resultHttp = "";
|
||||
boolean flag = true;
|
||||
// JCP
|
||||
|
||||
try {
|
||||
|
||||
XmlPullParserFactory factory = null;
|
||||
factory = XmlPullParserFactory
|
||||
.newInstance();
|
||||
|
||||
factory.setNamespaceAware(true);
|
||||
XmlPullParser xpp = factory.newPullParser();
|
||||
|
||||
SoapObject request = new SoapObject(CommonString.NAMESPACE,
|
||||
CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "CHAT_MESSAGE");
|
||||
request.addProperty("cultureid", culture_id);
|
||||
|
||||
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
HttpTransportSE androidHttpTransport = new HttpTransportSE(
|
||||
CommonString.URL);
|
||||
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL,
|
||||
envelope);
|
||||
Object result = (Object) envelope.getResponse();
|
||||
|
||||
if (result.toString() != null) {
|
||||
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
xpp.next();
|
||||
eventType = xpp.getEventType();
|
||||
|
||||
ChatMessageDownloadGetterSetter chatmsg = XMLHandlers.CHAT_MESSAGE_XMLHandler(xpp, eventType);
|
||||
|
||||
if (chatmsg.getSENDERID().size() > 0) {
|
||||
resultHttp = CommonString.KEY_SUCCESS;
|
||||
String document_Table = chatmsg.getTable_CHAT_MESSAGE();
|
||||
|
||||
db.createTable(document_Table);
|
||||
db.InserChatMessage(chatmsg);
|
||||
|
||||
} else {
|
||||
return "CHAT_MESSAGE";
|
||||
}
|
||||
|
||||
data.value = 10;
|
||||
data.name = "Message Data Downloading";
|
||||
|
||||
/* db.open();
|
||||
db.InsertMappingCountrywisePlanogram(document);*/
|
||||
|
||||
}
|
||||
|
||||
publishProgress(data);
|
||||
|
||||
} catch (XmlPullParserException e) {
|
||||
//Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
//Crashlytics.logException(e.getCause());
|
||||
// Crashlytics.logException(new Exception(e.getCause()));
|
||||
e.printStackTrace();
|
||||
resultHttp = getString(R.string.nonetwork);
|
||||
flag = false;
|
||||
} catch (SoapFault soapFault) {
|
||||
soapFault.printStackTrace();
|
||||
resultHttp = getString(R.string.nonetwork);
|
||||
flag = false;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
resultHttp = getString(R.string.nonetwork);
|
||||
flag = false;
|
||||
}
|
||||
catch ( Exception e){
|
||||
//Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
//Crashlytics.logException(e.getCause());
|
||||
//Crashlytics.logException(new Exception(e.getCause()));
|
||||
resultHttp = getString(R.string.nonetwork);
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if(flag)
|
||||
return CommonString.KEY_SUCCESS;
|
||||
else
|
||||
return resultHttp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
|
||||
dialog.cancel();
|
||||
|
||||
if (result.contains(CommonString.KEY_SUCCESS)) {
|
||||
|
||||
/* if(document.getPLANOGRAM_URL().size()>0){
|
||||
adapter = new PlanogramPDFActivity.MyRecyclerAdapter(getApplicationContext(), document);
|
||||
rec.setAdapter(adapter);
|
||||
rec.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
//Snackbar.make(fab, result, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
db.open();
|
||||
chatmessagelist = db.getChatMessageData(store_id);
|
||||
|
||||
if(chatmessagelist.size()>0){
|
||||
adapter = new MyRecyclerAdapter(context, chatmessagelist);
|
||||
rec.setAdapter(adapter);
|
||||
rec.setLayoutManager(new LinearLayoutManager(context));
|
||||
}
|
||||
|
||||
//finish();
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
class Data {
|
||||
int value;
|
||||
String name;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,915 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.StringReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.GetterSetter.CoverageBean;
|
||||
import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.FailureGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.NonWorkingReasonGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.NonWorkingSubReasonGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlHandlers.FailureXMLHandler;
|
||||
|
||||
|
||||
public class NonWorkingReason extends AppCompatActivity implements
|
||||
OnItemSelectedListener, OnClickListener {
|
||||
private Context context;
|
||||
ArrayList<NonWorkingReasonGetterSetter> reasondata = new ArrayList<NonWorkingReasonGetterSetter>();
|
||||
ArrayList<NonWorkingSubReasonGetterSetter> sub_reasondata = new ArrayList<>();
|
||||
private Spinner reasonspinner, subreason_spinner;
|
||||
private GSKOrangeDB database;
|
||||
String reasonname, reasonid, entry_allow, image, entry, reason_reamrk, intime, image_allow, remark_allow, remark_type, sub_reason_id="";
|
||||
Button save;
|
||||
boolean ResultFlag = true;
|
||||
private ArrayAdapter<CharSequence> reason_adapter, sub_reason_adapter;
|
||||
protected String _path, str,strflag;
|
||||
protected String _pathforcheck = "";
|
||||
private ArrayList<StoreBean> storedata = new ArrayList<StoreBean>();
|
||||
private String image1 = "";
|
||||
private ArrayList<CoverageBean> cdata = new ArrayList<CoverageBean>();
|
||||
protected boolean _taken;
|
||||
protected static final String PHOTO_TAKEN = "photo_taken";
|
||||
private SharedPreferences preferences;
|
||||
String _UserId, visit_date, store_id, username;
|
||||
protected boolean status = true;
|
||||
EditText text;
|
||||
AlertDialog alert;
|
||||
ImageButton camera;
|
||||
RelativeLayout reason_lay, rel_cam;
|
||||
String gallery_package = "";
|
||||
Uri outputFileUri;
|
||||
boolean leave_flag = false;
|
||||
ArrayList<CoverageBean> coverage = new ArrayList<CoverageBean>();
|
||||
ArrayList<StoreBean> storelist = new ArrayList<StoreBean>();
|
||||
//ArrayList<StoreBean> jcp;
|
||||
private Dialog dialog;
|
||||
private TextView percentage, message;
|
||||
private ProgressBar pb;
|
||||
private FailureGetterSetter failureGetterSetter = null;
|
||||
boolean nonflag=true;
|
||||
String store_flag_str,country_id, keyAccount_id, class_id, storeType_id;
|
||||
|
||||
TextView tv_remark;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nonworkingmainlayout);
|
||||
reasonspinner = (Spinner) findViewById(R.id.spinner_reason);
|
||||
camera = (ImageButton) findViewById(R.id.imgcam);
|
||||
save = (Button) findViewById(R.id.save);
|
||||
text = (EditText) findViewById(R.id.reasontxt);
|
||||
tv_remark = (TextView) findViewById(R.id.tv_remark);
|
||||
reason_lay = (RelativeLayout) findViewById(R.id.layout_reason);
|
||||
rel_cam = (RelativeLayout) findViewById(R.id.relimgcam);
|
||||
subreason_spinner = (Spinner) findViewById(R.id.spinner_sub_reason);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
context = this;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
store_flag_str = getIntent().getStringExtra(CommonString.KEY_STORE_FLAG);
|
||||
_UserId = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
|
||||
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
|
||||
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
|
||||
store_id = getIntent().getStringExtra(CommonString.KEY_STORE_ID);
|
||||
|
||||
database = new GSKOrangeDB(this);
|
||||
database.open();
|
||||
str = CommonString.getImagesFolder(context);
|
||||
|
||||
//storelist = database.getStoreData(visit_date,CommonString.KEY_JOURNEY_PLAN );
|
||||
|
||||
if(store_flag_str.equals(CommonString.FROM_JCP)){
|
||||
|
||||
storelist = database.getStoreData(visit_date,CommonString.KEY_JOURNEY_PLAN );
|
||||
}
|
||||
else if(store_flag_str.equals(CommonString.FROM_ADDITIONAL)){
|
||||
//Additional Journey Plan - Egypt
|
||||
storelist = database.getStoreData(visit_date,CommonString.KEY_JOURNEY_PLAN_ADDITIONAL);
|
||||
}else if(store_flag_str.equals(CommonString.FROM_PHARMA)){
|
||||
//Additional Journey Plan - Egypt
|
||||
|
||||
storelist = database.getStoreData(visit_date,CommonString.KEY_JOURNEY_PLAN_PHARMA);
|
||||
}else if(store_flag_str.equals(CommonString.FROM_ADDITIONAL_ADHOC)){
|
||||
//Additional Adhoc Journey Plan - Egypt
|
||||
storelist = database.getStoreData(visit_date,CommonString.KEY_ADHOC_JOURNEYPLAN_ADDITIONAL);
|
||||
}
|
||||
|
||||
coverage = database.getCoverageData(visit_date, CommonString.FROM_JCP);
|
||||
|
||||
for(int i=0;i<storelist.size();i++)
|
||||
{
|
||||
if(!storelist.get(i).getCHECKOUT_STATUS().equalsIgnoreCase("N") || !storelist.get(i).getUPLOAD_STATUS().equalsIgnoreCase("N")){
|
||||
|
||||
nonflag=true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
nonflag=false;
|
||||
}
|
||||
}
|
||||
|
||||
if (nonflag) {
|
||||
reasondata = database.getNonWorkingEntryAllowData();
|
||||
|
||||
} else {
|
||||
reasondata = database.getNonWorkingData();
|
||||
|
||||
}
|
||||
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
|
||||
camera.setOnClickListener(this);
|
||||
save.setOnClickListener(this);
|
||||
|
||||
reason_adapter = new ArrayAdapter<CharSequence>(this,
|
||||
android.R.layout.simple_spinner_item);
|
||||
|
||||
reason_adapter.add(getResources().getString(R.string.select_reason));
|
||||
|
||||
for (int i = 0; i < reasondata.size(); i++) {
|
||||
reason_adapter.add(reasondata.get(i).getREASON().get(0));
|
||||
}
|
||||
|
||||
reasonspinner.setAdapter(reason_adapter);
|
||||
|
||||
reason_adapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
reasonspinner.setOnItemSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
finish();
|
||||
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int position,
|
||||
long arg3) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
switch (arg0.getId()) {
|
||||
case R.id.spinner_reason:
|
||||
if (position != 0) {
|
||||
reasonname = reasondata.get(position - 1).getREASON().get(0);
|
||||
reasonid = reasondata.get(position - 1).getREASON_ID().get(0);
|
||||
entry_allow = reasondata.get(position - 1).getENTRY_ALLOW().get(0);
|
||||
|
||||
image_allow = reasondata.get(position - 1).getIMAGE_ALLOW().get(0);
|
||||
remark_allow = reasondata.get(position - 1).getREMARK_REQUIRED().get(0);
|
||||
remark_type = reasondata.get(position - 1).getREMARK_TYPE().get(0);
|
||||
|
||||
if (image_allow.equalsIgnoreCase("1")) {
|
||||
rel_cam.setVisibility(View.VISIBLE);
|
||||
image = "true";
|
||||
} else {
|
||||
rel_cam.setVisibility(View.GONE);
|
||||
image = "false";
|
||||
}
|
||||
//reason_reamrk = "true";
|
||||
if (remark_allow.equalsIgnoreCase("1")) {
|
||||
reason_lay.setVisibility(View.VISIBLE);
|
||||
if(remark_type.equalsIgnoreCase("Text")){
|
||||
text.setVisibility(View.VISIBLE);
|
||||
subreason_spinner.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
text.setVisibility(View.GONE);
|
||||
subreason_spinner.setVisibility(View.VISIBLE);
|
||||
|
||||
sub_reasondata = database.getNonWorkingSubReasonData(reasonid);
|
||||
|
||||
sub_reason_adapter = new ArrayAdapter<CharSequence>(this,
|
||||
android.R.layout.simple_spinner_item);
|
||||
|
||||
String select_str = getResources().getString(R.string.select_promo) + " " +reasondata.get(position - 1).getREMARK_LABEL().get(0);
|
||||
|
||||
sub_reason_adapter.add(select_str);
|
||||
|
||||
for (int i = 0; i < sub_reasondata.size(); i++) {
|
||||
sub_reason_adapter.add(sub_reasondata.get(i).getSUB_REASON().get(0));
|
||||
}
|
||||
|
||||
subreason_spinner.setAdapter(sub_reason_adapter);
|
||||
|
||||
sub_reason_adapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
subreason_spinner.setOnItemSelectedListener(this);
|
||||
}
|
||||
tv_remark.setText(reasondata.get(position - 1).getREMARK_LABEL().get(0));
|
||||
} else {
|
||||
reason_lay.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
reasonname = "";
|
||||
reasonid = "";
|
||||
reason_lay.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.spinner_sub_reason:
|
||||
|
||||
if (position != 0) {
|
||||
sub_reason_id = sub_reasondata.get(position-1).getSUB_REASON_ID().get(0);
|
||||
}
|
||||
else {
|
||||
sub_reason_id = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
protected void startCameraActivity() {
|
||||
try {
|
||||
|
||||
Log.i("MakeMachine", "startCameraActivity()");
|
||||
File file = new File(_path);
|
||||
outputFileUri = FileProvider.getUriForFile(context, "cpm.com.gskmtorange.fileprovider", file);
|
||||
|
||||
String defaultCameraPackage = "";
|
||||
final PackageManager packageManager = getPackageManager();
|
||||
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
for (int n = 0; n < list.size(); n++) {
|
||||
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
|
||||
Log.e("TAG", "package name : " + list.get(n).packageName);
|
||||
|
||||
//temp value in case camera is gallery app above jellybean
|
||||
String packag = list.get(n).loadLabel(packageManager).toString();
|
||||
if (packag.equalsIgnoreCase("Gallery") || packag.equalsIgnoreCase("Galeri") ||packag.equalsIgnoreCase("الاستوديو") ) {
|
||||
gallery_package = list.get(n).packageName;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera")|| packag.equalsIgnoreCase("الكاميرا")) {
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (packag.equalsIgnoreCase("Camera") || packag.equalsIgnoreCase("Kamera")|| packag.equalsIgnoreCase("الكاميرا")) {
|
||||
|
||||
defaultCameraPackage = list.get(n).packageName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//com.android.gallery3d
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(defaultCameraPackage);
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
|
||||
intent.setPackage(gallery_package);
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
//Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
//Crashlytics.logException(e.getCause());
|
||||
//Crashlytics.logException(new Exception(e.getCause()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("MissingSuperCall")
|
||||
@SuppressWarnings("deprecation")
|
||||
@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(str + _pathforcheck).exists()) {
|
||||
|
||||
camera.setImageDrawable(getResources().getDrawable(R.mipmap.camera_green));
|
||||
|
||||
image1 = _pathforcheck;
|
||||
|
||||
_pathforcheck = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean imageAllowed() {
|
||||
boolean result = true;
|
||||
|
||||
if (image.equalsIgnoreCase("true")) {
|
||||
|
||||
if (image1.equalsIgnoreCase("")) {
|
||||
|
||||
result = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public boolean textAllowed() {
|
||||
boolean result = true;
|
||||
|
||||
if(remark_type!=null && remark_type.equalsIgnoreCase("Text")){
|
||||
if (text.getText().toString().trim().equals("")) {
|
||||
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
if (v.getId() == R.id.imgcam) {
|
||||
|
||||
_pathforcheck = store_id + "NonWorking" + visit_date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck;
|
||||
|
||||
startCameraActivity();
|
||||
}
|
||||
if (v.getId() == R.id.save) {
|
||||
|
||||
if (validatedata()) {
|
||||
|
||||
if (imageAllowed()) {
|
||||
|
||||
boolean valid_flag = true;
|
||||
if(remark_allow.equalsIgnoreCase("1")){
|
||||
|
||||
if (textAllowed()) {
|
||||
|
||||
if(!validateSubReasonData()){
|
||||
valid_flag = false;
|
||||
Toast.makeText(context, R.string.title_activity_select_dropdown,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
} else {
|
||||
valid_flag = false;
|
||||
Toast.makeText(context, R.string.pleaseenterRemarks,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
if(valid_flag){
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
NonWorkingReason.this);
|
||||
builder.setMessage(R.string.title_activity_save_data)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(
|
||||
DialogInterface dialog,
|
||||
int id) {
|
||||
|
||||
alert.getButton(
|
||||
AlertDialog.BUTTON_POSITIVE)
|
||||
.setEnabled(false);
|
||||
|
||||
if (entry_allow.equals("0")) {
|
||||
|
||||
database.deleteAllTables();
|
||||
|
||||
//jcp = database.getStoreData(visit_date);
|
||||
|
||||
for (int i = 0; i < storelist.size(); i++) {
|
||||
|
||||
String stoteid = storelist.get(i).getSTORE_ID();
|
||||
|
||||
CoverageBean cdata = new CoverageBean();
|
||||
cdata.setStoreId(stoteid);
|
||||
cdata.setVisitDate(visit_date);
|
||||
cdata.setUserId(_UserId);
|
||||
cdata.setInTime(intime);
|
||||
cdata.setOutTime(CommonFunctions.getCurrentTimeWithLanguage(context));
|
||||
cdata.setReason(reasonname);
|
||||
cdata.setReasonid(reasonid);
|
||||
cdata.setLatitude("0.0");
|
||||
cdata.setLongitude("0.0");
|
||||
cdata.setImage(image1);
|
||||
cdata.setSub_reasonId(sub_reason_id);
|
||||
cdata.setRemark(text.getText().toString().replaceAll("[&^<>{}'$]", " "));
|
||||
cdata.setStatus(CommonString.STORE_STATUS_LEAVE);
|
||||
cdata.setFlag_from(store_flag_str);
|
||||
|
||||
if (country_id.equals("7") || country_id.equals("8")) {
|
||||
cdata.setKeyAccountId("0");
|
||||
cdata.setStoreTypeId("0");
|
||||
cdata.setClassId("0");
|
||||
} else {
|
||||
cdata.setKeyAccountId(keyAccount_id);
|
||||
cdata.setStoreTypeId(storeType_id);
|
||||
cdata.setClassId(class_id);
|
||||
}
|
||||
|
||||
database.open();
|
||||
database.InsertCoverageData(cdata);
|
||||
database.updateStoreStatusOnLeave(store_id, visit_date, CommonString.STORE_STATUS_LEAVE, store_flag_str);
|
||||
|
||||
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
editor.putString(CommonString.KEY_STOREVISITED_STATUS + stoteid, "No");
|
||||
editor.putString(CommonString.KEY_STOREVISITED_STATUS, "");
|
||||
editor.putString(CommonString.KEY_STORE_IN_TIME, "");
|
||||
editor.putString(CommonString.KEY_LATITUDE, "");
|
||||
editor.putString(CommonString.KEY_LONGITUDE, "");
|
||||
editor.commit();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
CoverageBean cdata = new CoverageBean();
|
||||
cdata.setStoreId(store_id);
|
||||
cdata.setVisitDate(visit_date);
|
||||
cdata.setUserId(_UserId);
|
||||
cdata.setInTime(intime);
|
||||
cdata.setOutTime(CommonFunctions.getCurrentTimeWithLanguage(context));
|
||||
cdata.setReason(reasonname);
|
||||
cdata.setReasonid(reasonid);
|
||||
cdata.setLatitude("0.0");
|
||||
cdata.setLongitude("0.0");
|
||||
cdata.setImage(image1);
|
||||
cdata.setSub_reasonId(sub_reason_id);
|
||||
|
||||
cdata.setRemark(text
|
||||
.getText()
|
||||
.toString()
|
||||
.replaceAll(
|
||||
"[&^<>{}'$]",
|
||||
" "));
|
||||
cdata.setStatus(CommonString.STORE_STATUS_LEAVE);
|
||||
cdata.setFlag_from(store_flag_str);
|
||||
|
||||
if (country_id.equals("7") || country_id.equals("8")) {
|
||||
cdata.setKeyAccountId("0");
|
||||
cdata.setStoreTypeId("0");
|
||||
cdata.setClassId("0");
|
||||
} else {
|
||||
cdata.setKeyAccountId(keyAccount_id);
|
||||
cdata.setStoreTypeId(storeType_id);
|
||||
cdata.setClassId(class_id);
|
||||
}
|
||||
database.open();
|
||||
database.InsertCoverageData(cdata);
|
||||
database.updateStoreStatusOnLeave(store_id, visit_date, CommonString.STORE_STATUS_LEAVE, store_flag_str);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString(CommonString.KEY_STOREVISITED_STATUS + store_id, "No");
|
||||
editor.putString(CommonString.KEY_STOREVISITED_STATUS, "");
|
||||
editor.putString(CommonString.KEY_STORE_IN_TIME, "");
|
||||
editor.putString(CommonString.KEY_LATITUDE, "");
|
||||
editor.putString(CommonString.KEY_LONGITUDE, "");
|
||||
editor.commit();
|
||||
}
|
||||
new NonWorkingReason.GeoTagUpload(NonWorkingReason.this).execute();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.closed,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(
|
||||
DialogInterface dialog,
|
||||
int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
Toast.makeText(context,
|
||||
R.string.title_activity_take_image, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(context,
|
||||
R.string.title_activity_select_dropdown, Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean validatedata() {
|
||||
boolean result = false;
|
||||
if (reasonid != null && !reasonid.equalsIgnoreCase("")) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean validateSubReasonData() {
|
||||
boolean result = false;
|
||||
if(remark_type!=null && remark_type.equalsIgnoreCase("List")){
|
||||
if (sub_reason_id != null && !sub_reason_id.equalsIgnoreCase("")) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String arabicToenglish(String number) {
|
||||
char[] chars = new char[number.length()];
|
||||
for (int i = 0; i < number.length(); i++) {
|
||||
char ch = number.charAt(i);
|
||||
if (ch >= 0x0660 && ch <= 0x0669)
|
||||
ch -= 0x0660 - '0';
|
||||
else if (ch >= 0x06f0 && ch <= 0x06F9)
|
||||
ch -= 0x06f0 - '0';
|
||||
chars[i] = ch;
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
public String getCurrentTimeNotUsed() {
|
||||
Calendar m_cal = Calendar.getInstance();
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss:mmm");
|
||||
String cdate = formatter.format(m_cal.getTime());
|
||||
|
||||
if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_KSA)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
}else if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_UAE)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
}else if (preferences.getString(CommonString.KEY_LANGUAGE, "").equalsIgnoreCase(CommonString.KEY_LANGUAGE_ARABIC_JORDAN)) {
|
||||
cdate = arabicToenglish(cdate);
|
||||
}
|
||||
|
||||
|
||||
return cdate;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
// NavUtils.navigateUpFromSameTask(this);
|
||||
finish();
|
||||
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
}
|
||||
|
||||
|
||||
public class GeoTagUpload extends AsyncTask<Void, Void, String> {
|
||||
|
||||
private Context context;
|
||||
|
||||
GeoTagUpload(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
|
||||
super.onPreExecute();
|
||||
|
||||
dialog = new Dialog(context);
|
||||
dialog.setContentView(R.layout.custom);
|
||||
dialog.setTitle(getResources().getString(R.string.dialog_title));
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
pb = (ProgressBar) dialog.findViewById(R.id.progressBar1);
|
||||
percentage = (TextView) dialog.findViewById(R.id.percentage);
|
||||
message = (TextView) dialog.findViewById(R.id.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
GSKOrangeDB db = new GSKOrangeDB(NonWorkingReason.this);
|
||||
db.open();
|
||||
|
||||
coverage = db.getCoverageWithStoreID_Data(store_id, visit_date);
|
||||
|
||||
// uploading Geotag
|
||||
|
||||
SAXParserFactory saxPF = SAXParserFactory.newInstance();
|
||||
SAXParser saxP = saxPF.newSAXParser();
|
||||
XMLReader xmlR = saxP.getXMLReader();
|
||||
|
||||
String service;
|
||||
|
||||
if(coverage.get(0).getFlag_from().equals(CommonString.FROM_ADDITIONAL) || coverage.get(0).getFlag_from().equals(CommonString.FROM_ADDITIONAL_ADHOC)){
|
||||
service = CommonString.METHOD_UPLOAD_CURRENT_DATA_ADDITIONAL;
|
||||
}
|
||||
else if(coverage.get(0).getFlag_from().equals(CommonString.FROM_PHARMA)){
|
||||
service = CommonString.METHOD_UPLOAD_CURRENT_DATA_PHARMA;
|
||||
}
|
||||
else{
|
||||
service = CommonString.METHOD_UPLOAD_CURRENT_DATA;
|
||||
|
||||
}
|
||||
|
||||
String current_xml = "";
|
||||
|
||||
if (coverage.size() > 0) {
|
||||
|
||||
//for (int i = 0; i < coverage.size(); i++) {
|
||||
|
||||
|
||||
String onXML = "[Coverage_Intime][USER_ID]"
|
||||
+ _UserId
|
||||
+ "[/USER_ID]"
|
||||
+ "[STORE_ID]"
|
||||
+ coverage.get(0).getStoreId()
|
||||
+ "[/STORE_ID]"
|
||||
+ "[VISIT_DATE]"
|
||||
+ coverage.get(0).getVisitDate()
|
||||
+ "[/VISIT_DATE]"
|
||||
+ "[IN_TIME]"
|
||||
+ coverage.get(0).getInTime()
|
||||
+ "[/IN_TIME]"
|
||||
+ "[LATITUDE]"
|
||||
+ coverage.get(0).getLatitude()
|
||||
+ "[/LATITUDE]"
|
||||
+ "[LONGITUDE ]"
|
||||
+ coverage.get(0).getLongitude()
|
||||
+ "[/LONGITUDE ]"
|
||||
+ "[REASON_ID]"
|
||||
+ coverage.get(0).getReasonid()
|
||||
+ "[/REASON_ID]"
|
||||
+ "[REMARK]"
|
||||
+ coverage.get(0).getReason()
|
||||
+ "[/REMARK][/Coverage_Intime]";
|
||||
|
||||
//current_xml = current_xml + onXML;
|
||||
|
||||
|
||||
//}
|
||||
|
||||
current_xml = "[DATA]" + onXML
|
||||
+ "[/DATA]";
|
||||
|
||||
SoapObject request = new SoapObject(CommonString.NAMESPACE,
|
||||
service);
|
||||
//request.addProperty("MID", "0");
|
||||
// request.addProperty("KEYS", "CURRENT_DATA");
|
||||
// request.addProperty("USERNAME", username);
|
||||
|
||||
request.addProperty("onXML", current_xml);
|
||||
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
HttpTransportSE androidHttpTransport = new HttpTransportSE(
|
||||
CommonString.URL);
|
||||
androidHttpTransport.call(
|
||||
CommonString.SOAP_ACTION + service, envelope);
|
||||
Object result = (Object) envelope.getResponse();
|
||||
|
||||
if (result.toString().equalsIgnoreCase(
|
||||
CommonString.KEY_SUCCESS)) {
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (result.toString().equalsIgnoreCase(
|
||||
CommonString.KEY_FALSE)) {
|
||||
return service;
|
||||
}
|
||||
|
||||
// for failure
|
||||
FailureXMLHandler failureXMLHandler = new FailureXMLHandler();
|
||||
xmlR.setContentHandler(failureXMLHandler);
|
||||
|
||||
InputSource is = new InputSource();
|
||||
is.setCharacterStream(new StringReader(result
|
||||
.toString()));
|
||||
xmlR.parse(is);
|
||||
|
||||
failureGetterSetter = failureXMLHandler
|
||||
.getFailureGetterSetter();
|
||||
|
||||
if (failureGetterSetter.getStatus().equalsIgnoreCase(
|
||||
CommonString.KEY_FAILURE)) {
|
||||
return CommonString.METHOD_UPLOAD_CURRENT_DATA + ","
|
||||
+ failureGetterSetter.getErrorMsg();
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return CommonString.KEY_SUCCESS;
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
|
||||
ResultFlag = false;
|
||||
strflag = CommonString.MESSAGE_EXCEPTION;
|
||||
|
||||
} catch (SocketTimeoutException e) {
|
||||
ResultFlag = false;
|
||||
strflag = CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
|
||||
} catch (InterruptedIOException e) {
|
||||
|
||||
ResultFlag = false;
|
||||
strflag = CommonString.MESSAGE_EXCEPTION;
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
ResultFlag = false;
|
||||
strflag = CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
|
||||
} catch (XmlPullParserException e) {
|
||||
ResultFlag = false;
|
||||
strflag = CommonString.MESSAGE_XmlPull;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
// Crashlytics.logException(new Exception(e.getCause()));
|
||||
|
||||
ResultFlag = false;
|
||||
strflag = CommonString.MESSAGE_EXCEPTION;
|
||||
|
||||
}
|
||||
|
||||
if (ResultFlag) {
|
||||
return CommonString.KEY_SUCCESS;
|
||||
|
||||
} else {
|
||||
|
||||
return strflag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
|
||||
dialog.dismiss();
|
||||
|
||||
if (result.equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
|
||||
dialog.dismiss();
|
||||
|
||||
finish();
|
||||
|
||||
//showAlert(getString(R.string.uploadeddata));
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
GSKOrangeDB db = new GSKOrangeDB(NonWorkingReason.this);
|
||||
db.open();
|
||||
|
||||
dialog.dismiss();
|
||||
db.deleteTableWithStoreID(store_id);
|
||||
|
||||
showAlert(getString(R.string.datanotfound) + " " + result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void showAlert(String str) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(NonWorkingReason.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(str).setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,446 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.Manifest
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.sj.camera_lib_android.Database.ReactPendingData
|
||||
import com.sj.camera_lib_android.Database.ReactSingleImage
|
||||
import com.sj.camera_lib_android.models.ImageUploadModel
|
||||
import com.sj.camera_lib_android.utils.CameraSDK
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter
|
||||
import cpm.com.gskmtorange.LoginActivity
|
||||
import cpm.com.gskmtorange.R
|
||||
import cpm.com.gskmtorange.adapter.SubCatPdAdapter
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions.savefile
|
||||
import cpm.com.gskmtorange.constant.CommonString
|
||||
import cpm.com.gskmtorange.constant.CommonUtils
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdimageBinding
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
|
||||
class PDimageActivity : AppCompatActivity() {
|
||||
private var context: Context? = null
|
||||
var categoryName: String? = null
|
||||
var categoryId: String? = null
|
||||
var store_id: String? = null;
|
||||
var date: String? = null;
|
||||
var store_type_id: String? = null
|
||||
var class_id: String? = null
|
||||
var key_account_id: String? = null
|
||||
var country_id: String? = null
|
||||
var store_flag_str: String? = null
|
||||
private var preferences: SharedPreferences? = null
|
||||
var db: GSKOrangeDB? = null
|
||||
var listdat: ArrayList<CategoryPictureGetterSetter>? = ArrayList()
|
||||
var username: String? = ""
|
||||
private var kpi_name: String? = ""
|
||||
private lateinit var binding: ActivityPdimageBinding
|
||||
private var adapter: SubCatPdAdapter? = null
|
||||
val PERMISSION_ALL: Int = 99
|
||||
private var _pos = -1;
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityPdimageBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
context = this
|
||||
db = GSKOrangeDB(context)
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
db?.open()
|
||||
preferences?.let {
|
||||
store_id = it.getString(CommonString.KEY_STORE_ID, "")
|
||||
username = it.getString(CommonString.KEY_USERNAME, "")
|
||||
store_type_id = it.getString(CommonString.KEY_STORETYPE_ID, "")
|
||||
class_id = it.getString(CommonString.KEY_CLASS_ID, "")
|
||||
key_account_id = it.getString(CommonString.KEY_KEYACCOUNT_ID, "")
|
||||
country_id = it.getString(CommonString.KEY_COUNTRY_ID, "")
|
||||
store_flag_str = it.getString(CommonString.KEY_STORE_FLAG, "")
|
||||
date = it.getString(CommonString.KEY_DATE, "")
|
||||
}
|
||||
|
||||
CommonFunctions.updateLangResources(
|
||||
context, preferences?.getString(CommonString.KEY_LANGUAGE, "")
|
||||
)
|
||||
intent?.let {
|
||||
categoryName = it.getStringExtra("categoryName")
|
||||
categoryId = it.getStringExtra("categoryId")
|
||||
kpi_name = it.getStringExtra("kpi_name")
|
||||
}
|
||||
supportActionBar?.apply {
|
||||
setHomeButtonEnabled(true)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
title = kpi_name
|
||||
}
|
||||
CommonUtils.initializePDSDK(this@PDimageActivity, _userId = username)
|
||||
registerIntentFilter(
|
||||
listOf(
|
||||
"DataSaved", "did-receive-queue-data", "did-receive-image-upload-status"
|
||||
)
|
||||
)
|
||||
|
||||
binding.apply {
|
||||
fab.setOnClickListener {
|
||||
if (validate()) {
|
||||
val builder = AlertDialog.Builder(this@PDimageActivity)
|
||||
builder.setMessage(getString(R.string.check_save_message)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
||||
// Handle Yes button click
|
||||
db?.open()
|
||||
db?.InsertPdImageData(date, store_id, categoryId, listdat)?.let {
|
||||
if (it > 0) {
|
||||
Snackbar.make(
|
||||
binding.fab,
|
||||
resources.getString(R.string.save_message),
|
||||
Snackbar.LENGTH_LONG
|
||||
).setAction("Action", null).show()
|
||||
lifecycleScope.launch {
|
||||
delay(3000) // 3 seconds delay
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(
|
||||
binding.fab,
|
||||
resources.getString(R.string.save_message),
|
||||
Snackbar.LENGTH_LONG
|
||||
).setAction("Action", null).show()
|
||||
}
|
||||
}
|
||||
dialog.dismiss()
|
||||
}.setNegativeButton(getString(R.string.no)) { dialog, _ ->
|
||||
dialog.cancel()
|
||||
}
|
||||
val alert = builder.create()
|
||||
alert.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callAdapter()
|
||||
checkAndRequestPermissions()
|
||||
}
|
||||
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
db?.open()
|
||||
}
|
||||
|
||||
private fun validate(): Boolean {
|
||||
var checkFlag = true // Use local variable to avoid issues
|
||||
if (!listdat.isNullOrEmpty()) {
|
||||
for (data in listdat!!) { // Use standard loop for better control
|
||||
if (data.imageUris.isNullOrEmpty()) {
|
||||
checkFlag = false // Set false if validation fails
|
||||
Snackbar.make(
|
||||
binding.fab,
|
||||
"Please capture IR images of ${data.suB_CATEGORY}",
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
break // Stop further checks once an issue is found
|
||||
}
|
||||
}
|
||||
}
|
||||
return checkFlag // Correctly return validation result
|
||||
}
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
val id = item.itemId
|
||||
if (id == android.R.id.home) {
|
||||
//showDataLossAlert();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out)
|
||||
finish()
|
||||
}
|
||||
if (id == R.id.action_settings) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
LocalBroadcastManager.getInstance(this@PDimageActivity)
|
||||
.unregisterReceiver(myBroadcastReceiver) // onDestroy
|
||||
}
|
||||
|
||||
private fun registerIntentFilter(filters: List<String> = listOf()) {
|
||||
filters.forEach { filter ->
|
||||
LocalBroadcastManager.getInstance(this@PDimageActivity)
|
||||
.registerReceiver(myBroadcastReceiver, IntentFilter(filter))
|
||||
}
|
||||
}
|
||||
|
||||
private val savedImages = mutableListOf<ImageUri>()
|
||||
private var myBroadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
when (intent?.action) {
|
||||
"did-receive-queue-data" -> {
|
||||
val receivedList =
|
||||
intent.getParcelableArrayListExtra<ReactPendingData>("imageList")
|
||||
Log.d("DEBUG-LOG did-receive-queue-data", "$receivedList")
|
||||
if (receivedList.isNullOrEmpty()) {
|
||||
CameraSDK.uploadFailedImage(this@PDimageActivity)
|
||||
}
|
||||
}
|
||||
|
||||
"did-receive-image-upload-status" -> {
|
||||
val receivedImage = intent.getParcelableExtra<ReactSingleImage>("image")
|
||||
Log.d("DEBUG-LOG did-receive-image-upload-status", "$receivedImage")
|
||||
}
|
||||
|
||||
"DataSaved" -> {
|
||||
val receivedList =
|
||||
intent.getParcelableArrayListExtra<ImageUploadModel>("imageListSaved")
|
||||
Log.d("DEBUG-LOG DataSaved", "$receivedList")
|
||||
receivedList?.let {
|
||||
savedImages.clear()
|
||||
it.forEach { item ->
|
||||
val dir = CommonString.getImagesFolder(context)
|
||||
val setName =
|
||||
store_id + "_" + username?.replace(".", "") + "_IRPDIMG-" + File(
|
||||
item.uri
|
||||
).getName()
|
||||
|
||||
savedImages.add(ImageUri(uri = item.uri, modify_uri = setName))
|
||||
savefile(Uri.parse(item.uri), "$dir $setName")
|
||||
}
|
||||
adapter?.updateItem(position = _pos, savedImages)
|
||||
Log.e("savedImages",savedImages.toString())
|
||||
_pos = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchCamera(subCat_code: String) {
|
||||
val uploadFrom = "TestApp"
|
||||
val uploadParams = JSONObject(
|
||||
"""
|
||||
{
|
||||
"shop_id": 62475,
|
||||
"project_id": "4f57635b-6b07-45bf-bfba-c61c2826b6db",
|
||||
"td_version_id": 178,
|
||||
"shelf_image_id": null,
|
||||
"asset_image_id": null,
|
||||
"shelf_type": "Primary Shelf",
|
||||
"category_id": 123,
|
||||
"user_id": 133,
|
||||
"isConnected": true,
|
||||
"sn_image_type": "skus",
|
||||
"image_type": "multiple",
|
||||
"seq_no": 1,
|
||||
"level": 1,
|
||||
"uploadOnlyOnWifi": 0,
|
||||
"app_session_id": "8e2faa6b-d6fe-413a-a693-76a0cbe0ce71",
|
||||
"metadata": { "Device_Name": "Samsung" }
|
||||
}
|
||||
"""
|
||||
)
|
||||
uploadParams.put("shop_id", store_id)
|
||||
uploadParams.put("user_id", username)
|
||||
uploadParams.put("category_id", subCat_code)
|
||||
uploadParams.put("project_id", CommonString.PD_PROJECT_iD)
|
||||
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
|
||||
private fun callAdapter() {
|
||||
if (country_id == "8") {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturedata(
|
||||
date,
|
||||
categoryId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_STOREWISE
|
||||
)
|
||||
} else if (store_flag_str.equals(CommonString.FROM_DEVIATION, ignoreCase = true)) {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturedata(
|
||||
date,
|
||||
categoryId,
|
||||
key_account_id,
|
||||
store_type_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_ADHOC
|
||||
)
|
||||
} else {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturedata(
|
||||
date,
|
||||
categoryId,
|
||||
key_account_id,
|
||||
store_type_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK
|
||||
)
|
||||
}
|
||||
|
||||
Log.d("listdatsize", listdat?.size.toString())
|
||||
adapter = SubCatPdAdapter(category = categoryName,
|
||||
context = this,
|
||||
subcates = ArrayList(),
|
||||
btnlistener = object : SubCatPdAdapter.BtnClickListener {
|
||||
override fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter) {
|
||||
this@PDimageActivity._pos = _pos
|
||||
launchCamera(data.subCatCode)
|
||||
}
|
||||
})
|
||||
binding.rlContent.apply {
|
||||
recyclerViewSubCat.adapter = adapter
|
||||
recyclerViewSubCat.layoutManager = LinearLayoutManager(this@PDimageActivity)
|
||||
adapter?.addsubCatItems(listdat)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
db?.open()
|
||||
db?.InsertPdImageData(date, store_id, categoryId, listdat)
|
||||
}
|
||||
|
||||
private fun checkAndRequestPermissions() {
|
||||
var read_phone_state = 0
|
||||
var write_storage = 0
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES)
|
||||
} else {
|
||||
read_phone_state =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
|
||||
val listPermissionsNeeded: MutableList<String> = java.util.ArrayList()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.READ_MEDIA_IMAGES)
|
||||
}
|
||||
} else {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
}
|
||||
|
||||
if (listPermissionsNeeded.isNotEmpty()) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
listPermissionsNeeded.toTypedArray<String>(),
|
||||
PERMISSION_ALL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
|
||||
if (requestCode == PERMISSION_ALL) {
|
||||
val perms: MutableMap<String, Int> = HashMap()
|
||||
// Initialize the map with both permissions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
perms[Manifest.permission.READ_MEDIA_IMAGES] = PackageManager.PERMISSION_GRANTED
|
||||
} else {
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] =
|
||||
PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
// Fill with actual results from user
|
||||
if (grantResults.isNotEmpty()) {
|
||||
for (i in permissions.indices) perms[permissions[i]] = grantResults[i]
|
||||
// Check for both permissions//
|
||||
if (perms[Manifest.permission.READ_MEDIA_IMAGES] == PackageManager.PERMISSION_GRANTED &&
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.d("", "sms & location services permission granted")
|
||||
} else {
|
||||
Log.d("", "Some permissions are not granted ask again ")
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.READ_MEDIA_IMAGES
|
||||
) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
showDialogOK(
|
||||
"Photos or media Service Permission required for this app"
|
||||
) { dialog: DialogInterface?, which: Int ->
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> checkAndRequestPermissions()
|
||||
DialogInterface.BUTTON_NEGATIVE -> {
|
||||
// proceed with logic by disabling the related features or quit the app.
|
||||
val startMain =
|
||||
Intent(Intent.ACTION_MAIN)
|
||||
startMain.addCategory(Intent.CATEGORY_HOME)
|
||||
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(startMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialogOK(message: String, okListener: DialogInterface.OnClickListener) {
|
||||
AlertDialog.Builder(this).setMessage(message).setPositiveButton("OK", okListener)
|
||||
.setNegativeButton("Cancel", okListener).create().show()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,613 @@
|
||||
package cpm.com.gskmtorange.dailyentry;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.InputFilter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityStockFacingGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.POGGetterSetter;
|
||||
|
||||
public class POGQuestionsActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
ExpandableListView expandableListView;
|
||||
LinearLayout linPlanogramType;
|
||||
Spinner spinPlanogramType;
|
||||
|
||||
String categoryName, categoryId, Error_Message = "";
|
||||
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id, camera_allow, country_id, pog_type_id;
|
||||
boolean isDialogOpen = true;
|
||||
private SharedPreferences preferences;
|
||||
int scrollPosition = 0;
|
||||
|
||||
|
||||
|
||||
GSKOrangeDB db;
|
||||
|
||||
List<MSL_AvailabilityStockFacingGetterSetter> headerDataList = new ArrayList<>();
|
||||
HashMap<MSL_AvailabilityStockFacingGetterSetter, List<POGGetterSetter>> hashMapListChildData = new HashMap<>();
|
||||
|
||||
ExpandableListAdapter adapter;
|
||||
|
||||
List<Integer> checkHeaderArray = new ArrayList<>();
|
||||
String error_msg = "";
|
||||
boolean checkflag = true;
|
||||
int selectedPOSMTypePosition = 0;
|
||||
boolean userSelect = false, changedFlag = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pogquestions);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
|
||||
linPlanogramType = (LinearLayout) findViewById(R.id.lin_planogram_type);
|
||||
spinPlanogramType = (Spinner) findViewById(R.id.spinner_planogram_type);
|
||||
context = this;
|
||||
db = new GSKOrangeDB(this);
|
||||
db.open();
|
||||
|
||||
//preference data
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
|
||||
visit_date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
date = preferences.getString(CommonString.KEY_DATE, null);
|
||||
username = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, "");
|
||||
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
|
||||
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
|
||||
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
|
||||
camera_allow = preferences.getString(CommonString.KEY_CAMERA_ALLOW, "");
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
|
||||
pog_type_id = preferences.getString(CommonString.KEY_POG_TYPE_ID, "");
|
||||
|
||||
//Intent data
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
|
||||
//txt_mslAvailabilityName.setText(getResources().getString(R.string.title_activity_msl__availability));
|
||||
toolbar.setTitle(getResources().getString(R.string.pog));
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (validateData()) {
|
||||
|
||||
db.savePOGQuestionAnswerData(hashMapListChildData, headerDataList, store_id, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
/* AlertDialog.Builder builder = new AlertDialog.Builder(POGQuestionsActivity.this);
|
||||
builder.setMessage(R.string.title_activity_Want_save)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
db.savePOGQuestionAnswerData(hashMapListChildData, headerDataList,store_id, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
|
||||
} else {
|
||||
|
||||
if(adapter!=null){
|
||||
adapter.notifyDataSetChanged();
|
||||
expandableListView.invalidateViews();
|
||||
}
|
||||
Snackbar.make(expandableListView, error_msg, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (country_id.equals("2") && (storeType_id.equals("9") || storeType_id.equals("15")||storeType_id.equals("47"))) {
|
||||
linPlanogramType.setVisibility(View.VISIBLE);
|
||||
final ArrayAdapter planogramTypeAdapter = new ArrayAdapter<CharSequence>(this,
|
||||
android.R.layout.simple_spinner_item);
|
||||
|
||||
String select_str = getResources().getString(R.string.select_promo);
|
||||
|
||||
planogramTypeAdapter.add(select_str);
|
||||
|
||||
final ArrayList<String> pogTypeList = db.getPogType(categoryId, storeType_id, pog_type_id);
|
||||
|
||||
for (int i = 0; i < pogTypeList.size(); i++) {
|
||||
planogramTypeAdapter.add(pogTypeList.get(i));
|
||||
}
|
||||
|
||||
spinPlanogramType.setAdapter(planogramTypeAdapter);
|
||||
|
||||
planogramTypeAdapter
|
||||
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
spinPlanogramType.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
userSelect = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinPlanogramType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, final int position, long id) {
|
||||
|
||||
if (userSelect) {
|
||||
|
||||
userSelect = false;
|
||||
|
||||
if (changedFlag) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(POGQuestionsActivity.this);
|
||||
builder.setMessage(R.string.DELETE_ALERT_MESSAGE)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.yes),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
selectedPOSMTypePosition = position;
|
||||
prepareListData(planogramTypeAdapter.getItem(position).toString(), true);
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getResources().getString(R.string.no),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
|
||||
spinPlanogramType.setSelection(selectedPOSMTypePosition);
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
|
||||
alert.show();
|
||||
} else {
|
||||
selectedPOSMTypePosition = position;
|
||||
prepareListData(planogramTypeAdapter.getItem(position).toString(), true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<POGGetterSetter> pogSavedList = db.getAfterSavePOGUploadQuestionAnswerData(store_id, categoryId);
|
||||
|
||||
if (pogSavedList.size() > 0) {
|
||||
String qType = pogSavedList.get(0).getQTYPE();
|
||||
for (int i = 0; i < pogTypeList.size(); i++) {
|
||||
if (qType.equals(pogTypeList.get(i))) {
|
||||
selectedPOSMTypePosition = i + 1;
|
||||
spinPlanogramType.setSelection(i + 1);
|
||||
prepareListData(qType, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
changedFlag = true;
|
||||
}
|
||||
} else {
|
||||
prepareListData(null, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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) {
|
||||
|
||||
if (changedFlag) {
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(POGQuestionsActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//super.onBackPressed();
|
||||
if (changedFlag) {
|
||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(POGQuestionsActivity.this);
|
||||
builder.setTitle("Parinaam");
|
||||
builder.setMessage(getResources().getString(R.string.data_will_be_lost)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
android.app.AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void prepareListData(String planogramType, boolean clearFlag) {
|
||||
headerDataList = new ArrayList<>();
|
||||
|
||||
headerDataList = db.getSubCategoryMasterForPOG(categoryId, storeType_id, pog_type_id, planogramType);
|
||||
|
||||
if (headerDataList.size() > 0) {
|
||||
for (int i = 0; i < headerDataList.size(); i++) {
|
||||
|
||||
ArrayList<POGGetterSetter> quizDataList = new ArrayList<>();
|
||||
if (!clearFlag) {
|
||||
quizDataList = db.getAfterSavePOGQuestionAnswerData(store_id, categoryId, headerDataList.get(i).getSub_category_id());
|
||||
}
|
||||
|
||||
|
||||
if (quizDataList.size() == 0) {
|
||||
quizDataList = db.getPOGSubCategoryWise(headerDataList.get(i).getSub_category_id(), pog_type_id, storeType_id, planogramType);
|
||||
}
|
||||
|
||||
//hashMapListChildData = new HashMap<>();
|
||||
ArrayList<POGGetterSetter> childListData = new ArrayList<>();
|
||||
|
||||
if (quizDataList.size() > 0) {
|
||||
String select = getString(R.string.title_activity_select_dropdown);
|
||||
// Adding child data
|
||||
for (int j = 0; j < quizDataList.size(); j++) {
|
||||
childListData = db.getPOGAnswerData(quizDataList.get(j).getQUESTION_ID(), headerDataList.get(i).getSub_category_id(), select);
|
||||
quizDataList.get(j).setAnswerList(childListData);
|
||||
}
|
||||
}
|
||||
|
||||
//childDataList = new ArrayList<>();
|
||||
/* childDataList = db.getMSL_Availability_StockFacingSKU_AfterSaveData(categoryId, headerDataList.get(i).getBrand_id(), store_id);
|
||||
if (!(childDataList.size() > 0)) {
|
||||
childDataList = db.getPOGSubCategoryWise(categoryId, headerDataList.get(i).getBrand_id(), keyAccount_id, storeType_id, class_id);
|
||||
}*/
|
||||
|
||||
hashMapListChildData.put(headerDataList.get(i), quizDataList);
|
||||
}
|
||||
}
|
||||
|
||||
adapter = new ExpandableListAdapter(this, headerDataList, hashMapListChildData);
|
||||
expandableListView.setAdapter(adapter);
|
||||
|
||||
for (int i = 0; i < adapter.getGroupCount(); i++)
|
||||
expandableListView.expandGroup(i);
|
||||
|
||||
}
|
||||
|
||||
public class ExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
private Context _context;
|
||||
private List<MSL_AvailabilityStockFacingGetterSetter> _listDataHeader;
|
||||
private HashMap<MSL_AvailabilityStockFacingGetterSetter, List<POGGetterSetter>> _listDataChild;
|
||||
|
||||
public ExpandableListAdapter(Context context, List<MSL_AvailabilityStockFacingGetterSetter> listDataHeader,
|
||||
HashMap<MSL_AvailabilityStockFacingGetterSetter, List<POGGetterSetter>> listChildData) {
|
||||
this._context = context;
|
||||
this._listDataHeader = listDataHeader;
|
||||
this._listDataChild = listChildData;
|
||||
}
|
||||
|
||||
@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) {
|
||||
MSL_AvailabilityStockFacingGetterSetter headerTitle = (MSL_AvailabilityStockFacingGetterSetter) getGroup(groupPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = infalInflater.inflate(R.layout.item_pog_header, null, false);
|
||||
}
|
||||
|
||||
TextView txt_categoryHeader = (TextView) convertView.findViewById(R.id.txt_categoryHeader);
|
||||
RelativeLayout rel_header = (RelativeLayout) convertView.findViewById(R.id.rel_categoryHeader);
|
||||
ImageView img_camera = (ImageView) convertView.findViewById(R.id.img_camera);
|
||||
CardView card_view = (CardView) convertView.findViewById(R.id.card_view);
|
||||
|
||||
txt_categoryHeader.setTypeface(null, Typeface.BOLD);
|
||||
|
||||
txt_categoryHeader.setText(headerTitle.getSub_category());
|
||||
|
||||
|
||||
if (!checkflag) {
|
||||
if (checkHeaderArray.contains(groupPosition)) {
|
||||
card_view.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
|
||||
} else {
|
||||
card_view.setCardBackgroundColor(getResources().getColor(R.color.grey_background));
|
||||
}
|
||||
}
|
||||
|
||||
//empty check color change
|
||||
/*if (headerTitle.getCompany_id().equals("1")) {
|
||||
if (!checkflag) {
|
||||
if (checkHeaderArray.contains(groupPosition)) {
|
||||
//card_view.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
|
||||
txt_categoryHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
|
||||
} else {
|
||||
txt_categoryHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!checkflag) {
|
||||
if (checkHeaderArray.contains(groupPosition)) {
|
||||
txt_categoryHeader.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
|
||||
} else {
|
||||
txt_categoryHeader.setTextColor(getResources().getColor(R.color.black));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosititon) {
|
||||
return this._listDataChild.get(this._listDataHeader.get(groupPosition)).get(childPosititon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return childPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
|
||||
View convertView, ViewGroup parent) {
|
||||
|
||||
final POGGetterSetter childData =
|
||||
(POGGetterSetter) getChild(groupPosition, childPosition);
|
||||
ArrayList<POGGetterSetter> ans_list = childData.getAnswerList();
|
||||
ViewHolder holder = null;
|
||||
|
||||
if (convertView == null) {
|
||||
LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = infalInflater.inflate(R.layout.pog_question, null, false);
|
||||
|
||||
holder = new ViewHolder();
|
||||
holder.txt_question = (TextView) convertView.findViewById(R.id.txt_question);
|
||||
holder.sp_auditAnswer = (Spinner) convertView.findViewById(R.id.sp_auditAnswer);
|
||||
holder.cardView = (CardView) convertView.findViewById(R.id.card_view);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.sp_auditAnswer.setAdapter(new AnswerSpinnerAdapter(POGQuestionsActivity.this, R.layout.custom_spinner_item, ans_list));
|
||||
|
||||
final ArrayList<POGGetterSetter> finalAns_list = ans_list;
|
||||
holder.sp_auditAnswer.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
POGGetterSetter ans = finalAns_list.get(position);
|
||||
childData.setANSWER_ID(ans.getANSWER_ID());
|
||||
childData.setANSWER(ans.getANSWER());
|
||||
changedFlag = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.txt_question.setText(childData.getQUESTION() + " (" + childData.getQTYPE() + ")");
|
||||
|
||||
for (int i = 0; i < ans_list.size(); i++) {
|
||||
if (ans_list.get(i).getANSWER_ID().equals(childData.getANSWER_ID())) {
|
||||
holder.sp_auditAnswer.setSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkflag) {
|
||||
if (childData.getANSWER_ID().equals("0")) {
|
||||
holder.cardView.setCardBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
|
||||
|
||||
} else {
|
||||
holder.cardView.setCardBackgroundColor(getResources().getColor(R.color.white));
|
||||
}
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewHolder {
|
||||
CardView cardView;
|
||||
View mView;
|
||||
TextView txt_question;
|
||||
Spinner sp_auditAnswer;
|
||||
}
|
||||
|
||||
public class AnswerSpinnerAdapter extends ArrayAdapter<POGGetterSetter> {
|
||||
List<POGGetterSetter> list;
|
||||
Context context;
|
||||
int resourceId;
|
||||
|
||||
public AnswerSpinnerAdapter(Context context, int resourceId, ArrayList<POGGetterSetter> list) {
|
||||
super(context, resourceId, list);
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
POGGetterSetter cm = list.get(position);
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.tv_text);
|
||||
txt_spinner.setText(list.get(position).getANSWER());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
|
||||
view = inflater.inflate(resourceId, parent, false);
|
||||
|
||||
POGGetterSetter cm = list.get(position);
|
||||
|
||||
TextView txt_spinner = (TextView) view.findViewById(R.id.tv_text);
|
||||
txt_spinner.setText(cm.getANSWER());
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
boolean validateData() {
|
||||
//boolean flag = true;
|
||||
checkHeaderArray.clear();
|
||||
|
||||
checkflag = true;
|
||||
if (country_id.equals("2") && (storeType_id.equals("9") || storeType_id.equals("15"))) {
|
||||
if (headerDataList.size() == 0) {
|
||||
error_msg = getString(R.string.title_activity_select_dropdown);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < headerDataList.size(); l++) {
|
||||
|
||||
List<POGGetterSetter> child_data = hashMapListChildData.get(headerDataList.get(l));
|
||||
for (int i = 0; i < child_data.size(); i++) {
|
||||
if (child_data.get(i).getANSWER_ID().equalsIgnoreCase("0")) {
|
||||
error_msg = getString(R.string.pls_answer_all_qns);
|
||||
checkflag = false;
|
||||
}
|
||||
|
||||
if (checkflag == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkflag == false) {
|
||||
if (!checkHeaderArray.contains(l)) {
|
||||
checkHeaderArray.add(l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return checkflag;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user