Initial commit

This commit is contained in:
Sultan Mustafijul Hoque 2023-12-05 18:07:20 +05:30
parent 1117f8037a
commit d5735b9053
7 changed files with 64 additions and 5 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -14,6 +15,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.PlantDatabse" android:theme="@style/Theme.PlantDatabse"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".WebViewActivity"
android:exported="false" />
<activity <activity
android:name=".CustomScannerActivity" android:name=".CustomScannerActivity"
android:exported="false" android:exported="false"

View File

@ -70,10 +70,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// Extract the dynamic part after "&" and display it in messageText // Extract the dynamic part after "&" and display it in messageText
String dynamicPart = extractDynamicPart(scannedContent); String dynamicPart = extractDynamicPart(scannedContent);
messageText.setText("Dynamic Part: " + dynamicPart);
// Display the scanned code format // Construct the full URL by appending the dynamic part to the base URL
messageFormat.setText("Format: " + intentResult.getFormatName()); String fullUrl = "https://bhalumni.in/view/plant-database/entry/" + dynamicPart;
// Open the WebView activity with the constructed URL
openWebViewActivity(fullUrl);
// Vibrate for 200 milliseconds on successful read // Vibrate for 200 milliseconds on successful read
if (vibrator != null) { if (vibrator != null) {
@ -93,4 +95,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
return ""; return "";
} }
// Custom method to open WebView activity with the specified URL
private void openWebViewActivity(String url) {
Intent webViewIntent = new Intent(this, WebViewActivity.class);
webViewIntent.putExtra("url", url);
startActivity(webViewIntent);
}
} }

View File

@ -0,0 +1,26 @@
package com.sultan.plantdatabse;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
public class WebViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_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());
webView.loadUrl(url);
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WebViewActivity">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>