Permission handling Library ,Espresso and Validation Attributes Added
This commit is contained in:
@@ -4,21 +4,20 @@
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".crash"></activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
@@ -28,66 +27,75 @@
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_path" />
|
||||
</provider>
|
||||
<activity android:name=".NegativeResults" android:screenOrientation="portrait"
|
||||
></activity>
|
||||
<activity android:name=".PositiveResult" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".TestDetails" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".Register" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".ForgetPassword" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".CreatePassword" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".Home" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".VerifyOTP.VerifyOtp" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".ForgetPasswordReset" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".VerifyOTP.VerifyOtpForgetPassword" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".SplashScreen" android:screenOrientation="portrait"
|
||||
> <intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter></activity>
|
||||
<activity android:name=".MainActivity" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".Report" android:screenOrientation="portrait"
|
||||
>
|
||||
|
||||
</activity>
|
||||
<activity android:name=".NavigationTop" android:screenOrientation="portrait"
|
||||
/>
|
||||
<activity android:name=".LoginScreen" android:screenOrientation="portrait"
|
||||
/>
|
||||
|
||||
|
||||
<activity android:name=".AddImage" android:screenOrientation="portrait"
|
||||
></activity>
|
||||
<activity android:name=".CameraGuide" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".About" android:screenOrientation="portrait" />
|
||||
<activity android:name=".PatientDetail" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".TestResult" android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<activity
|
||||
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
|
||||
android:name=".NegativeResults"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".PositiveResult"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".TestDetails"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".Register"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ForgetPassword"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".CreatePassword"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".Home"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".VerifyOTP.VerifyOtp"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ForgetPasswordReset"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".VerifyOTP.VerifyOtpForgetPassword"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".SplashScreen"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".Report"
|
||||
android:screenOrientation="portrait"></activity>
|
||||
<activity
|
||||
android:name=".NavigationTop"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".LoginScreen"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".AddImage"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".CameraGuide"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".About"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".PatientDetail"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".TestResult"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
|
||||
android:theme="@style/Base.Theme.AppCompat" />
|
||||
</application>
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.theartofdev.edmodo.cropper.CropImageView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
@@ -332,12 +333,16 @@ public class AddImage extends NavigationTop {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy");
|
||||
saveCurrentDate = currentDate.format(calendar.getTime());
|
||||
|
||||
SimpleDateFormat currentTime = new SimpleDateFormat("HH:mm:ss a");
|
||||
saveCurrentDate = currentDate.format(calendar.getTime());
|
||||
saveCurrentDate = saveCurrentDate .replaceAll("[^A-Za-z0-9 ]","");
|
||||
|
||||
|
||||
SimpleDateFormat currentTime = new SimpleDateFormat("h:mm a");
|
||||
saveCurrentTime = currentTime.format(calendar.getTime());
|
||||
|
||||
TestRandomKey = saveCurrentDate + saveCurrentTime+number;
|
||||
TestRandomKey = TestRandomKey .replaceAll("[^A-Za-z0-9 ]","");
|
||||
|
||||
|
||||
final StorageReference filePath1 =TestImagesRef.child(ImageUri1.getLastPathSegment() + TestRandomKey + ".jpg");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package in.sminnovations.arrest_tb;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
@@ -9,7 +10,9 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -24,7 +27,14 @@ import android.widget.Toast;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.karumi.dexter.Dexter;
|
||||
import com.karumi.dexter.MultiplePermissionsReport;
|
||||
import com.karumi.dexter.PermissionToken;
|
||||
import com.karumi.dexter.listener.PermissionRequest;
|
||||
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class PatientDetail extends NavigationTop implements AdapterView.OnItemSelectedListener {
|
||||
private Button next_act;
|
||||
@@ -105,7 +115,55 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
if (patientid.equals("") || patientage.equals("") || patientnikshayid.equals("")) {
|
||||
Toast.makeText(PatientDetail.this, "Please fill all fields", Toast.LENGTH_SHORT).show();
|
||||
|
||||
} else {
|
||||
}
|
||||
else if (patientid.length()!=5 )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Patient Id must be 5 characters", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (patientid.matches("^[a-zA-Z]*$") || patientid.matches("^[0-9]*$") )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Patient Id must be alphanumeric", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
/* else if ( patientagedigit>100)
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Enter a valid Age", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
else if(Integer.parseInt(String.valueOf(Age.getText()))>100 || Integer.parseInt(String.valueOf(Age.getText()))<1) {
|
||||
|
||||
|
||||
Toast.makeText(PatientDetail.this, "Enter a valid Age", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if ( patientnikshayid.length()<8 )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Nikshay Id must be 8 or 9 digit Number ", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if ( patientnikshayid.length()>9 )
|
||||
{
|
||||
Toast.makeText(PatientDetail.this, "Nikshay Id must be 8 or 9 digit Number ", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else {
|
||||
locationpermission();
|
||||
getLocation();
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences("PhoneBook", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@@ -196,6 +254,60 @@ public class PatientDetail extends NavigationTop implements AdapterView.OnItemSe
|
||||
gpsTracker.showSettingsAlert();
|
||||
}
|
||||
}
|
||||
private void locationpermission()
|
||||
{
|
||||
/* Dexter.withContext(this).withPermission(Manifest.permission.ACCESS_FINE_LOCATION).withListener(new PermissionListener() {
|
||||
@Override
|
||||
public void onPermissionGranted(PermissionGrantedResponse permissionGrantedResponse) {
|
||||
getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionDenied(PermissionDeniedResponse permissionDeniedResponse) {
|
||||
Intent intent=new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri =Uri.fromParts("package",getPackageName(),"");
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionRationaleShouldBeShown(PermissionRequest permissionRequest, PermissionToken permissionToken) {
|
||||
permissionToken.continuePermissionRequest();
|
||||
|
||||
}
|
||||
}).check();
|
||||
*/
|
||||
Dexter.withContext(this).withPermissions(Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION).withListener(new MultiplePermissionsListener() {
|
||||
@Override
|
||||
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
|
||||
if(multiplePermissionsReport.areAllPermissionsGranted())
|
||||
{
|
||||
getLocation();
|
||||
}
|
||||
if(multiplePermissionsReport.isAnyPermissionPermanentlyDenied())
|
||||
{
|
||||
Intent intent=new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri =Uri.fromParts("package",getPackageName(),"");
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
|
||||
permissionToken.continuePermissionRequest();
|
||||
|
||||
}
|
||||
}).check();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,34 @@ public class TestResult extends NavigationTop implements AdapterView.OnItemSelec
|
||||
if (NIRTLabde.equals("") || SPINTubeIDde.equals("") || sampled.equals("")) {
|
||||
Toast.makeText(TestResult.this, "Please fill all fields", Toast.LENGTH_SHORT).show();
|
||||
|
||||
} else {
|
||||
}
|
||||
else if ( NIRTLabde.length()!=7 )
|
||||
|
||||
{
|
||||
Toast.makeText(TestResult.this, "NIRT Lab Number must be 7 characters", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if (NIRTLabde.matches("^[a-zA-Z]*$") || NIRTLabde.matches("^[0-9]*$") )
|
||||
|
||||
{
|
||||
Toast.makeText(TestResult.this, "NIRT Lab Number must be alphanumeric", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if (SPINTubeIDde.length()!=6 )
|
||||
{
|
||||
Toast.makeText(TestResult.this, "Spin Tube ID must be 6 characters", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else if (SPINTubeIDde.matches("^[a-zA-Z]*$") || SPINTubeIDde.matches("^[0-9]*$") )
|
||||
{
|
||||
Toast.makeText(TestResult.this, "Spin Tube ID must be alphanumeric", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
if(ContextCompat.checkSelfPermission(TestResult.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
|
||||
|
||||
23
app/src/main/java/in/sminnovations/arrest_tb/crash.java
Normal file
23
app/src/main/java/in/sminnovations/arrest_tb/crash.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package in.sminnovations.arrest_tb;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class crash extends AppCompatActivity {
|
||||
Button d;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_crash);
|
||||
d.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
throw new RuntimeException("app crashed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
14
app/src/main/res/layout/activity_crash.xml
Normal file
14
app/src/main/res/layout/activity_crash.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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=".crash">
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/gg"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user