mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
parent
cfde0b1e91
commit
49e8a6e6bb
|
@ -10,7 +10,6 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -19,12 +18,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
|
@ -79,22 +73,8 @@ public class ScannerDataManagerStubFragment extends Fragment {
|
||||||
Log.d("ScannerDataManagerStubFragment", "button_call_camera clicked");
|
Log.d("ScannerDataManagerStubFragment", "button_call_camera clicked");
|
||||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
||||||
File photoFile = null;
|
Log.d("ScannerDataManagerStubFragment", "camera available");
|
||||||
try {
|
cameraLauncher.launch(takePictureIntent);
|
||||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
|
|
||||||
String imageFileName = "JPEG_" + timeStamp + "_";
|
|
||||||
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
|
||||||
photoFile = File.createTempFile(imageFileName, ".jpg", storageDir);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Log.e("ScannerDataManagerStubFragment", "Error occurred while creating the file", ex);
|
|
||||||
}
|
|
||||||
if (photoFile != null) {
|
|
||||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoFile);
|
|
||||||
cameraLauncher.launch(takePictureIntent);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Log.d("ScannerDataManagerStubFragment", "photoFile is null");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.d("ScannerDataManagerStubFragment", "camera not available");
|
Log.d("ScannerDataManagerStubFragment", "camera not available");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user