added qr-code generator in ba-assessment
This commit is contained in:
@@ -13,3 +13,9 @@
|
|||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
|
# Android build outputs
|
||||||
|
*.apk
|
||||||
|
*.aab
|
||||||
|
/build
|
||||||
|
/app/build
|
||||||
|
|||||||
Binary file not shown.
+22
-85
@@ -1,73 +1,42 @@
|
|||||||
package com.cpm.lorealbaautomation.dailyactivity;
|
package com.cpm.lorealbaautomation.dailyactivity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.webkit.WebSettings;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.cardview.widget.CardView;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
import com.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||||
import com.cpm.lorealbaautomation.R;
|
import com.cpm.lorealbaautomation.R;
|
||||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
|
||||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterSurvey;
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.journeyapps.barcodescanner.BarcodeEncoder;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import im.delight.android.webview.AdvancedWebView;
|
|
||||||
|
|
||||||
|
|
||||||
public class BaAssessmentActivity extends AppCompatActivity {
|
public class BaAssessmentActivity extends AppCompatActivity {
|
||||||
private final Handler loaderHandler = new Handler(Looper.getMainLooper());
|
private ImageView qrImage;
|
||||||
private String username;
|
|
||||||
private String couter_code;
|
|
||||||
private Lorealba_Database db;
|
private Lorealba_Database db;
|
||||||
JourneyPlan jcp_Object = new JourneyPlan();
|
JourneyPlan jcp_Object = new JourneyPlan();
|
||||||
AdvancedWebView webView;
|
|
||||||
ProgressBar progressBar;
|
|
||||||
private Runnable showLoaderRunnable;
|
|
||||||
private boolean pageLoaded = false;
|
|
||||||
|
|
||||||
@SuppressLint("MissingInflatedId")
|
@SuppressLint("MissingInflatedId")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_ba_assessment);
|
setContentView(R.layout.activity_ba_assessment);
|
||||||
progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
|
||||||
webView = (AdvancedWebView) findViewById(R.id.webviewbaAssessment);
|
|
||||||
SharedPreferences preferences = PrefHelper.getPrefs(this);
|
SharedPreferences preferences = PrefHelper.getPrefs(this);
|
||||||
String date = preferences.getString(CommonString.KEY_DATE, "");
|
String date = preferences.getString(CommonString.KEY_DATE, "");
|
||||||
username = preferences.getString(CommonString.KEY_USERNAME, "");
|
String username = preferences.getString(CommonString.KEY_USERNAME, "");
|
||||||
String counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
String counter_id = preferences.getString(CommonString.KEY_COUNTER_ID, "");
|
||||||
couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
String couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
qrImage = findViewById(R.id.qrImage);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
if (!CommonFunctions.isTablet(this)) {
|
if (!CommonFunctions.isTablet(this)) {
|
||||||
toolbar.setTitleTextAppearance(this, R.style.changestext_sizefor_mobile);
|
toolbar.setTitleTextAppearance(this, R.style.changestext_sizefor_mobile);
|
||||||
@@ -78,12 +47,9 @@ public class BaAssessmentActivity extends AppCompatActivity {
|
|||||||
db.open();
|
db.open();
|
||||||
jcp_Object = db.getBIDfromJCP(username, counter_id);
|
jcp_Object = db.getBIDfromJCP(username, counter_id);
|
||||||
setTitle("BA Assessment - " + date);
|
setTitle("BA Assessment - " + date);
|
||||||
|
String link = CommonString.BA_ASSESSMENT_URL + "c=" + couter_code + "&u=" + username;
|
||||||
if (CommonFunctions.checkNetIsAvailable(this)) {
|
Log.e("link", link);
|
||||||
loadWeb();
|
generateQRCode(link);
|
||||||
} else {
|
|
||||||
AlertandMessages.showToastMsg(this, getString(R.string.nonetwork));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,52 +72,23 @@ public class BaAssessmentActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (webView.canGoBack()) {
|
|
||||||
webView.goBack();
|
|
||||||
} else {
|
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
this.finish();
|
this.finish();
|
||||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateQRCode(String text) {
|
||||||
|
try {
|
||||||
|
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
|
||||||
|
Bitmap bitmap = barcodeEncoder.encodeBitmap(
|
||||||
|
text,
|
||||||
|
BarcodeFormat.QR_CODE,
|
||||||
|
400,
|
||||||
|
400
|
||||||
|
);
|
||||||
|
qrImage.setImageBitmap(bitmap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.fillInStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
|
||||||
private void loadWeb() {
|
|
||||||
WebSettings webSettings = webView.getSettings();
|
|
||||||
webSettings.setJavaScriptEnabled(true);
|
|
||||||
webSettings.setDomStorageEnabled(true);
|
|
||||||
webSettings.setLoadWithOverviewMode(true);
|
|
||||||
webSettings.setUseWideViewPort(true);
|
|
||||||
webSettings.setSupportZoom(true);
|
|
||||||
webSettings.setBuiltInZoomControls(true);
|
|
||||||
webSettings.setDisplayZoomControls(false);
|
|
||||||
// Android 5+ mixed content
|
|
||||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
||||||
webView.loadUrl(CommonString.BA_ASSESSMENT_URL + "c=" + couter_code + "&u=" + username);
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
||||||
pageLoaded = false;
|
|
||||||
|
|
||||||
showLoaderRunnable = () -> {
|
|
||||||
if (!pageLoaded) {
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ⏳ Wait 400ms before showing loader
|
|
||||||
loaderHandler.postDelayed(showLoaderRunnable, 4000);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
pageLoaded = true;
|
|
||||||
|
|
||||||
loaderHandler.removeCallbacks(showLoaderRunnable);
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,56 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".dailyactivity.BaAssessmentActivity"
|
|
||||||
android:background="@color/grey_background"
|
android:background="@color/grey_background"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context=".dailyactivity.BaAssessmentActivity"
|
||||||
tools:showIn="@layout/activity_ba_assessment">
|
tools:showIn="@layout/activity_ba_assessment">
|
||||||
|
|
||||||
<ProgressBar
|
<!-- CENTER CONTAINER -->
|
||||||
android:id="@+id/progressBar"
|
<LinearLayout
|
||||||
android:layout_width="@dimen/custom_margin60dp"
|
android:id="@+id/container"
|
||||||
android:layout_height="@dimen/custom_margin60dp"
|
android:layout_width="wrap_content"
|
||||||
android:indeterminate="true"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<im.delight.android.webview.AdvancedWebView
|
<!-- QR CODE -->
|
||||||
android:id="@+id/webviewbaAssessment"
|
<!-- ROUNDED CORNER QR CARD -->
|
||||||
android:layout_width="match_parent"
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_height="match_parent"
|
android:layout_width="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:cardCornerRadius="16dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:cardElevation="5dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
android:layout_gravity="center"
|
||||||
|
app:cardUseCompatPadding="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/qrImage"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="320dp"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="QR Code" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<!-- SPACE -->
|
||||||
|
<!-- TEXT -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Scan this QR code\n to start BA Assessment"
|
||||||
|
android:textSize="@dimen/text_size_16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -4,29 +4,56 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".dailyactivity.BaAssessmentActivity"
|
|
||||||
android:background="@color/grey_background"
|
android:background="@color/grey_background"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context=".dailyactivity.BaAssessmentActivity"
|
||||||
tools:showIn="@layout/activity_ba_assessment">
|
tools:showIn="@layout/activity_ba_assessment">
|
||||||
|
|
||||||
<ProgressBar
|
<!-- CENTER CONTAINER -->
|
||||||
android:id="@+id/progressBar"
|
<LinearLayout
|
||||||
android:layout_width="@dimen/custom_margin60dp"
|
android:id="@+id/container"
|
||||||
android:layout_height="@dimen/custom_margin60dp"
|
android:layout_width="wrap_content"
|
||||||
android:indeterminate="true"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<im.delight.android.webview.AdvancedWebView
|
<!-- QR CODE -->
|
||||||
android:id="@+id/webviewbaAssessment"
|
<!-- ROUNDED CORNER QR CARD -->
|
||||||
android:layout_width="match_parent"
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_height="match_parent"
|
android:layout_width="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:cardCornerRadius="16dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:cardElevation="5dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
android:layout_gravity="center"
|
||||||
|
app:cardUseCompatPadding="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/qrImage"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="320dp"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="QR Code" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<!-- SPACE -->
|
||||||
|
<!-- TEXT -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Scan this QR code\n to start BA Assessment"
|
||||||
|
android:textSize="@dimen/text_size_16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#Fri Dec 19 17:45:22 IST 2025
|
#Tue Dec 30 12:37:22 IST 2025
|
||||||
com.androidbuts.multispinnerfilter.library-main-5\:/layout/activity_main.xml=D\:\\jeevanp_cpm_projects\\LorealBaProjects\\LorealBa-Latest-2024\\library\\build\\intermediates\\packaged_res\\release\\layout\\activity_main.xml
|
com.androidbuts.multispinnerfilter.library-main-5\:/layout/activity_main.xml=D\:\\jeevanp_cpm_projects\\LorealBaProjects\\LorealBa-Latest-2024\\library\\build\\intermediates\\packaged_res\\release\\layout\\activity_main.xml
|
||||||
com.androidbuts.multispinnerfilter.library-main-5\:/layout/alert_dialog_listview_search.xml=D\:\\jeevanp_cpm_projects\\LorealBaProjects\\LorealBa-Latest-2024\\library\\build\\intermediates\\packaged_res\\release\\layout\\alert_dialog_listview_search.xml
|
com.androidbuts.multispinnerfilter.library-main-5\:/layout/alert_dialog_listview_search.xml=D\:\\jeevanp_cpm_projects\\LorealBaProjects\\LorealBa-Latest-2024\\library\\build\\intermediates\\packaged_res\\release\\layout\\alert_dialog_listview_search.xml
|
||||||
com.androidbuts.multispinnerfilter.library-main-5\:/layout/item_listview_multiple.xml=D\:\\jeevanp_cpm_projects\\LorealBaProjects\\LorealBa-Latest-2024\\library\\build\\intermediates\\packaged_res\\release\\layout\\item_listview_multiple.xml
|
com.androidbuts.multispinnerfilter.library-main-5\:/layout/item_listview_multiple.xml=D\:\\jeevanp_cpm_projects\\LorealBaProjects\\LorealBa-Latest-2024\\library\\build\\intermediates\\packaged_res\\release\\layout\\item_listview_multiple.xml
|
||||||
|
|||||||
Reference in New Issue
Block a user