Merge branch 'master' of gitlab.com:smileomi18/arrest-tb

 Conflicts:
	app/build.gradle
	app/src/main/AndroidManifest.xml
	app/src/main/res/layout/activity_home.xml
	app/src/main/res/layout/head.xml
	app/src/main/res/menu/menu.xml
This commit is contained in:
developerraman
2020-10-27 21:33:32 -07:00
27 changed files with 1283 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "in.sminnovations.arresttb"
applicationId "com.ShanMukhaInnovations.ArrestTB"
minSdkVersion 19
targetSdkVersion 29
versionCode 1

View File

@@ -0,0 +1,27 @@
package com.ShanMukhaInnovations.ArrestTB;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.ShanMukhaInnovations.ArrestTB", appContext.getPackageName());
}
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.sminnovations.arresttb">
package="com.ShanMukhaInnovations.ArrestTB">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -23,15 +23,15 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_path" />
</provider>
<activity android:name="in.sminnovations.arresttb.Report">
<activity android:name=".Report">
</activity>
<activity android:name=".Add_Image"></activity>
<activity android:name=".AddImage"></activity>
<activity android:name=".Camera_Guide"></activity>
<activity android:name=".About" />
<activity android:name=".Test_details" />
<activity android:name=".Splash_Screen">
<activity android:name=".splash_screen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -41,12 +41,12 @@
</activity>
<activity android:name=".Patient_Detail" >
<activity android:name=".Patient_detail" >
</activity>
<activity android:name=".Home" />
<activity android:name=".home" />
<activity android:name=".Navigation_Top" />
<activity android:name=".Login_Screen">

View File

@@ -0,0 +1,22 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
public class About extends Navigation_Top {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_about, null, false);
draw.addView(contentView, 0);
//setContentView(R.layout.activity_about);
}
}

View File

@@ -0,0 +1,92 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
public class AddImage extends Navigation_Top {
de.hdodenhof.circleimageview.CircleImageView circle_image;
Button selection_image,report1;
private static final int PERMISSION_FILE=23;
String Data_report,patientid,patientdob,patientage,patientnikshayid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_add_image, null, false);
draw.addView(contentView, 0);
// setContentView(R.layout.activity_add_image);
circle_image=findViewById(R.id.circle_image);
patientdob= getIntent().getStringExtra("dob_report");
patientid=getIntent().getStringExtra("id_report");
patientage=getIntent().getStringExtra("age_report");
patientnikshayid=getIntent().getStringExtra("nikshay_report");
report1=findViewById(R.id.report);
report1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AddImage.this, Report.class);
startActivity(intent);
}
});
if(ContextCompat.checkSelfPermission(AddImage.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(AddImage.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},PERMISSION_FILE);
}
else
{
//startCropImageActivity();
CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.setCropShape(CropImageView.CropShape.OVAL)
.start(AddImage.this);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Uri resultUri = result.getUri();
circle_image.setImageURI(resultUri);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
}
}
}

View File

@@ -0,0 +1,60 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class Camera_Guide extends AppCompatActivity {
private Button Intro,report1;
String Data_report,patientid,patientgender,patientdob,patientage,patientnikshayid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_camera__guide);
Intro=findViewById(R.id.intro);
Intro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),AddImage.class );
startActivity(intent);
savePrefsData();
finish();
}
});
}
private void savePrefsData() {
SharedPreferences pref = getApplicationContext().getSharedPreferences("myPrefs",MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("isIntroOpnend",true);
editor.commit();
}
}

View File

@@ -0,0 +1,35 @@
package com.ShanMukhaInnovations.ArrestTB;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
public class FontAwesome extends AppCompatTextView {
public FontAwesome(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public FontAwesome(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public FontAwesome(Context context) {
super(context);
init();
}
private void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
"fa-solid-900.ttf");
setTypeface(tf);
}
}

View File

