diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..b366460 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..006b18b --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.sultan.plantdatabse", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0.beta", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/src/main/assets/error_404.html b/app/src/main/assets/error_404.html new file mode 100644 index 0000000..022a438 --- /dev/null +++ b/app/src/main/assets/error_404.html @@ -0,0 +1,13 @@ + + +
+ + + +The requested page could not be found. Please check the URL and try again.
+ + diff --git a/app/src/main/assets/error_generic.html b/app/src/main/assets/error_generic.html new file mode 100644 index 0000000..88b100c --- /dev/null +++ b/app/src/main/assets/error_generic.html @@ -0,0 +1,13 @@ + + + + + + +Sorry, an error occurred while processing your request. Please try again later.
+ + diff --git a/app/src/main/assets/network_error.html b/app/src/main/assets/network_error.html new file mode 100644 index 0000000..473b7c2 --- /dev/null +++ b/app/src/main/assets/network_error.html @@ -0,0 +1,13 @@ + + + + + + +Sorry, there is an issue with your network connection. Please check your internet connection and try again.
+ + diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..ac22132 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/sultan/plantdatabse/WebViewActivity.java b/app/src/main/java/com/sultan/plantdatabse/WebViewActivity.java index 909e9af..eeb4a8d 100644 --- a/app/src/main/java/com/sultan/plantdatabse/WebViewActivity.java +++ b/app/src/main/java/com/sultan/plantdatabse/WebViewActivity.java @@ -22,10 +22,8 @@ import com.google.zxing.integration.android.IntentResult; public class WebViewActivity extends AppCompatActivity implements View.OnClickListener { - // private ProgressBar progressBar; private LottieAnimationView lottieAnimationView; - Button scanAgainButton; - Button btnHome; + private WebView webView; @SuppressLint("SetJavaScriptEnabled") @Override @@ -33,48 +31,67 @@ public class WebViewActivity extends AppCompatActivity implements View.OnClickLi super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview); - scanAgainButton = findViewById(R.id.scanAgain); - btnHome = findViewById(R.id.btnHome); - // progressBar = findViewById(R.id.progressBar); + Button scanAgainButton = findViewById(R.id.scanAgain); + Button btnHome = findViewById(R.id.btnHome); lottieAnimationView = findViewById(R.id.lottieAnimationView); + webView = findViewById(R.id.webView); // Retrieve the URL from the intent String url = getIntent().getStringExtra("url"); // Load the URL in the WebView - WebView webView = findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); - webView.setWebViewClient(new WebViewClient() { - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - // Show the progress bar when the page starts loading - // progressBar.setVisibility(View.VISIBLE); - // Show the Lottie animation when the page starts loading - lottieAnimationView.setVisibility(View.VISIBLE); - } - @Override - public void onPageFinished(WebView view, String url) { - // Hide the progress bar when the page finishes loading - // progressBar.setVisibility(View.INVISIBLE); - // Hide the Lottie animation when the page finishes loading - lottieAnimationView.setVisibility(View.INVISIBLE); - } - - @Override - public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { - // Handle page load error - Toast.makeText(WebViewActivity.this, "Failed to load the page", Toast.LENGTH_SHORT).show(); - // progressBar.setVisibility(View.INVISIBLE); - lottieAnimationView.setVisibility(View.INVISIBLE); - } - }); - - assert url != null; - webView.loadUrl(url); + webView.setWebViewClient(new CustomWebViewClient()); // Set click listeners scanAgainButton.setOnClickListener(this); btnHome.setOnClickListener(this); + + // Load the URL in the WebView + if (url != null) { + webView.loadUrl(url); + } else { + // Handle invalid URL + Toast.makeText(this, "Invalid URL", Toast.LENGTH_SHORT).show(); + finish(); + } + } + + private class CustomWebViewClient extends WebViewClient { + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + // Show the Lottie animation when the page starts loading + lottieAnimationView.setVisibility(View.VISIBLE); + } + + @Override + public void onPageFinished(WebView view, String url) { + // Hide the Lottie animation when the page finishes loading + lottieAnimationView.setVisibility(View.INVISIBLE); + } + + @Override + public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { + super.onReceivedError(view, request, error); + // Handle different types of errors + if (error.getErrorCode() == -2) { + // Network error (no internet connection) + showCustomErrorPage("file:///android_asset/network_error.html"); + } else if (error.getErrorCode() == 404) { + // 404 error (page not found) + showCustomErrorPage("file:///android_asset/error_404.html"); + } else { + // Other errors + showCustomErrorPage("file:///android_asset/error_generic.html"); + } + } + + private void showCustomErrorPage(String errorPageUrl) { + // Load the custom error page in the WebView + webView.loadUrl(errorPageUrl); + // Hide the Lottie animation + lottieAnimationView.setVisibility(View.INVISIBLE); + } } @Override diff --git a/app/src/main/res/drawable/bh_logo.png b/app/src/main/res/drawable/bh_logo.png new file mode 100644 index 0000000..7641841 Binary files /dev/null and b/app/src/main/res/drawable/bh_logo.png differ diff --git a/app/src/main/res/drawable/logo_a.png b/app/src/main/res/drawable/logo_a.png new file mode 100644 index 0000000..f113c2b Binary files /dev/null and b/app/src/main/res/drawable/logo_a.png differ diff --git a/app/src/main/res/drawable/logo_c_c.png b/app/src/main/res/drawable/logo_c_c.png new file mode 100644 index 0000000..104e911 Binary files /dev/null and b/app/src/main/res/drawable/logo_c_c.png differ diff --git a/app/src/main/res/drawable/logo_e.png b/app/src/main/res/drawable/logo_e.png new file mode 100644 index 0000000..4e08241 Binary files /dev/null and b/app/src/main/res/drawable/logo_e.png differ diff --git a/app/src/main/res/drawable/plant_logo.png b/app/src/main/res/drawable/plant_logo.png new file mode 100644 index 0000000..3ba47cc Binary files /dev/null and b/app/src/main/res/drawable/plant_logo.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3d0adf2..f1b9c4e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -8,6 +8,19 @@ android:background="@drawable/app_background_14" tools:context=".MainActivity"> +