Initial commit

This commit is contained in:
Sultan Mustafijul Hoque 2023-12-06 23:37:27 +05:30
parent 3d98bb7663
commit c1bc64478c
11 changed files with 56 additions and 7 deletions

View File

@ -36,6 +36,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
implementation 'com.journeyapps:zxing-android-embedded:4.1.0' implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
implementation 'com.karumi:dexter:6.2.2' implementation 'com.karumi:dexter:6.2.2'
implementation 'com.airbnb.android:lottie:6.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
} }

View File

@ -13,8 +13,9 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.PlantDatabse" android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
tools:targetApi="31"> tools:targetApi="31">
<activity <activity
android:name=".WebViewActivity" android:name=".WebViewActivity"
android:exported="false" /> android:exported="false" />

View File

@ -42,7 +42,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// of IntentIntegrator class // of IntentIntegrator class
// which is the class of QR library // which is the class of QR library
IntentIntegrator intentIntegrator = new IntentIntegrator(this); IntentIntegrator intentIntegrator = new IntentIntegrator(this);
intentIntegrator.setPrompt("Scan a barcode or QR Code"); intentIntegrator.setPrompt(getString(R.string.scan_qr));
intentIntegrator.setOrientationLocked(true); intentIntegrator.setOrientationLocked(true);
intentIntegrator.setCaptureActivity(CustomScannerActivity.class); intentIntegrator.setCaptureActivity(CustomScannerActivity.class);
intentIntegrator.initiateScan(); intentIntegrator.initiateScan();

View File

@ -1,13 +1,19 @@
package com.sultan.plantdatabse; package com.sultan.plantdatabse;
import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.google.zxing.integration.android.IntentIntegrator;
public class WebViewActivity extends AppCompatActivity { public class WebViewActivity extends AppCompatActivity {
@SuppressLint("SetJavaScriptEnabled")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -20,7 +26,27 @@ public class WebViewActivity extends AppCompatActivity {
WebView webView = findViewById(R.id.webView); WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient()); webView.setWebViewClient(new WebViewClient());
assert url != null;
webView.loadUrl(url); webView.loadUrl(url);
// Set an OnClickListener for the "Scan QR" button
Button scanAgainButton = findViewById(R.id.scanAgain);
scanAgainButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Handle button click, for example, initiate a new scan
initiateScan();
}
});
} }
private void initiateScan() {
// Initialize the IntentIntegrator and start the scan
IntentIntegrator intentIntegrator = new IntentIntegrator(this);
intentIntegrator.setPrompt(getString(R.string.scan_qr));
intentIntegrator.setOrientationLocked(true);
intentIntegrator.setCaptureActivity(CustomScannerActivity.class);
intentIntegrator.initiateScan();
}
} }

View File

@ -13,6 +13,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="10dp" android:layout_margin="10dp"
android:visibility="gone"
android:text="messageContent"/> android:text="messageContent"/>
<TextView <TextView
@ -21,15 +22,23 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="10dp" android:layout_margin="10dp"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:visibility="gone"/>
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="531dp"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/qr_scan_big_1" />
<Button <Button
android:id="@+id/scanBtn" android:id="@+id/scanBtn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp" android:layout_margin="10dp"
android:backgroundTint="#0F9D58" android:backgroundTint="#0F9D58"
android:layout_gravity="center" android:text="Scan QR Code" />
android:text="Scan"/>
</LinearLayout> </LinearLayout>

View File

@ -11,4 +11,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<Button
android:id="@+id/scanAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:text="Scan QR"/>
</RelativeLayout> </RelativeLayout>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
<resources> <resources>
<string name="app_name">Plant Databse</string> <string name="app_name">Plant Database</string>
<string name="scan_qr">SCAN QR CODE FOUND ON THE TREE</string>
</resources> </resources>

View File

@ -13,5 +13,5 @@ dependencyResolutionManagement {
} }
} }
rootProject.name = "Plant Databse" rootProject.name = "Plant Database"
include ':app' include ':app'