@@ -0,0 +1,70 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatCheckBox;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;
public class Login_Screen extends AppCompatActivity {
private EditText Username;
private Button login;
private android.widget.EditText Password;
private AppCompatCheckBox checkbox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login__screen);
Username=findViewById(R.id.username);
Password=findViewById(R.id.password);
login=findViewById(R.id.login);
checkbox = (AppCompatCheckBox) findViewById(R.id.showpassword);
Password = (EditText) findViewById(R.id.password);
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
// show password
Password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
// hide password
Password.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = Username.getText().toString();
String password = Password.getText().toString();
if(username.length()==0 || password.length()==0)
{
Toast.makeText(Login_Screen.this, "Please Fill all the fields", Toast.LENGTH_SHORT).show();
}
else if (username.equals("Arresttb") && password.equals("tb123")) {
Intent intent = new Intent(Login_Screen.this, home.class);
startActivity(intent);
} else {
Toast.makeText(Login_Screen.this, "Invalid Credentials ", Toast.LENGTH_SHORT).show();
}
}
});
}
}

View File

@@ -0,0 +1,80 @@
package com.ShanMukhaInnovations.ArrestTB;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.navigation.NavigationView;
public class Navigation_Top extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
protected DrawerLayout draw;
private LinearLayout line;
private Toolbar tool;
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId())
{
case R.id.logout:
Intent intent=new Intent(this,Login_Screen.class);
startActivity(intent);
break;
case R.id.nav_contact_us:
Intent intent1=new Intent(this,About.class);
startActivity(intent1);
break;
}
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_navigation__top);
draw = findViewById(R.id.Drawer);
line = findViewById(R.id.line);
tool = findViewById(R.id.tollbar);
NavigationView navigationView = findViewById(R.id.navigation);
navigationView.setNavigationItemSelectedListener(this);
setSupportActionBar(tool);
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, draw, tool, R.string.open_navigation_drawer, R.string.close_navigation_drawer) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
float sidebar = drawerView.getWidth() * slideOffset;
line.setTranslationX(sidebar);
}
};
draw.addDrawerListener(toggle);
toggle.syncState();
View headerView = navigationView.getHeaderView(0);
}
}

View File

@@ -0,0 +1,159 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.Calendar;
public class Patient_detail extends Navigation_Top implements AdapterView.OnItemSelectedListener {
private Button next_act;
private DatePickerDialog.OnDateSetListener mDateSetListener;
String patientid,patientdob,patientage,patientnikshayid;
String gender;
private EditText mDisplayDate,patient_ID,Age,NikshayId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_patient_detail, null, false);
draw.addView(contentView, 0);
Spinner Spinner_gender = findViewById(R.id.spinner_gender);
mDisplayDate=findViewById(R.id.dob);
patient_ID=findViewById(R.id.patientid);
Age=findViewById(R.id.age);
NikshayId=findViewById(R.id.NikshayID);
/* patient_ID.addTextChangedListener(loginTextWatcher);
Age.addTextChangedListener(loginTextWatcher);
NikshayId.addTextChangedListener(loginTextWatcher);
*/
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.Gender, android.R.layout.simple_spinner_item);
mDisplayDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mDisplayDate.setEnabled(true);
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(
Patient_detail.this,
android.R.style.Theme_Holo_Light_Dialog_MinWidth,
mDateSetListener,
year,month,day);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
});
mDateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
month = month + 1;
String date = month + "/" + day + "/" + year;
mDisplayDate.setText(date);
patientdob=date;
}
};
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner_gender.setAdapter(adapter);
Spinner_gender.setOnItemSelectedListener(this);
// setContentView(R.layout.activity_patient_detail);
next_act=findViewById(R.id.next);
next_act.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
patientid = patient_ID.getText().toString();
patientage = Age.getText().toString();
patientnikshayid = NikshayId.getText().toString();
if (patientid.equals("") || patientage.equals("") || patientnikshayid.equals("")) {
Toast.makeText(Patient_detail.this, "Please fill all fields", Toast.LENGTH_SHORT).show();
} else {
SharedPreferences preferences = getSharedPreferences("PhoneBook", MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
// editor.putString(Name, phonenum);
editor.putString("gender", gender);
editor.putString("patientid", patientid);
editor.putString("patientage", patientage);
editor.putString("patientnikshayid", patientnikshayid);
editor.putString("dob", patientdob);
editor.commit();
Intent intent = new Intent(Patient_detail.this, Test_details.class);
startActivity(intent);
}
}
});
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(parent.getId() == R.id.spinner_gender)
{
gender = parent.getItemAtPosition(position).toString();
//do this
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
/*private TextWatcher loginTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
next_act.setEnabled(!patientid.isEmpty() && !patientage.isEmpty() && !patientnikshayid.isEmpty());
}
@Override
public void afterTextChanged(Editable s) {
}
};*/
}

