diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 31e085c..b6b6ff3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,7 +9,8 @@ android:roundIcon="@mipmap/ic_launcher_custom" android:supportsRtl="true" android:theme="@style/AppTheme"> - + + diff --git a/app/src/main/java/com/example/voiceprescription/FRONTACTIVITY.java b/app/src/main/java/com/example/voiceprescription/FRONTACTIVITY.java index 00dbd64..6648b5f 100644 --- a/app/src/main/java/com/example/voiceprescription/FRONTACTIVITY.java +++ b/app/src/main/java/com/example/voiceprescription/FRONTACTIVITY.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; @@ -14,6 +15,10 @@ public class FRONTACTIVITY extends AppCompatActivity implements AdapterView.OnItemSelectedListener { + String user; + String age; + EditText name; + EditText ag; @Override protected void onCreate(Bundle savedInstanceState) { @@ -24,10 +29,13 @@ protected void onCreate(Bundle savedInstanceState) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); - EditText name =(EditText) findViewById(R.id.editText); - EditText age =(EditText) findViewById(R.id.editText1); - Spinner gen = (Spinner) findViewById(R.id.spinner); - Button pro = (Button)findViewById(R.id.button); + name = findViewById(R.id.editText); + ag = findViewById(R.id.editText1); + Spinner gen = findViewById(R.id.spinner); + Button pro = findViewById(R.id.button); + + + pro.setOnClickListener (new View.OnClickListener() { @Override @@ -36,6 +44,12 @@ public void onClick(View v) Intent in= new Intent(FRONTACTIVITY.this, prescription.class); + user = name.getText().toString(); + age= ag.getText().toString(); + + in.putExtra("Name",user); + in.putExtra("Age",age); + startActivity(in); } @@ -52,9 +66,5 @@ public void onItemSelected(AdapterView parent, View view, int position, long public void onNothingSelected(AdapterView parent) { } - public void text1(View view) - { - - } } diff --git a/app/src/main/java/com/example/voiceprescription/fourthactivity.java b/app/src/main/java/com/example/voiceprescription/fourthactivity.java new file mode 100644 index 0000000..49bd4b8 --- /dev/null +++ b/app/src/main/java/com/example/voiceprescription/fourthactivity.java @@ -0,0 +1,83 @@ +package com.example.voiceprescription; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.util.Log; +import android.widget.TextView; + +public class fourthactivity extends AppCompatActivity { + + TextView tv; + String st; + TextView tv1; + String st1; + + TextView tv2; + String st2; + + TextView tv3; + String st3; + + TextView tv4; + String st4; + + TextView tv5; + String st5; + + TextView tv6; + String st6; + + + TextView tv7; + String st7; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fourthactivity); + + tv=findViewById(R.id.textView5); + st= getIntent().getStringExtra("Name1"); + Log.i("TAG",st); + tv.setText(st); + + tv1 =findViewById(R.id.textView8); + st1=getIntent().getStringExtra("Age1"); + tv1.setText(st1); + + + + tv2 =findViewById(R.id.diag); + st2=getIntent().getStringExtra("Diag"); + tv2.setText(st2); + + tv3 =findViewById(R.id.sym); + st3=getIntent().getStringExtra("sym"); + tv3.setText(st3); + + tv4 =findViewById(R.id.drg); + st4=getIntent().getStringExtra("drug"); + tv4.setText(st4); + + + tv5 =findViewById(R.id.dos); + st5=getIntent().getStringExtra("dosages"); + tv5.setText(st5); + + tv6 =findViewById(R.id.per); + st6=getIntent().getStringExtra("con"); + tv6.setText(st6); + + + tv7 =findViewById(R.id.adv); + st7=getIntent().getStringExtra("adv"); + tv7.setText(st7); + + + + + } +} diff --git a/app/src/main/java/com/example/voiceprescription/prescription.java b/app/src/main/java/com/example/voiceprescription/prescription.java index 796dfa9..91a7466 100644 --- a/app/src/main/java/com/example/voiceprescription/prescription.java +++ b/app/src/main/java/com/example/voiceprescription/prescription.java @@ -6,20 +6,51 @@ import android.content.Intent; import android.os.Bundle; import android.speech.RecognizerIntent; +import android.util.Log; import android.view.View; -import android.widget.ImageButton; +import android.widget.Button; import android.widget.TextView; -import android.widget.Toast; import java.util.ArrayList; import java.util.Locale; public class prescription extends AppCompatActivity { - private static final int REQUEST_CODE_SPEECH_INPUT = 1000 ; + Button bt; + String a; + String b; + String c; + String d; + String e; + String f; + String gi; + String h; + + + + + //private static final int REQUEST_CODE_SPEECH_INPUT = 1000; + + TextView text1; + //ImageButton button1; + + TextView text2; + //ImageButton button2; + + TextView text3; + //ImageButton button3; + + TextView text4; + //ImageButton button4; + + TextView text5; + //ImageButton button5; + + TextView text6; + //ImageButton button6;*/ + + - TextView textview1; - ImageButton imagebutton1; @Override @@ -27,56 +58,286 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_prescription); - textview1 = findViewById(R.id.editText2); - imagebutton1 = findViewById(R.id.imageButton); + text1 = findViewById(R.id.editText2); + // button1 = findViewById(R.id.imageButton); + + text2 = findViewById(R.id.sym); + //button2 = findViewById(R.id.b1); + + text3 = findViewById(R.id.dr); + //button3 = findViewById(R.id.b2); + + text4 = findViewById(R.id.dos); + //button4 = findViewById(R.id.b3); + + text5 = findViewById(R.id.con); + // button5 = findViewById(R.id.b4); + + text6 = findViewById(R.id.adv); + //button6 = findViewById(R.id.b5);*/ + //button click to show voice to text recognition - imagebutton1.setOnClickListener(new View.OnClickListener() { + /* button1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + speak(); + } + }); + + button2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + speak(); + } + + + }); + button3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + speak(); + } + + + }); + + button4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + speak(); + } + + + }); + + button5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + speak(); + } + + + }); + + button6.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { speak(); } + + + });*/ + + + bt = findViewById(R.id.generate); + a= getIntent().getStringExtra("Name"); + b=getIntent().getStringExtra("Age"); + + + + bt.setOnClickListener(new View.OnClickListener() + { + @Override + public void onClick(View v) { + opennext(); + + } }); } + public void opennext() + { + + Intent g = new Intent(prescription.this , fourthactivity.class); + c=text1.getText().toString(); + d=text2.getText().toString(); + e=text3.getText().toString(); + f=text4.getText().toString(); + gi=text5.getText().toString(); + h=text6.getText().toString(); + + + + + + + + g.putExtra("Name1",a); + g.putExtra("Age1",b); + g.putExtra("Diag", c); + g.putExtra("sym", d); + g.putExtra("drug", e); + g.putExtra("dosages", f); + g.putExtra("con", gi); + g.putExtra("adv", h); + + + + startActivity(g); + } + + - private void speak() { + + public void get1(View view) { + Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + + if (intent.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent, 10); + + } + + + } + + public void get2(View view) { + Intent intent1 = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent1.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent1.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + + if (intent1.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent1, 11); + + } + + + } + public void get3(View view) { + Intent intent2 = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent2.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent2.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + + if (intent2.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent2, 12); + + } + } + + public void get4(View view) { + Intent intent3 = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent3.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent3.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + + if (intent3.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent3, 13); + + } + } + + public void get5(View view) { + Intent intent4 = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent4.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent4.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + + if (intent4.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent4, 14); + + } + } + + public void get6(View view) { + Intent intent5 = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent5.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent5.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); + + if (intent5.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent5, 15); + + } + } + + + /*private void speak() { //intent to show speech to text dialog Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); - intent.putExtra(RecognizerIntent.EXTRA_PROMPT,"Please Say the symptoms.."); + intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Analyze Diagnosis"); //start intent - try{ + try { startActivityForResult(intent, REQUEST_CODE_SPEECH_INPUT); - } - catch(Exception e){ + } catch (Exception e) { - Toast.makeText(this,""+e.getMessage(), Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "" + e.getMessage(), Toast.LENGTH_SHORT).show(); } } //receive voice input and handle it - + */ @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); - switch(requestCode){ - case REQUEST_CODE_SPEECH_INPUT: - { + switch (requestCode) { + case 10: if (resultCode == RESULT_OK && null != data) { ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); - textview1.setText(result.get(0)); + text1.setText(result.get(0)); + + } + break; + case 11: + if (resultCode == RESULT_OK && null != data) { + ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); + text2.setText(result.get(0)); + + + } + break; + case 12: + if (resultCode == RESULT_OK && null != data) { + ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); + text3.setText(result.get(0)); + + + } + break; + case 13: + if (resultCode == RESULT_OK && null != data) { + ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); + text4.setText(result.get(0)); + + + } + break; + + case 14: + if (resultCode == RESULT_OK && null != data) { + ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); + text5.setText(result.get(0)); + + + } + break; + + case 15: + if (resultCode == RESULT_OK && null != data) { + ArrayList result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); + text6.setText(result.get(0)); + + + } + break; + + + - break ; - } } } + + } + + + + + diff --git a/app/src/main/res/drawable-v24/prescription.jpg b/app/src/main/res/drawable-v24/prescription.jpg new file mode 100644 index 0000000..5f3e2ae Binary files /dev/null and b/app/src/main/res/drawable-v24/prescription.jpg differ diff --git a/app/src/main/res/drawable-v24/prescriptionformat.jpg b/app/src/main/res/drawable-v24/prescriptionformat.jpg new file mode 100644 index 0000000..7baca33 Binary files /dev/null and b/app/src/main/res/drawable-v24/prescriptionformat.jpg differ diff --git a/app/src/main/res/drawable/ic_keyboard_voice.xml b/app/src/main/res/drawable/ic_keyboard_voice.xml new file mode 100644 index 0000000..831bb5f --- /dev/null +++ b/app/src/main/res/drawable/ic_keyboard_voice.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/font/sega.TTF b/app/src/main/res/font/sega.TTF new file mode 100644 index 0000000..3278377 Binary files /dev/null and b/app/src/main/res/font/sega.TTF differ diff --git a/app/src/main/res/layout/activity_fourthactivity.xml b/app/src/main/res/layout/activity_fourthactivity.xml new file mode 100644 index 0000000..be4902b --- /dev/null +++ b/app/src/main/res/layout/activity_fourthactivity.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_frontactivity.xml b/app/src/main/res/layout/activity_frontactivity.xml index 194ac76..ac6dfd8 100644 --- a/app/src/main/res/layout/activity_frontactivity.xml +++ b/app/src/main/res/layout/activity_frontactivity.xml @@ -13,7 +13,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" - android:layout_marginTop="250dp" + android:layout_marginTop="250sp" android:background="#11000000" android:gravity="center_horizontal" android:ems="10" @@ -27,7 +27,7 @@ android:ems="10" android:layout_centerHorizontal="true" android:gravity="center_horizontal" - android:layout_marginTop="300dp" + android:layout_marginTop="300sp" android:background="#11000000" android:inputType="textPersonName" android:hint="Enter Patient's Age"/> @@ -39,7 +39,7 @@ android:gravity="center_horizontal" android:layout_centerHorizontal="true" - android:layout_marginTop="350dp" + android:layout_marginTop="350sp" /> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 73e1083..1855924 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -9,11 +9,11 @@ + tools:context=".prescription"> + + + + + + + android:gravity="center" + android:hint="Tap On Mic" + android:inputType="textPersonName" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + +