This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun updateTransform() { | |
val matrix = Matrix() | |
// Compute the center of the view finder | |
val centerX = viewFinder.width / 2f | |
val centerY = viewFinder.height / 2f | |
// Correct preview output to account for display rotation | |
val rotationDegrees = when(viewFinder.display.rotation) { | |
Surface.ROTATION_0 -> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun startCamera() { | |
// Create configuration object for the viewfinder use case | |
val previewConfig = PreviewConfig.Builder().apply { | |
setTargetAspectRatio(Rational(1, 1)) | |
setTargetResolution(Size(640, 640)) | |
}.build() | |
// Build the viewfinder use case | |
val preview = Preview(previewConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
// Add this at the end of onCreate function | |
viewFinder = findViewById(R.id.view_finder) | |
// Request camera permissions | |
if (allPermissionsGranted()) { | |
viewFinder.post { startCamera() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity(), LifecycleOwner { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
} | |
// Add this after onCreate | |
private lateinit var viewFinder: TextureView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Your IDE likely can auto-import these classes, but there are several | |
// different implementations so we list them here to disambiguate | |
import android.Manifest | |
import android.util.Size | |
import android.graphics.Matrix | |
import java.util.concurrent.TimeUnit | |
// This is an arbitrary number we are using to keep tab of the permission | |
// request. Where an app has multiple context for requesting permission, | |
// this can help differentiate the different contexts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<TextureView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
android:width="24dp" | |
android:height="24dp" | |
android:viewportWidth="24.0" | |
android:viewportHeight="24.0"> | |
<path | |
android:fillColor="?android:colorControlNormal" | |
android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/> | |
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
package="com.example.com"> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/ic_launcher" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
<!-- Customize your theme here. --> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorAccent">@color/colorAccent</item> | |
</style> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun addQuotations(orderId: String){ | |
var docRef : DocumentReference = FirebaseFirestore.getInstance().collection("orders").document(orderId) | |
var newQuotation = RetailerQuotationItem("retailer4","Retailer THree","",790.0, | |
SharedPreferencesDB.getSavedAddress(activity)!!,4.6) | |
docRef.update("quotations",FieldValue.arrayRemove(newQuotation)) | |
} |