View File

@@ -0,0 +1,302 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.pdf.PdfDocument;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Report extends AppCompatActivity {
TextView patient_id,patient_dob,patientnikshayid,agepatient,patientgender,patientsample,validatyd,spintubeid,nirtlab,dated,timed,resultd;
ImageButton shared ,dowbloadd;
String string1,string2,string3,string4,string5,string6,string7,string8,string9,date,time;
File filePath=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_report);
/* super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_report, null, false);
draw.addView(contentView, 0);
*/
setContentView(R.layout.activity_report);
shared=findViewById(R.id.share);
dowbloadd=findViewById(R.id.downlaod);
patient_id=findViewById(R.id.patient_idr);
patient_dob=findViewById(R.id.patien_dobr);
patientnikshayid=findViewById(R.id.patient_nikshayidr);
agepatient=findViewById(R.id.patient_ager);
date = String.valueOf(android.text.format.DateFormat.format("dd-MM-yyyy", new java.util.Date()));
DateFormat df = new SimpleDateFormat("h:mm a");
time = df.format(Calendar.getInstance().getTime());
patientgender=findViewById(R.id.patient_genderr);
patientsample=findViewById(R.id.patient_typesampler);
validatyd=findViewById(R.id.patient_tubevisibler);
spintubeid=findViewById(R.id.patient_spintuber);
nirtlab=findViewById(R.id.patient_nirtr);
timed=findViewById(R.id.timer);
resultd=findViewById(R.id.patient_resultr);
dated=findViewById(R.id.dater);
dated.setText(date);
timed.setText(time);
resultd.setText("POSITIVE");
resultd.setTextColor(Color.RED);
SharedPreferences preferences=getSharedPreferences("PhoneBook",MODE_PRIVATE);
string1 = preferences.getString("gender", null);
string2 = preferences.getString("patientid", null);
string3 = preferences.getString("patientage", null);
string4 = preferences.getString("patientnikshayid", null);
string5 = preferences.getString("dob", null);
SharedPreferences preferences1=getSharedPreferences("PhoneBook1",MODE_PRIVATE);
string6 = preferences1.getString("NIRTLabde", null);
string7 = preferences1.getString("SPINTubeIDde", null);
string8 = preferences1.getString("sample", null);
string9 = preferences1.getString("validity", null);
shared.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(ContextCompat.checkSelfPermission(Report.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(Report.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
}
else
{
createPdf();
Intent intent=new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,"Report");
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) {
Uri path= FileProvider.getUriForFile(Report.this,"com.ShanMukhaInnovations.ArrestTB.fileprovider",filePath);
intent.putExtra(Intent.EXTRA_STREAM,path);
}
else{
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(filePath));
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("application/pdf");
startActivity(intent);
//startCropImageActivity();
// createPdf(editText.getText().toString());
}
//now for sharing file i need to create file provider for android version greater than noughat let's do it
//Everything WOrking
}
});
dowbloadd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ContextCompat.checkSelfPermission(Report.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(Report.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
}
else
{
//startCropImageActivity();
createPdf();
Toast.makeText(Report.this, "File Downloaded", Toast.LENGTH_LONG).show();
}
}
});
patient_id.setText(string2);
patient_dob.setText(string5);
patientgender.setText(string1);
patientnikshayid.setText(string4);
patientsample.setText(string8);
agepatient.setText(string3);
validatyd.setText(string9);
spintubeid.setText(string7);
nirtlab.setText(string6);
}
private void createPdf(){
// create a new document
PdfDocument document = new PdfDocument();
// crate a page description
PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(1000, 2000, 1).create();
// start a page
PdfDocument.Page page = document.startPage(pageInfo);
Canvas canvas = page.getCanvas();
Paint paint = new Paint();
paint.setTextSize(80);
canvas.drawText("Arrest Tb",40,80,paint);
paint.setTextSize(30);
canvas.drawText("ShanMukha Innovations Pvt Ltd",30,120,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(date,canvas.getWidth()-40,40,paint);
canvas.drawText(time,canvas.getWidth()-40,80,paint);
paint.setTextAlign(Paint.Align.LEFT);
paint.setColor(Color.rgb(150,150,150));
canvas.drawRect(30,250,canvas.getWidth()-30,300,paint);
paint.setColor(Color.WHITE);
canvas.drawText("Result",50,285,paint);
// canvas.drawText("name 2",450,435,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText("POSITIVE",canvas.getWidth()-40,285,paint);
paint.setTextAlign(Paint.Align.LEFT);
paint.setColor(Color.rgb(150,150,150));
// canvas.drawRect(30,150,canvas.getWidth()-30,160,paint);
canvas.drawRect(30,400,canvas.getWidth()-30,450,paint);
paint.setColor(Color.WHITE);
canvas.drawText("Patient ID",50,435,paint);
canvas.drawText("Patient Gender",450,435,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText("Date of Birth",canvas.getWidth()-40,435,paint);
paint.setTextAlign(Paint.Align.LEFT);
paint.setColor(Color.BLACK);
canvas.drawText(string2,50,480,paint);
canvas.drawText(string1,450,480,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(string5+".",canvas.getWidth()-40,480,paint);
paint.setTextAlign(Paint.Align.RIGHT);
paint.setColor(Color.rgb(150,150,150));
// canvas.drawRect(30,150,canvas.getWidth()-30,160,paint);
// canvas.drawRect(30,550,canvas.getWidth()-30,560,paint);
canvas.drawRect(30,570,canvas.getWidth()-30,620,paint);
paint.setColor(Color.WHITE);
canvas.drawText("Age",100,605,paint);
canvas.drawText("Nikshay ID ",540,605,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText("NIRT Lab Number",canvas.getWidth()-40,605,paint);
paint.setTextAlign(Paint.Align.LEFT);
paint.setColor(Color.BLACK);
canvas.drawText(string3,50,650,paint);
canvas.drawText(string4,440,650,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(string6,canvas.getWidth()-40,650,paint);
paint.setTextAlign(Paint.Align.RIGHT);
paint.setColor(Color.rgb(150,150,150));
canvas.drawRect(30,740,canvas.getWidth()-30,790,paint);
paint.setColor(Color.WHITE);
canvas.drawText("SPIN Tube ID",220,775,paint);
canvas.drawText("Type of Sample",540,775,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText("Tube Validity",canvas.getWidth()-40,775,paint);
paint.setTextAlign(Paint.Align.LEFT);
paint.setColor(Color.BLACK);
canvas.drawText(string7,50,820,paint);
canvas.drawText(string8,440,820,paint);
paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(string9,canvas.getWidth()-40,820,paint);
paint.setTextAlign(Paint.Align.RIGHT);
paint.setColor(Color.rgb(150,150,150));
// finish the page
document.finishPage(page);
/* File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"Raman.pdf");
// write the document content
*//*String directory_path = Environment.getExternalStorageDirectory().getPath() + "/ArrestTb/";
File file = new File(directory_path);
if (!file.exists()) {
file.mkdirs();
}*//*
// String targetPdf = directory_path+"Report_"+string2+".pdf";
filePath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"Report_"+string2+".pdf");
*/
String directory_path = Environment.getExternalStorageDirectory().getPath() + "/ArrestTb/";
File file = new File(directory_path);
if (!file.exists()) {
file.mkdirs();
}
String targetPdf = directory_path+"Report_"+string2+".pdf";
filePath = new File(targetPdf);
try {
document.writeTo(new FileOutputStream(filePath));
} catch (IOException e) {
Log.e("main", "error "+e.toString());
}
// filePath= new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"Report_"+string2+".pdf");
// close the document
document.close();
}
}

View File

@@ -0,0 +1,162 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
public class Test_details extends Navigation_Top implements AdapterView.OnItemSelectedListener {
Button btnTest;
EditText NIRTLabd,SPINTubeIDd;
String NIRTLabde,SPINTubeIDde,validatyd,sampled;
int PERMISSION_ALL = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_test_details, null, false);
draw.addView(contentView, 0);
Spinner Spinner_sample = findViewById(R.id.spinner_sample);
// editor.putString(Name, phonenum);
NIRTLabd=findViewById(R.id.NIRTLab);
SPINTubeIDd=findViewById(R.id.SPINTubeID);
btnTest=findViewById(R.id.startTest);
btnTest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NIRTLabde = NIRTLabd.getText().toString();
SPINTubeIDde = SPINTubeIDd.getText().toString();
if (NIRTLabde.equals("") || SPINTubeIDde.equals("") || sampled.equals("")) {
Toast.makeText(Test_details.this, "Please fill all fields", Toast.LENGTH_SHORT).show();
} else {
if(ContextCompat.checkSelfPermission(Test_details.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(Test_details.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant
return;
}
SharedPreferences preferences = getSharedPreferences("PhoneBook1", MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("NIRTLabde", NIRTLabde);
editor.putString("SPINTubeIDde", SPINTubeIDde);
editor.putString("sample", sampled);
editor.putString("validity", validatyd);
editor.commit();
if (restorePrefData()) {
Intent intent = new Intent(getApplicationContext(), AddImage.class);
startActivity(intent);
finish();
} else {
Intent intent = new Intent(getApplicationContext(), Camera_Guide.class);
startActivity(intent);
finish();
}
}
}
});
ArrayAdapter<CharSequence> sample_adapter = ArrayAdapter.createFromResource(this,
R.array.Type_Of_Sample, android.R.layout.simple_spinner_item);
sample_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner_sample.setAdapter(sample_adapter);
Spinner_sample.setOnItemSelectedListener(this);
Spinner Spinner_validity = findViewById(R.id.spinner_validity);
ArrayAdapter<CharSequence> Validity_adapter = ArrayAdapter.createFromResource(this,
R.array.Validity, android.R.layout.simple_spinner_item);
Validity_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner_validity.setAdapter(Validity_adapter);
Spinner_validity.setOnItemSelectedListener(this);
}
private boolean restorePrefData() {
SharedPreferences pref = getApplicationContext().getSharedPreferences("myPrefs",MODE_PRIVATE);
Boolean isIntroActivityOpnendBefore = pref.getBoolean("isIntroOpnend",false);
return isIntroActivityOpnendBefore;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(parent.getId() == R.id.spinner_sample)
{
sampled = parent.getItemAtPosition(position).toString();
//do this
}
if(parent.getId() == R.id.spinner_validity)
{
validatyd = parent.getItemAtPosition(position).toString();
//do this
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}

View File

@@ -0,0 +1,41 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
public class home extends Navigation_Top {
private Button add_patient,about;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_home, null, false);
draw.addView(contentView, 0);
add_patient=findViewById(R.id.register_user);
about=findViewById(R.id.aboutus);
add_patient.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent (home.this,Patient_detail.class);
startActivity(intent);
}
});
about.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent (home.this,About.class);
startActivity(intent);
}
});
//setContentView(R.layout.activity_home);
}
}

