added qr-code generator in ba-assessment
This commit is contained in:
@@ -13,3 +13,9 @@
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
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;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
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.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
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.cpm.lorealbaautomation.Database.Lorealba_Database;
|
||||
import com.cpm.lorealbaautomation.R;
|
||||
import com.cpm.lorealbaautomation.constant.AlertandMessages;
|
||||
import com.cpm.lorealbaautomation.constant.CommonFunctions;
|
||||
import com.cpm.lorealbaautomation.constant.CommonString;
|
||||
import com.cpm.lorealbaautomation.delegates.PrefHelper;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.JourneyPlan;
|
||||
import com.cpm.lorealbaautomation.gsonGetterSetter.MasterSurvey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.journeyapps.barcodescanner.BarcodeEncoder;
|
||||
import java.util.Objects;
|
||||
|
||||
import im.delight.android.webview.AdvancedWebView;
|
||||
|
||||
|
||||
public class BaAssessmentActivity extends AppCompatActivity {
|
||||
private final Handler loaderHandler = new Handler(Looper.getMainLooper());
|
||||
private String username;
|
||||
private String couter_code;
|
||||
private ImageView qrImage;
|
||||
private Lorealba_Database db;
|
||||
JourneyPlan jcp_Object = new JourneyPlan();
|
||||
AdvancedWebView webView;
|
||||
ProgressBar progressBar;
|
||||
private Runnable showLoaderRunnable;
|
||||
private boolean pageLoaded = false;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_ba_assessment);
|
||||
progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
||||
webView = (AdvancedWebView) findViewById(R.id.webviewbaAssessment);
|
||||
SharedPreferences preferences = PrefHelper.getPrefs(this);
|
||||
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, "");
|
||||
couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
String couter_code = preferences.getString(CommonString.KEY_COUNTER_CODE, "");
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
qrImage = findViewById(R.id.qrImage);
|
||||
setSupportActionBar(toolbar);
|
||||
if (!CommonFunctions.isTablet(this)) {
|
||||
toolbar.setTitleTextAppearance(this, R.style.changestext_sizefor_mobile);
|
||||
@@ -78,12 +47,9 @@ public class BaAssessmentActivity extends AppCompatActivity {
|
||||
db.open();
|
||||
jcp_Object = db.getBIDfromJCP(username, counter_id);
|
||||
setTitle("BA Assessment - " + date);
|
||||
|
||||
if (CommonFunctions.checkNetIsAvailable(this)) {
|
||||
loadWeb();
|
||||
} else {
|
||||
AlertandMessages.showToastMsg(this, getString(R.string.nonetwork));
|
||||
}
|
||||
String link = CommonString.BA_ASSESSMENT_URL + "c=" + couter_code + "&u=" + username;
|
||||
Log.e("link", link);
|
||||
generateQRCode(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,52 +72,23 @@ public class BaAssessmentActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
this.finish();
|
||||
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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".dailyactivity.BaAssessmentActivity"
|
||||
android:background="@color/grey_background"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".dailyactivity.BaAssessmentActivity"
|
||||
tools:showIn="@layout/activity_ba_assessment">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="@dimen/custom_margin60dp"
|
||||
android:layout_height="@dimen/custom_margin60dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"
|
||||
<!-- CENTER CONTAINER -->
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<im.delight.android.webview.AdvancedWebView
|
||||
android:id="@+id/webviewbaAssessment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
<!-- QR CODE -->
|
||||
<!-- ROUNDED CORNER QR CARD -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="5dp"
|
||||
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>
|
||||
@@ -4,29 +4,56 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".dailyactivity.BaAssessmentActivity"
|
||||
android:background="@color/grey_background"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".dailyactivity.BaAssessmentActivity"
|
||||
tools:showIn="@layout/activity_ba_assessment">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="@dimen/custom_margin60dp"
|
||||
android:layout_height="@dimen/custom_margin60dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"
|
||||
<!-- CENTER CONTAINER -->
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<im.delight.android.webview.AdvancedWebView
|
||||
android:id="@+id/webviewbaAssessment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
<!-- QR CODE -->
|
||||
<!-- ROUNDED CORNER QR CARD -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="5dp"
|
||||
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>
|
||||
+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/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
|
||||
|
||||
Reference in New Issue
Block a user