Initial commit
This commit is contained in:
parent
1117f8037a
commit
d5735b9053
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -2,7 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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
|
||||
android:allowBackup="true"
|
||||
|
|
@ -14,6 +15,9 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.PlantDatabse"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".WebViewActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".CustomScannerActivity"
|
||||
android:exported="false"
|
||||
|
|
|
|||
|
|
@ -70,10 +70,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
// Extract the dynamic part after "&" and display it in messageText
|
||||
String dynamicPart = extractDynamicPart(scannedContent);
|
||||
messageText.setText("Dynamic Part: " + dynamicPart);
|
||||
|
||||
// Display the scanned code format
|
||||
messageFormat.setText("Format: " + intentResult.getFormatName());
|
||||
// Construct the full URL by appending the dynamic part to the base URL
|
||||
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
|
||||
if (vibrator != null) {
|
||||
|
|
@ -93,4 +95,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
||||
Loading…
Reference in New Issue