View File

@@ -0,0 +1,27 @@
package com.ShanMukhaInnovations.ArrestTB;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class splash_screen extends AppCompatActivity {
private static int SPLASH_TIME_OUT=3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent home = new Intent(splash_screen.this, Login_Screen.class);
startActivity(home);
finish();
}
}, SPLASH_TIME_OUT);
}
}

View File

@@ -70,7 +70,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<in.sminnovations.arresttb.Font_Awesome
<com.ShanMukhaInnovations.ArrestTB.FontAwesome
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@@ -81,7 +81,7 @@
android:textStyle="normal"
android:fontFamily="sans-serif"
></in.sminnovations.arresttb.Font_Awesome>
></com.ShanMukhaInnovations.ArrestTB.FontAwesome>
<TextView
@@ -119,7 +119,7 @@ android:fontFamily="@font/fontstyle"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<in.sminnovations.arresttb.Font_Awesome
<com.ShanMukhaInnovations.ArrestTB.FontAwesome
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@@ -130,7 +130,7 @@ android:fontFamily="@font/fontstyle"
android:id="@+id/patient_details"
></in.sminnovations.arresttb.Font_Awesome>
></com.ShanMukhaInnovations.ArrestTB.FontAwesome>
<TextView
android:textSize="14sp"
@@ -173,7 +173,7 @@ android:fontFamily="@font/fontstyle"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<in.sminnovations.arresttb.Font_Awesome
<com.ShanMukhaInnovations.ArrestTB.FontAwesome
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@@ -184,7 +184,7 @@ android:fontFamily="@font/fontstyle"
android:textSize="40dp"
></in.sminnovations.arresttb.Font_Awesome>
></com.ShanMukhaInnovations.ArrestTB.FontAwesome>
<TextView
android:textSize="14sp"
@@ -219,7 +219,7 @@ android:fontFamily="@font/fontstyle"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<in.sminnovations.arresttb.Font_Awesome
<com.ShanMukhaInnovations.ArrestTB.FontAwesome
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@@ -230,7 +230,7 @@ android:fontFamily="@font/fontstyle"
android:text="&#xf05a;"
></in.sminnovations.arresttb.Font_Awesome>
></com.ShanMukhaInnovations.ArrestTB.FontAwesome>
<TextView
android:textSize="14sp"

