Initial commit
This commit is contained in:
parent
3d98bb7663
commit
c1bc64478c
|
|
@ -36,6 +36,7 @@ dependencies {
|
|||
testImplementation 'junit:junit:4.13.2'
|
||||
implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
|
||||
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.espresso:espresso-core:3.5.1'
|
||||
}
|
||||
|
|
@ -13,8 +13,9 @@
|
|||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.PlantDatabse"
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
tools:targetApi="31">
|
||||
|
||||
<activity
|
||||
android:name=".WebViewActivity"
|
||||
android:exported="false" />
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
// of IntentIntegrator class
|
||||
// which is the class of QR library
|
||||
IntentIntegrator intentIntegrator = new IntentIntegrator(this);
|
||||
intentIntegrator.setPrompt("Scan a barcode or QR Code");
|
||||
intentIntegrator.setPrompt(getString(R.string.scan_qr));
|
||||
intentIntegrator.setOrientationLocked(true);
|
||||
intentIntegrator.setCaptureActivity(CustomScannerActivity.class);
|
||||
intentIntegrator.initiateScan();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
package com.sultan.plantdatabse;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.zxing.integration.android.IntentIntegrator;
|
||||
|
||||
public class WebViewActivity extends AppCompatActivity {
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -20,7 +26,27 @@ public class WebViewActivity extends AppCompatActivity {
|
|||
WebView webView = findViewById(R.id.webView);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
assert url != null;
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:visibility="gone"
|
||||
android:text="messageContent"/>
|
||||
|
||||
<TextView
|
||||
|
|
@ -21,15 +22,23 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
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
|
||||
android:id="@+id/scanBtn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="#0F9D58"
|
||||
android:layout_gravity="center"
|
||||
android:text="Scan"/>
|
||||
android:text="Scan QR Code" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -11,4 +11,12 @@
|
|||
android:layout_width="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>
|
||||
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
|
|
@ -1,3 +1,4 @@
|
|||
<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>
|
||||
|
|
@ -13,5 +13,5 @@ dependencyResolutionManagement {
|
|||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Plant Databse"
|
||||
rootProject.name = "Plant Database"
|
||||
include ':app'
|
||||
|
|
|
|||
Loading…
Reference in New Issue