View File

@@ -18,7 +18,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<in.sminnovations.arresttb.Font_Awesome
<com.ShanMukhaInnovations.ArrestTB.FontAwesome
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50dp"
@@ -27,7 +27,7 @@
android:layout_marginTop="30dp"
android:id="@+id/image"
android:textColor="@android:color/white"
></in.sminnovations.arresttb.Font_Awesome>
></com.ShanMukhaInnovations.ArrestTB.FontAwesome>
<TextView
android:layout_width="wrap_content"

View File

@@ -0,0 +1,17 @@
package com.ShanMukhaInnovations.ArrestTB;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

0
docs/.gitkeep Normal file
View File

BIN
docs/ARREST-TB.pptx Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,52 @@
clc;
close all;
for l = 2:21
sum=0;
% l=9;
grayImage = strcat('e_images_', num2str(l), '.jpg');
grayImage=imread(grayImage);
fontSize = 10;
maxRows = 0;
maxCols = 0;
for k = 1 : l
% read images.....
[rows, columns, numberOfSlices] = size(grayImage);
if rows > maxRows
maxRows = rows;
end
if columns > maxCols
maxCols = columns;
end
end
for k = 1:l
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
grayImage = rgb2gray(grayImage);
end
figure(1);
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
end
%% Extract left half and display histogram
middleColumn = floor(columns/2);
leftHalfImage = grayImage(:,1:middleColumn);
T = adaptthresh(leftHalfImage,0.5,'ForegroundPolarity','dark');
binaryImage1= imbinarize(leftHalfImage,T);
figure(1);
subplot(2, 2, 2);
imshow(binaryImage1, []);
title('left half', 'FontSize', fontSize);
%% Extract right half and display histogram
middleColumn = floor(columns/2);
rightHalfImage = grayImage(:, middleColumn+1:end);
T = adaptthresh(rightHalfImage,0.5,'ForegroundPolarity','dark');
binaryImage2= imbinarize(rightHalfImage,T);
figure(1);
subplot(2, 2, 3);
imshow(binaryImage2, []);
title('right half', 'FontSize', fontSize);
end

View File

@@ -0,0 +1,12 @@
setDir = fullfile(toolboxdir('machine'),'machine data','imagesets');
imds = imageDatastore(setDir,'IncludeSubfolders',true,'LabelSource',...
'foldernames');
[trainingSet,testSet] = splitEachLabel(imds,0.3,'randomize');
bag = bagOfFeatures(trainingSet);
categoryClassifier = trainImageCategoryClassifier(trainingSet,bag);
confMatrix = evaluate(categoryClassifier,testSet)
mean(diag(confMatrix))
img = imread(fullfile(setDir,'negative','e_images_3.jpg'));
[labelIdx, score] = predict(categoryClassifier,img);
categoryClassifier.Labels(labelIdx)

View File

@@ -0,0 +1,107 @@
clc;
close all;
clear all;
%% Read the data set
imageFolder = fullfile(toolboxdir('machine'),'machine data','imagesets');
imds = imageDatastore(imageFolder,'IncludeSubfolders',true,'LabelSource',...
'foldernames');% Find the first instance of an image for each category
positive = find(imds.Labels == 'positive', 1);
figure(1);
imshow(readimage(imds,positive));
%%
tbl = countEachLabel(imds);
% Determine the smallest amount of images in a category
minSetCount = min(tbl{:,2});
maxNumImages = 100;
minSetCount = min(maxNumImages,minSetCount);
% Use splitEachLabel method to trim the set.
imds = splitEachLabel(imds, minSetCount, 'randomize');
% Notice that each set now has exactly the same number of images.
countEachLabel(imds)
% Load pretrained network
% Visualize the first section of the network.
% figure(2);
% net = resnet50();
net = vgg16();
% net = vgg16('Weights','imagenet')
% layers = vgg16('Weights','none')
% plot(net);
% title('First section of resnet-50')
% set(gca,'YLim',[150 170]);
%%
% Inspect the first layer
net.Layers(1)
% Inspect the last layer
net.Layers(end)
% Number of class names for ImageNet classification task
numel(net.Layers(end).ClassNames)
[trainingSet, testSet] = splitEachLabel(imds, 0.3, 'randomize');
% Create augmentedImageDatastore from training and test sets to resize
% images in imds to the size required by the network.
imageSize = net.Layers(1).InputSize;
augmentedTrainingSet = augmentedImageDatastore(imageSize, trainingSet, 'ColorPreprocessing', 'gray2rgb');
augmentedTestSet = augmentedImageDatastore(imageSize, testSet, 'ColorPreprocessing', 'gray2rgb');
% Get the network weights for the second convolutional layer
w1 = net.Layers(2).Weights;
% Scale and resize the weights for visualization
w1 = mat2gray(w1);
w1 = imresize(w1,5);
% Display a montage of network weights. There are 96 individual sets of
% weights in the first layer.
figure(3);
montage(w1);
title('First convolutional layer weights')
%(resnet-50)
% featureLayer = 'fc1000';
%vgg-16
featureLayer = 'fc8';
trainingFeatures = activations(net, augmentedTrainingSet, featureLayer, ...
'MiniBatchSize', 32, 'OutputAs', 'columns');
%%
% Get training labels from the trainingSet
trainingLabels = trainingSet.Labels;
% Train multiclass SVM classifier using a fast linear solver, and set
% 'ObservationsIn' to 'columns' to match the arrangement used for training
% features.
classifier = fitcecoc(trainingFeatures, trainingLabels, ...
'Learners', 'Linear', 'Coding', 'onevsall', 'ObservationsIn', 'columns');
%%
% Extract test features using the CNN
testFeatures = activations(net, augmentedTestSet, featureLayer, ...
'MiniBatchSize', 32, 'OutputAs', 'columns');
% Pass CNN image features to trained classifier
predictedLabels = predict(classifier, testFeatures, 'ObservationsIn', 'columns');
% Get the known labels
testLabels = testSet.Labels;
% Tabulate the results using a confusion matrix.
confMat = confusionmat(testLabels, predictedLabels);
% Convert confusion matrix into percentage form
confMat = bsxfun(@rdivide,confMat,sum(confMat,2));
disp(confMat);
% Display the mean accuracy
mean(diag(confMat))
testImage = readimage(testSet,1);
testLabel = testSet.Labels(1)
%%
% Create augmentedImageDatastore to automatically resize the image when
% image features are extracted using activations.
ds = augmentedImageDatastore(imageSize, testImage, 'ColorPreprocessing', 'gray2rgb');
% Extract image features using the CNN
imageFeatures = activations(net, ds, featureLayer, 'OutputAs', 'columns');
% Make a prediction using the classifier
predictedLabel = predict(classifier, imageFeatures, 'ObservationsIn', 'columns')

Binary file not shown.

Binary file not shown.